[Protection Issue] Chisel is not checking if a block is protected before chiseling
See original GitHub issueAfter triaging and investigating a SpongeForge interoperability issue when protection plugins wish to keep blocks from being modified/broken, I’ve since resolved parts of the issue reported to us https://github.com/SpongePowered/SpongeForge/issues/2167, however a new issue is arising and I think I know why:
When an already chiseled block is being interacted by another player (regardless whether Sponge is installed at this point or not), there’s a succeed fast check whether a block can be chiseled: https://github.com/AlgorithmX2/Chisels-and-Bits/blob/1.12/src/main/java/mod/chiselsandbits/items/ItemChisel.java#L397-L410
The issue with the line:
state.getBlock() instanceof BlockChiseled
is short circuiting any protection or harvestability checks for the desired block position, so even though the block is already chiseled, the drops (bits) can be cancelled, but the block modification can still go through.
I’d go as far as eliminating the succeed fast check since protection would then be able to determine that the chisel can be used at that time (and Forge’s harvest block event can be thrown).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:12
Top GitHub Comments
That works! Many thanks for adding the various checks!
Ok, so I think the original issue is resolved with the chisel, but now it’s a matter of the bits being placed on an existing chiseled block. I haven’t explored the source or threaded through yet to see if any events are thrown, but that might be what’s going on.
To clarify: The original issue was that you could chisel blocks regardless whether they were owned because no events or harvest checks were being called.
The new issue is that you can modify chiseled blocks, as it appears there’s no event check present. I’m going to dig further and see if I can narrow down where we can add some block modification check of sorts.
From a cursory glance, I’m under the belief that this block of code is where bits are being either placed to create a new block, or being placed into an existing chiseled block? I’m suspecting some sort of block check (maybe
server.isBlockProtected()
) before performing additional changes?