Wierd chest inventory glitch

Discussion in 'Plugin Development' started by nitrousspark, Jun 13, 2013.

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


    currently in a plugin im making loot chests, and ive got most things working, like the chest respawns, and the what not. but when the items get set in the chesst, it shows the items i put, but they are ghost items, that you cant pick up or take out. ive tried so much to fix this but it wont work. heres my code.

    final Location loc = chest.getLocation();
    final ItemStack[] itemlist = chest.getBlockInventory().getContents();
    final Integer time = DyrneProject.lootchests.get(chest);
    new BukkitRunnable()
    public void run()
    final Chest newChest = (Chest)loc.getBlock().getState();
    DyrneProject.lootchests.put(newChest, time);
    }.runTaskLater(DyrneProject.plugin, time * 20);

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 1, 2016
  2. Offline


    Maybe update the BlockState? newChest.update().
  3. Offline


    You should add a few prints to see if the values are what you expect.
    Figure out what the itemlist array looks like when you go to set the contents. Arrays set to final variables can still experience changes to the elements of them. They might all have 0 left in the stack because you looted the chest already.
Thread Status:
Not open for further replies.

Share This Page