From 826c4010be5294348403329db808cd6d261c573d Mon Sep 17 00:00:00 2001 From: AlignedCookie88 <52969840+AlignedCookie88@users.noreply.github.com> Date: Mon, 18 Nov 2024 22:19:45 +0000 Subject: [PATCH] [Feature] Client actions now display as redstone ore. --- .../mixin/SignBlockEntityMixin.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/alignedcookie88/fireclient/mixin/SignBlockEntityMixin.java b/src/main/java/com/alignedcookie88/fireclient/mixin/SignBlockEntityMixin.java index 8391660..581207f 100644 --- a/src/main/java/com/alignedcookie88/fireclient/mixin/SignBlockEntityMixin.java +++ b/src/main/java/com/alignedcookie88/fireclient/mixin/SignBlockEntityMixin.java @@ -2,9 +2,13 @@ import com.alignedcookie88.fireclient.FireClient; import com.alignedcookie88.fireclient.FireFunction; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.block.entity.SignBlockEntity; import net.minecraft.block.entity.SignText; import net.minecraft.text.Text; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -21,9 +25,22 @@ public class SignBlockEntityMixin { @Inject(method = "getFrontText", at = @At("HEAD"), cancellable = true) public void getFrontText(CallbackInfoReturnable cir) { SignText original = this.frontText; - if (Objects.equals(original.getMessage(0, false).getString(), "CALL FUNCTION")) { - if (original.getMessage(1, false).getString().startsWith("fireclient.")) { + boolean isAlreadyKnown = Objects.equals(original.getMessage(0, false).getString(), "CLIENT ACTION"); + if (isAlreadyKnown || Objects.equals(original.getMessage(0, false).getString(), "CALL FUNCTION")) { + if (isAlreadyKnown || original.getMessage(1, false).getString().startsWith("fireclient.")) { String functionId = original.getMessage(1, false).getString().replaceFirst("fireclient\\.", ""); + + BlockPos pos = ((SignBlockEntity) (Object) this).getPos(); + BlockPos oreBlock = pos.mutableCopy().add(1, 0, 0); + World world = ((SignBlockEntity) (Object) this).getWorld(); + + if (world.isChunkLoaded(oreBlock) && world.getBlockState(oreBlock).getBlock() != Blocks.REDSTONE_ORE) { + world.setBlockState(oreBlock, Blocks.REDSTONE_ORE.getDefaultState()); + } + + if (isAlreadyKnown) + return; + for (FireFunction function : FireClient.functionRegistry) { if (Objects.equals(function.getID(), functionId)) { SignText newSignText = original