InventoryHolder on blocks does not save?

Discussion in 'Plugin Development' started by Vilsol, Oct 24, 2013.

Thread Status:
Not open for further replies.
  1. I am very confused about this, I have tried many ways and none of them seem to work.

    Here is the code:
    Code:java
    1. if(inv != null){
    2. if(realBlock.getState() instanceof InventoryHolder){
    3. ((InventoryHolder) realBlock.getState()).getInventory().setContents(inv.getContents());
    4. realBlock.getState().update(true);
    5. Bukkit.broadcastMessage("Inventory updated.");
    6. }
    7. }


    What it is supposed to do is first, check if the inv is not null, yes it is not. Then it checks if the block is an actual inventory holder (Chest, Dispenser, etc), which also works. Then it is setting the inventory of block to the one stored in inv variable, and then update the block so it sends to players.

    How do I know there are no errors and the code executes? The Bukkit.broadcast broadcasts the message...

    I have no idea why it does not work, I have tried removing the update, does not work either...

    I have tried running for loops, just to check that the inventory actually contains something, and it does... The size is equal to the required one.

    Bump?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  2. Come one, someone must know this...

    I would appreciate at least some help...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  3. Really no one knows this?
     
Thread Status:
Not open for further replies.

Share This Page