Mining Gadget doesn't unlock Lost Trinkets
NielsPilgaard opened this issue · 2 comments
The Mining Gadget from the mod of the same name does not unlock Lost Trinkets ever, I was hoping you could help me inform the Mining Gadgets developers on which actions they could take to remedy this? :)
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.