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

Block.BreakBlockNaturally(ItemStack tool) does not seem to reflect tool used

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-2040c4c-1872231 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
    • Yes

      Block.BreakBlockNaturually(ItemStack tool) does not seem to respect the tool being used. For example, if the block is diamond ore and the tool is a wooden pick, the block should break but not drop diamonds. Similarly, some blocks, if broken with hands (tool = AIR) should not drop the block at all. It appears as if this parameter has no effect.

      If it is used, breaking blocks with bare hands will drop the block. Breaking blocks with incorrect tools will drop drops.

      Test plugin:

      public class TestPlugin extends JavaPlugin implements Listener {
          @Override
          public void onEnable() {
              Bukkit.getPluginManager().registerEvents(this, this);
          }
      
      
          @EventHandler
          public void onBlockBreak(BlockBreakEvent e) {
              ItemStack inHand = e.getPlayer().getInventory().getItemInMainHand();
              Bukkit.getLogger().info("Breaking block " + e.getBlock() + " with " + inHand);
              e.setCancelled(true);
              e.getBlock().breakNaturally(inHand);
          }
      }
      

       

       

            Unassigned Unassigned
            tastybento tastybento
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: