diff --git a/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java b/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java index 9977f79b6..c11fb7988 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java +++ b/src/main/java/fi/dy/masa/tweakeroo/config/Configs.java @@ -299,6 +299,7 @@ public static class Disable public static final ConfigBooleanHotkeyed DISABLE_SCOREBOARD_RENDERING = new ConfigBooleanHotkeyed("disableScoreboardRendering", false, "", "Removes the sidebar scoreboard rendering"); public static final ConfigBooleanHotkeyed DISABLE_SHULKER_BOX_TOOLTIP = new ConfigBooleanHotkeyed("disableShulkerBoxTooltip", false, "", "Disables the vanilla text tooltip for Shulker Box contents"); public static final ConfigBooleanHotkeyed DISABLE_SHOVEL_PATHING = new ConfigBooleanHotkeyed("disableShovelPathing", false, "", "Disables converting grass etc. to Path Blocks with a shovel"); + public static final ConfigBooleanHotkeyed DISABLE_SIGN_EDIT = new ConfigBooleanHotkeyed("disableSignEdit", false, "", "Disables the sign edit gui when a sign is right clicked\n(Sneak + right click to edit)"); public static final ConfigBooleanHotkeyed DISABLE_SIGN_GUI = new ConfigBooleanHotkeyed("disableSignGui", false, "", "Prevent the Sign edit GUI from opening"); public static final ConfigBooleanHotkeyed DISABLE_SKY_DARKNESS = new ConfigBooleanHotkeyed("disableSkyDarkness", false, "", "Disables the sky darkness below y = 63\n\n(By moving the threshold y to 2 blocks below the bottom of the world instead)"); public static final ConfigBooleanHotkeyed DISABLE_SLIME_BLOCK_SLOWDOWN = new ConfigBooleanHotkeyed("disableSlimeBlockSlowdown", false, "", "Removes the slowdown from walking on Slime Blocks.\n(This is originally from usefulmod by nessie.)"); @@ -345,6 +346,7 @@ public static class Disable DISABLE_SCOREBOARD_RENDERING, DISABLE_SHULKER_BOX_TOOLTIP, DISABLE_SHOVEL_PATHING, + DISABLE_SIGN_EDIT, DISABLE_SIGN_GUI, DISABLE_SKY_DARKNESS, DISABLE_SLIME_BLOCK_SLOWDOWN, diff --git a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinClientPlayerInteractionManager.java b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinClientPlayerInteractionManager.java index 4b970e296..84c7c92b3 100644 --- a/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinClientPlayerInteractionManager.java +++ b/src/main/java/fi/dy/masa/tweakeroo/mixin/MixinClientPlayerInteractionManager.java @@ -1,5 +1,9 @@ package fi.dy.masa.tweakeroo.mixin; +import net.minecraft.block.entity.SignBlockEntity; +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.item.HoneycombItem; +import net.minecraft.util.hit.BlockHitResult; import org.apache.commons.lang3.mutable.MutableObject; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -47,6 +51,26 @@ private void onProcessRightClickFirst(PlayerEntity player, Hand hand, CallbackIn } } + @Inject(method = "interactBlock", at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;sendSequencedPacket(" + + "Lnet/minecraft/client/world/ClientWorld;" + + "Lnet/minecraft/client/network/SequencedPacketCreator;" + + ")V"), + cancellable = true) + private void onProcessRightClickFirst(ClientPlayerEntity player, Hand hand, BlockHitResult hitResult, CallbackInfoReturnable cir) + { + if (!player.shouldCancelInteraction() && + !(player.getStackInHand(hand).getItem() instanceof HoneycombItem) && + Configs.Disable.DISABLE_SIGN_EDIT.getBooleanValue() && + player.getWorld().getBlockEntity(hitResult.getBlockPos()) instanceof SignBlockEntity sbe && + !sbe.isWaxed()) + { + cir.setReturnValue(ActionResult.SUCCESS); + cir.cancel(); + } + } + @Inject(method = "method_41929", slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;use(" +