setItem(row, column) [HELP]

Discussion in 'Plugin Development' started by NewGarbo, Apr 23, 2014.

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

    NewGarbo

    All I need to know is how would I go about having a method which is along these lines: setItem(row, column, inventory, itemstack)? Please help! :)
     
  2. Offline

    SuppaTim

    <inv>.setItem(<slot>, <itemstack>);

    Slot = 0 - <max slot size inventory>, every 9 slots (0-8 > 9-17 > etc) is a column.
     
  3. Offline

    NewGarbo

    SuppaTim What? please elaborate more :S
     
  4. Offline

    SuppaTim

    To set an item in an inventory you use the method descripted above.
    You give it an integer, the slot, and an itemstack. The slot is an integer from 0 to the inventory's max size. So myInv.setItem(10, new ItemStack(Material.STICK)); would set the second slot from left in the second row to a stick.

    Example inv:
    Code = myInv.setItem(10, stick);
    # = Empty
    / = Stick

    #########
    #/#######
    #########
     
  5. Offline

    1Rogue


    Inventory has a method named "setItem", it accepts two arguments (The slot number, and the ItemStack to set).
     
  6. Offline

    AoH_Ruthless

    SuppaTim
    Actually, item 10 is at the tippity-top row, 2nd column.

    [​IMG]
     
  7. Offline

    SuppaTim

    I actually thought he meant an inventory more like a chest idea, but if he didn't, my bad.
     
  8. Offline

    AoH_Ruthless

    SuppaTim
    Crap, I did just like you in assuming, but I assumed he was speaking of a player inventory.
     
  9. Offline

    NewGarbo

    I have no idea how to do this :'(
     
  10. Offline

    Garris0n

    First, what on earth do you need this for?

    Second, just some simple math. Think about what you're trying to do, you'll figure it out.
     
  11. Offline

    Krijn

    All you have to do is yourInventory.setItem(slotNumber, nameOfItemStack);
     
Thread Status:
Not open for further replies.

Share This Page