Chisels & Bits - For Fabric

Chisels & Bits - For Fabric

2M Downloads

[Protection Issue] Chisel is not checking if a block is protected before chiseling

gabizou opened this issue ยท 12 comments

commented

After 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 SpongePowered/SpongeForge#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).

commented

spongeforge-1.12.2-2690-7.1.0-BETA-0.jar.zip
And try with this version of SpongeForge please, I added another mixin location to ensure the pre block event check is going through on sponge's end.

commented

I'll try and i'll tell you

commented

Thats not working, we can still modify the already chiseled blocks. i tried to relog/restart client&server block is really modified serverside.

commented

As you can see here, i can't modify full blocks but already chiseled blocks can be updated (breaked or placed)

https://i.imgur.com/nPkDjYX.mp4

commented

Also, i know thats not really the good place too ask i should open another issue but as i'm not sure its one, is it normal that placing bits doesnt make sounds as breaking makes one?

commented

@gabizou Any idea why its not working? Was I missing something with regards to your observation? I couldn't simply remove the test as its recursive, however calling to the original parent method seemed like a good second. Did I miss understand something?

@TeKGameR950 I'll look at it when I have a moment.

commented

Could you give me a version where it return false to check if i can modify the block or not? if i can its propably because there is another check elsewhere

commented

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?

commented

Hi, any news about fixing this issue?

commented

Here is another version with additional tests in the packet handling.

https://www.dropbox.com/s/71rjnqxxrwipn17/chiselsandbits-14.18b.jar?dl=1

commented

That works! Many thanks for adding the various checks!