
Blocks Should Not destroyed !
drkhodakarami opened this issue ยท 4 comments
Hi
This is a common scenario that happens for me everytime I mine at level -53:
Normally I use stone hammers, why? cheap, and good for tunneling and looking for resources. How ever, stone tool is not capable of breaking redstone or diamond ore. So, what happens? I see the block break, and no Item drops. It's exactly like when you break the block with a stone pickaxe. How ever, a better approach would be to leave the block untouched! This way, we would be able to use stone hammers and dig tunnels fast. Then come back and take the ore by proper tool.
I understand that forcing the blocks to break, can motivate people using higher grade hammers, but even with this thought in mind, destroying blocks of diamond simply because someone is using stone hammer for cheap early game access and not paying attention to the block being in the digging area, and as the result, loosing precious diamonds..... I would suggest to change the mechanics here lol !
I just submitted a pull request to fix this issue.
This fix also makes it so hammers only radius mine blocks that require a pickaxe (Stone, Ore), that is logically how the hammers should work anyway but that functionality could always be re-implemented with hammer upgrades.
I just submitted a pull request to fix this issue.
This fix also makes it so hammers only radius mine blocks that require a pickaxe (Stone, Ore), that is logically how the hammers should work anyway but that functionality could always be re-implemented with hammer upgrades.
This is not solving the issue completely, if you dive into level -52, use any hammer until you find redstone, or diamond, then try a stone hammer. now, choose a mineable stone block beside those two. you will see that the redsrone or diamond will be broken and dropped down even when you are using a stone hammer.
it partially fixed the issue that no item would be dropped, how ever, the main section that needs to be fixed is the canDestroy method. it should compare the block itself, with the material of the tool and make decision if the block IS DESTROYABLE by this material level or not.
this is for fabric, not sure what is the api call in architectury
`private boolean canDestroy(BlockState targetState, World world, BlockPos pos)
{
if (targetState.getHardness(world, pos) <= 0)
return false;
if(!this.isSuitableFor(targetState))
return false;
if (targetState.isIn(ModTags.Blocks.HAMMER_NO_SMASHY))
return false;
return world.getBlockEntity(pos) == null;
}`
as you see the second condition is checking if the block is minable by the tool material or not. if not, it will send back false and move to the next block on iterator