Solved Make a loop for glass panels

Discussion in 'Plugin Development' started by TheFl4me, Jun 12, 2015.

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

    TheFl4me

    HI im trying to make a simple loop to fill all empty slots in an inventory.
    The way i have it right now it only stacks up the glass panels. How can i make it so that it makes a single stack or every panel.

    Code:
    for(int i = 0; i < 54; i++) {
                inv.addItem(new ItemStack(glass));
            }
     
  2. Offline

    TomTheDeveloper

    new ItemStack(glass, amount)
     
  3. Offline

    TheFl4me

    I cannot add the amount, when i do it says this:
    "The constructor ItemStack(ItemStack, int) is undefined"
     
  4. Offline

    TomTheDeveloper

  5. Offline

    FisheyLP

    Code:java
    1. inventory.setItem(slot, itemstack);
     
  6. Offline

    TheFl4me

    I know that method but i am looking for a loop that can fill all the emtpy slots without having to enter all of them manually. What you said wont work since there already re some items in the inventory.

    that already is the case:

    Code:
    ItemStack glass = new ItemStack(Material.THIN_GLASS, 1);
     
  7. Offline

    TomTheDeveloper

    Then check if the slot is empty... and if it's not then add an item to it
     
  8. Offline

    TheFl4me

    How do it do that? xd
     
  9. Offline

    FisheyLP

    Code:
    if (item == null || item.getType() == Material.AIR)
     
  10. Offline

    TheFl4me

    i know that but how do i define "item"?

    EDIT: nvm got it thx :).
     
    Last edited: Jun 12, 2015
  11. Offline

    I Al Istannen

    @TheFl4me Either with an enhanced for loop through "inv.getContents()" or by a normal for loop and using "inv.getItem(int index)".
     
  12. Offline

    TheFl4me

    yeah 3 sec after i wrote that last comment i found out the "inv.getItem(i)" part. thx anyways :)
     
Thread Status:
Not open for further replies.

Share This Page