Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable sign edit #449

Open
wants to merge 3 commits into
base: pre-rewrite/fabric/1.20.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/fi/dy/masa/tweakeroo/config/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.)");
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<ActionResult> 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(" +
Expand Down