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

BlockState Chest#getInventory() no longer returns a double chest inventory for double chests.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version dev-Spigot-dc75aca-11c9299 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT)
    • Yes

      Testing code:

      @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
          public void onPlayerInteractEvent(PlayerInteractEvent event) {
              if (event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
              if (event.getHand() != EquipmentSlot.HAND) return;
              if (event.getItem() == null || event.getItem().getType() != Material.STICK) return;
              Block block = event.getClickedBlock();
              if (block == null || block.getType() != Material.CHEST) return;        Player player = event.getPlayer();
              player.sendMessage("right clicked chest with stick");
              event.setCancelled(true);
              Bukkit.getScheduler().runTaskLater(Test.INSTANCE, () -> {
                  if (!player.isValid()) return;
                  if (block.getType() != Material.CHEST) return;            player.sendMessage("Opening chest ..");
                  Chest chest = (Chest) block.getState();
                  Inventory inventory = chest.getInventory();
                  player.sendMessage("  " + inventory.getClass().getName());
                  player.sendMessage("  " + inventory.getHolder().getClass().getName());
                  player.openInventory(inventory);
              }, 20L);
          } 

      Right clicking a double chest with a stick only opens one half of the double chest and yields the following output in chat:

      Opening chest ..
        org.bukkit.caftbukkit.v1_17_R1.inventory.CraftInventory
        org.bukkit.caftbukkit.v1_17_R1.block.CraftChest

            Unassigned Unassigned
            blablubbabc blablubbabc
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: