Closed Paul-16098 closed 2 months ago
This bug happens because the block is only destroyed when the Breaker is able to get items from the block's loot table. As leaves have a randomized chance of giving items normally, they are not destroyed unless that randomized chance is triggered.
This will be fixed in the next version of the mod. Thank you for reporting it.
Bug has hopefully been fixed in version 1.0.2+1.21. The mod now checks the tool's capabilities against the target block's hardness and takes that into account as well when deciding whether the block can be broken.
Please let me know if you find any other strange behaviour. Thank you!
https://github.com/user-attachments/assets/b115b3ec-d5f4-403a-a4c0-b23f6775c19f
/**
* miningSpeed > 0.95F ensures all hand-breakable items are breakable
* miningSpeed >= blockHardness ensures the correct tools are used for harder-than-hand-breakable blocks
**/
public boolean canBreakBlock(ItemStack stack, CachedBlockPosition cachedPos) {
// Get target block's information from cached position
BlockState blockState = cachedPos.getBlockState();
BlockPos blockPos = cachedPos.getBlockPos();
WorldView world = cachedPos.getWorld();
// Check if the item is a tool and get its mining speed
float miningSpeed = stack.getMiningSpeedMultiplier(blockState);
// Check the block's hardness
float blockHardness = blockState.getHardness(world, blockPos);
// Determine if the tool can break the block
boolean canBreak = miningSpeed > 0.95F && miningSpeed >= blockHardness;
// Additional check for specific tool materials if needed
boolean isCorrectTool = stack.isSuitableFor(blockState);
return canBreak || isCorrectTool;
}
A by-product of this method is that blocks such as wooden logs can now only be broken with a wooden axe or greater, as their hardness
is 2.0
. I think this is an acceptable drawback, but if any outlandish examples are found please let me know.
the breaker is not destroy leaves
1.21.1-NeoForge_21.1.22 breakerplacer-1.0.1+1.21 Sinytra Connector-2.0.0-beta.2+1.21.1 Forgified Fabric API-0.102.0+2.0.12+1.21.1