How do i set a users inventory slot? (ID and Amount)

Discussion in 'Plugin Development' started by EvilPeanut, Oct 15, 2011.

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

    EvilPeanut

    How do i set a users inventory slot?

    Lets say i want slot 2 to be 64 stone, whats the code?
     
  2. Offline

    coldandtired

    You need to create an ItemStack with the Stone, and then the Inventory class has a SetItem Method which takes the index of the backpack slot and the ItemStack you created.
     
  3. Code:java
    1. player.getInventory().setItem(2, new ItemStack(Material.STONE, 64));

    In that code 2 is the slot. You can use 0-8.
     
  4. Offline

    Pasukaru

    Code:java
    1. player.getInventory().setItem(2, new ItemStack(Material.STONE, 64));

    [edit]
    Oh well, @r3Fuze was faster :p
     
    r3Fuze likes this.
  5. Offline

    EvilPeanut

    Cheers guys :D

    Oooooh ACDC :D U rock!
    NOTE: I saw ACDC live France 2010 it was fkin awsome

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 20, 2016
Thread Status:
Not open for further replies.

Share This Page