Creators-of-Create / Create

[Forge Mod] Building Tools and Aesthetic Technology
MIT License
2.66k stars 864 forks source link

Fix dupe bug with using a wrench in claimed chunks #6467

Open Attack8 opened 1 month ago

Attack8 commented 1 month ago

Fixes FTBTeam/FTB-Mods-Issues#1162 Fixes #6465

desht commented 1 month ago

world.destroyBlock(pos, false) does not cause any block break events to be fired, so I don't believe this approach will work to account for claim protection mods (more precisely, it'll probably fix the original problem, but introduce a new one, where players can use a wrench to steal blocks from other players' claims). The false return from the method is purely based on vanilla checks.

Attack8 commented 1 month ago

You can give it a try yourself but it worked for me in testing. I will do further testing to confirm

desht commented 1 month ago

Did you try it with a mod like FTB Chunks installed, in a claim you can't normally break blocks in?

Arguably that's not necessarily a bug, since block-breaking is a feature of sneak+right-clicking the wrench, which is an item interaction rather than a block break. But from a gameplay point of view, it's equivalent to breaking a block, so if a player chooses to allow item interaction in their claims, they may be surprised when someone else comes in and steals their blocks...

Attack8 commented 1 month ago

Did you try it with a mod like FTB Chunks installed, in a claim you can't normally break blocks in?

Yes, I did

Arguably that's not necessarily a bug, since block-breaking is a feature of sneak+right-clicking the wrench, which is an item interaction rather than a block break. But from a gameplay point of view, it's equivalent to breaking a block, so if a player chooses to allow item interaction in their claims, they may be surprised when someone else comes in and steals their blocks...

Yes, I agree that it's a bug; it doesn't make sense gameplay-wise

Attack8 commented 1 month ago

Needs more 1.20.1 specific testing

desht commented 1 month ago

Should be pretty easy to get around; fire a Forge BlockEvent.BreakEvent before attempting to break the block, and if the event comes back canceled, don't proceed.

Attack8 commented 1 month ago

Yea, I’ll take a look at it this evening after school with specifically 1.20.1 since I can’t reproduce the bug in 1.18.2

Attack8 commented 1 month ago

Ok, fixed