fix tools bypassing claims again

This commit is contained in:
Flemmli97 2022-01-23 01:13:27 +01:00
parent 9a49225c19
commit 14249c196a
4 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,8 @@
Flan 1.6.9
======================
- Fix claiming tools bypassing permissions *cough*
- Also fix claiming tool still doing their normal actions (aka hoeing the ground)
Flan 1.6.8
======================
- Rewrite block interaction check again which should fix some issues with it

View File

@ -74,7 +74,10 @@ public class FlanFabric implements ModInitializer {
public static InteractionResult useBlocks(Player p, Level world, InteractionHand hand, BlockHitResult hitResult) {
if (p instanceof ServerPlayer serverPlayer) {
ItemUseBlockFlags flags = ItemUseBlockFlags.fromPlayer(serverPlayer);
flags.stopCanUseBlocks(BlockInteractEvents.useBlocks(p, world, hand, hitResult) == InteractionResult.FAIL);
InteractionResult res = BlockInteractEvents.useBlocks(p, world, hand, hitResult);
if (res == InteractionResult.SUCCESS)
return res;
flags.stopCanUseBlocks(res == InteractionResult.FAIL);
flags.stopCanUseItems(ItemInteractEvents.onItemUseBlock(new UseOnContext(p, hand, hitResult)) == InteractionResult.FAIL);
}
return InteractionResult.PASS;

View File

@ -28,10 +28,15 @@ public class BlockInteractEventsForge {
public static void useBlocks(PlayerInteractEvent.RightClickBlock event) {
InteractionResult res = BlockInteractEvents.useBlocks(event.getPlayer(), event.getWorld(), event.getHand(), event.getHitVec());
if(res == InteractionResult.FAIL)
if (res == InteractionResult.SUCCESS) {
event.setCancellationResult(res);
event.setCanceled(true);
return;
}
if (res == InteractionResult.FAIL)
event.setUseBlock(Event.Result.DENY);
res = ItemInteractEvents.onItemUseBlock(new UseOnContext(event.getPlayer(), event.getHand(), event.getHitVec()));
if(res == InteractionResult.FAIL)
if (res == InteractionResult.FAIL)
event.setUseItem(Event.Result.DENY);
}
}

View File

@ -10,7 +10,7 @@ forge_version=1.18.1-39.0.14
loader_version=0.12.8
# Mod Properties
mod_version=1.6.8
mod_version=1.6.9
maven_group=io.github.flemmli97
archives_base_name=flan