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

setType(Material.AIR) on a Chest drops Chest contents

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • Minecraft 1.12.2

      Java 1.8.0_151 64bit

      Plugins installed:

      Multiverse-Core 2.5.0
      Vault 1.5.6
      PermissionsEx 1.23.4

      Using BlockBreakEvent, when calling method Block.setType(Material.AIR) to remove a Chest block in Creative mode, the block would be removed, no block would drop, but the Inventory contents of the block would be dropped.

      The intended behavior should be that the block is removed and no contents are dropped.

      The following code was used:

      event.setDropItems(false);
      event.setExpToDrop(0);
      block.setType(Material.AIR);
      event.setCancelled(true);
      

      Basis for the intended behavior in Vanilla would be to place a Chest with contents, and use /setblock x y z air to remove the block.  The Chest is removed and the contents are not dropped.

      The current work around is to remove the contents of the Chest before replacing the block type with Material.AIR, such as:

       

      event.setDropItems(false);
      event.setExpToDrop(0);
      BlockState bs = block.getState();
      if(bs instanceof Chest) {
        ((Chest) bs).getInventory().clear();
      }
      bs.setType(Material.AIR);
      bs.update(true);
      event.setCancelled(true);
      

       

       

       

       

            Unassigned Unassigned
            klugemonkey klugemonkey
            Votes:
            2 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated:
              Resolved: