Mining Gadgets

Mining Gadgets

33M Downloads

Mining Gadget doesn't unlock Lost Trinkets

NielsPilgaard opened this issue · 3 comments

commented

Original issue: EnigmaticaModpacks/Enigmatica6#2515
Question on Lost Trinkets tracker: owmii/Lost-Trinkets#80

The Mining Gadget does not unlock Lost Trinkets when mining. I asked for help relaying the issue on the Lost Trinkets tracker, and got this helpful response:

Lost Trinkets is using a mixin on Block#harvestBlock to detect when a block is broken. I'm not 100% sure why it's not using the Block Break event tbh (perhaps it had issues with trinkets dropping when they should due to the block break being canceled after it fired for the mod?). It gets called in PlayerInteractionManager#tryHarvestBlock(BlockPos pos).

Mining Gadget seems to replace the target block with a tile entity that stores the block state.
When RenderBlockTileEntity#removeBlock() is called, it doesn't seem to update the actual state of the block in world before getting the drops, I think this is okay, but it doesn't raise a block break event either... It does raise a block break event when checking for harvestibility though, which might cause some weird things to happen if a mod is listening in on that event to do something when a block is broken.

I think Mining gadget could do something similar to what the PSI mod does, where it temporarily sets the currently held item of the player to the tool to use for harvestability checks and when breaking the block and then turning it back (the latter doesn't happen in psi but it probably should, oops...).

In summary I'd take a look at the PlayerInteractionManager#tryHarvestBlock(BlockPos pos) method and try to call that some how with the desired mining tool being in the main hand for actually mining a block. As for checking for harvestibility without doing a break block event, could do something like what the PSI mod does, calling IForgeBlock#canHarvestBlock with the tool in the main hand will raise the proper events without breaking the block.

Do you guys think it would be possible to add compatibility with Lost Trinkets, given that information? :)

commented

Could this have been fixed in the latest release? :)

commented

Please re-open if this is an issue still in 1.21

commented

I'll try and rework how all this works soon 👍