From e2ff3c5a1489c7b64f4968b4f291f941d0cb80e8 Mon Sep 17 00:00:00 2001 From: Jess Date: Thu, 20 Jun 2024 02:03:04 +0100 Subject: [PATCH] i dont know tudbut perhaps you can rewrite this --- .../java/de/com/baseband/client/Setup.java | 1 + .../feature/modules/ingame/ColourSign.java | 51 +++++++++++++++++++ .../com/baseband/client/mixin/MixinProxy.java | 2 +- .../mixin/mixins/ICPacketUpdateSign.java | 14 +++++ .../src/main/resources/mixins.baseband.json | 3 +- 5 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 Client/src/main/java/de/com/baseband/client/feature/modules/ingame/ColourSign.java create mode 100644 Client/src/main/java/de/com/baseband/client/mixin/mixins/ICPacketUpdateSign.java diff --git a/Client/src/main/java/de/com/baseband/client/Setup.java b/Client/src/main/java/de/com/baseband/client/Setup.java index 374f5ae..262cb68 100644 --- a/Client/src/main/java/de/com/baseband/client/Setup.java +++ b/Client/src/main/java/de/com/baseband/client/Setup.java @@ -49,6 +49,7 @@ public class Setup { new ChatCrypt(), new ChatExtras(), new ChatFilter(), + new ColourSign(), new Notifier(), new ClickGUI(), new Connect(), diff --git a/Client/src/main/java/de/com/baseband/client/feature/modules/ingame/ColourSign.java b/Client/src/main/java/de/com/baseband/client/feature/modules/ingame/ColourSign.java new file mode 100644 index 0000000..616fef2 --- /dev/null +++ b/Client/src/main/java/de/com/baseband/client/feature/modules/ingame/ColourSign.java @@ -0,0 +1,51 @@ +package de.com.baseband.client.feature.modules.ingame; + +import de.com.baseband.client.event.events.PacketEvent; +import de.com.baseband.client.feature.Feature; +import de.com.baseband.client.mixin.mixins.ICPacketUpdateSign; +import de.com.baseband.client.registry.annotation.Config; +import net.minecraft.network.play.client.CPacketUpdateSign; + +public class ColourSign extends Feature { + @Override + public String toString() { + return "ColourSign"; + } + + @Config("Mode") + public Mode mode; + + enum Mode { + Vanilla, + Spigot + } + + @Override + public void onTick() { + meta = mode.name(); + } + + public void packetOut(PacketEvent event) { + if (event.getPacket() instanceof CPacketUpdateSign) { + ICPacketUpdateSign updateSignAccessor = ((ICPacketUpdateSign) event.getPacket()); + String[] lines = updateSignAccessor.getLines(); + for (int i = 0; i < 4; ++i) { + String line = lines[i]; + if (line != null && !line.isEmpty()) { + switch (mode) { + case Vanilla: { + lines[i] = line.replace("&", "§§0"); + break; + } + + case Spigot: { + lines[i] = line.replace("&", "§§§00"); + break; + } + } + } + } + updateSignAccessor.setLines(lines); + } + } +} diff --git a/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java b/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java index 5e049ab..a99c21c 100644 --- a/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java +++ b/Client/src/main/java/de/com/baseband/client/mixin/MixinProxy.java @@ -8,10 +8,10 @@ import de.com.baseband.client.event.events.PacketEvent; import de.com.baseband.client.feature.Features; import de.com.baseband.client.feature.modules.chat.ChatExtras; import de.com.baseband.client.feature.modules.client.Client; +import de.com.baseband.client.feature.modules.ingame.AutoSignText; import de.com.baseband.client.feature.modules.movement.Velocity; import de.com.baseband.client.feature.modules.render.NoRender; import de.com.baseband.client.feature.modules.render.SwingSpeed; -import de.com.baseband.client.feature.modules.ingame.AutoSignText; import de.com.baseband.client.util.adapt.FieldFinder; import de.com.baseband.client.util.net.ScreenshotHelper; import net.minecraft.client.gui.ChatLine; diff --git a/Client/src/main/java/de/com/baseband/client/mixin/mixins/ICPacketUpdateSign.java b/Client/src/main/java/de/com/baseband/client/mixin/mixins/ICPacketUpdateSign.java new file mode 100644 index 0000000..a0a6791 --- /dev/null +++ b/Client/src/main/java/de/com/baseband/client/mixin/mixins/ICPacketUpdateSign.java @@ -0,0 +1,14 @@ +package de.com.baseband.client.mixin.mixins; + +import net.minecraft.network.play.client.CPacketUpdateSign; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(CPacketUpdateSign.class) +public interface ICPacketUpdateSign { + @Accessor(value = "lines") + String[] getLines(); + + @Accessor(value = "lines") + void setLines(String[] lines); +} \ No newline at end of file diff --git a/Client/src/main/resources/mixins.baseband.json b/Client/src/main/resources/mixins.baseband.json index f209ee7..f35202a 100644 --- a/Client/src/main/resources/mixins.baseband.json +++ b/Client/src/main/resources/mixins.baseband.json @@ -6,15 +6,16 @@ "refmap": "mixins.baseband.refmap.json", "client": [ "ICPacketChat", + "ICPacketUpdateSign", "IMinecraft", "IPlayerControllerMP", "IRenderManager", "ISPacketExplosion", "ITimer", + "MixinEntity", "MixinEntityLivingBase", "MixinEntityPlayerSP", "MixinEntityRender", - "MixinEntity", "MixinEventBus", "MixinFMLNetworkRegistry", "MixinGuiEditSign",