When trying to lower the stack size of an ItemStack in a chest after the chunk has been reloaded (leave and reenter the area) after the first, initial chunk load, the chest inventory is not updating.
As said, this only happens after the chunk has been unloaded. After first entering the chunk everything is working fine.
chest.getChunk().load(true); for (int i = 0; i < chest.getInventory().getSize(); i++) { ItemStack is = chest.getInventory().getItem(i); if (is != null) { getServer().getLogger().info("stack has " + is.getAmount() + " items"); is.setAmount(is.getAmount() - amount); chest.getInventory().setItem(i, is); chest.update(true); } }
The behaviour is also described in the post on the forums: https://www.spigotmc.org/threads/chest-inventory-update-not-working.159674/