ItemStacking

Discussion in 'Plugin Development' started by Monckey100, Mar 30, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Monckey100

    >.< I know I been quite the bother, and thank you everyone for helping me out. but I got a problem with ItemStacking...
    first I can't figure out how to make an ItemStack have actual items, such as wooden axe, pickaxe etc.
    also this line of code seems to be bickering at me, so I couldn't figure it out how to fix it, even with documentation provided. >.<

    public void onPlayerRespawn(PlayerRespawnEvent event){
    Player player = event.getPlayer();
    ItemStack wooden = new ItemStack(Block.WOOD,64);
    Inventory inv = player.getInventory();
    inv.addItem(wooden);
    }

    [I want to give them wooden items, but since I couldn't figure the ItemStack I tried a simple set of 64 woods...which failed]
     
  2. Offline

    ssell

    @Monckey100

    Use Material not Block for making items. As an example, to add a wooden pickaxe to player's inventory:

    Code:
    public void onPlayerRespawn( PlayerRespawnEvent event )
    {
        event.getPlayer( ).getInventory( ).addItem( new ItemStack( Material.WOOD_PICKAXE, 1 ) );
    }
     
  3. Offline

    Monckey100

    it says its not applicable for the arguements(Item stack)
    the constructor material is undefined (material,int) is undefined

    [that was a direct copy pasta of what you wrote]

    also would like to note that I did try to use material earlier >.<

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  4. Offline

    ssell

    It works fine on my end and I am using the most recent Bukkit build. Are you importing Material? (org.bukkit.Material)

    edit:
    Here it is in the JavaDocs:

    addItem
    ItemStack
     
  5. Offline

    Monckey100

    I'm using the most recent bukkit build too, and yes the material is imported.

    I'm also having a problem working with Entities, I can't seem to get the event.getTarget() to work >.< bukkit just spews errors out

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  6. Offline

    Edward Hand

    PlayerRespawnEvent.getTarget()? There's no such function. What are you trying to do?
     
  7. Offline

    Monckey100

    no no no, that was a seperate question altogether. I was trying to check if a spider is attacking a human or if a human is attacking a cow etc. but my first one still stands which is basically giving a player wooden items when they die

    anyone X_X

    >.< its probably my bukkit or some crap, can someone link me to the most RECENT build

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  8. Offline

    ssell

  9. Offline

    Monckey100

    ah i figured it out, I was using craftbukkit as a reference library.
     
  10. Offline

    ssell

    That would do it! Glad you finally got it working :)
     
Thread Status:
Not open for further replies.

Share This Page