ItemStack[] Broken?

Discussion in 'Plugin Development' started by PatoTheBest, Apr 14, 2014.

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

    PatoTheBest

    Hello,
    When I try to set the chest contents to the itemstack, anything that was saved with a stack of 2 and more items would return as if it was saved as one item.

    Code(when trying to restore):
    Code:java
    1. for (Entry<Location, ItemStack[]> chest : chests.entrySet()){
    2. Location l = chest.getKey();
    3. Block block = l.getBlock();
    4. Chest c = (Chest) block.getState();
    5. c.getInventory().setContents(chest.getValue());
    6. }

    Code when Saving:
    Code:java
    1. if (event.getBlock().getType() == Material.CHEST){
    2. Chest chest = (Chest) event.getBlock().getState();
    3. chests.put(chest.getLocation(), chest.getInventory().getContents());
    4. }
     
  2. Offline

    PatoTheBest

  3. Offline

    coasterman10

    Is there anything that happens in between saving and getting the itemstacks that could be altering them?
     
Thread Status:
Not open for further replies.

Share This Page