Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-2486

Chest inventory not updating when edited via Plugin when the chunk has been reloaded

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major Major
    • None
    • None
    • Spigot server with no other plugin which could be interfering with the chest edit

      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/

            Unassigned Unassigned
            Sabbertran Sabbertran
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: