[SPIGOT-5718] Block.BreakBlockNaturally(ItemStack tool) does not seem to reflect tool used Created: 04/May/20  Updated: 09/May/20  Resolved: 09/May/20

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: tastybento Assignee: Unassigned
Resolution: Fixed Votes: 1
Labels: api

Attachments: File TestPlugin-1.11.1-SNAPSHOT-LOCAL.jar     Zip Archive TestPlugin.zip    
Version: This server is running CraftBukkit version git-Spigot-2040c4c-1872231 (MC: 1.15.2) (Implementing API version 1.15.2-R0.1-SNAPSHOT)
Guidelines Read: Yes

 Description   

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);
    }
}

 

 


Generated at Sat Apr 05 09:38:05 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.