diff --git a/src/main/java/com/tangykiwi/kiwiclient/command/commands/Ez.java b/src/main/java/com/tangykiwi/kiwiclient/command/commands/Ez.java index bf674001..2bf31387 100644 --- a/src/main/java/com/tangykiwi/kiwiclient/command/commands/Ez.java +++ b/src/main/java/com/tangykiwi/kiwiclient/command/commands/Ez.java @@ -2,9 +2,13 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.tangykiwi.kiwiclient.command.Command; +import com.tangykiwi.kiwiclient.mixin.ClientPlayerEntityAccessor; import com.tangykiwi.kiwiclient.util.Utils; import net.minecraft.command.CommandSource; +import net.minecraft.network.message.ChatMessageSigner; +import net.minecraft.network.message.MessageSignature; import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket; +import net.minecraft.text.Text; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; @@ -13,15 +17,22 @@ public Ez() { super("ez", "Says a big EZ in chat"); } + String[] messages = { + "███████╗███████╗", + "███████╗███████╗", + "█████╗░░░░███╔═╝", + "██╔══╝░░██╔══╝░░", + "███████╗███████╗", + "╚══════╝╚══════╝"}; + @Override public void build(LiteralArgumentBuilder builder) { + builder.executes(context -> { - Utils.mc.player.sendChatMessage("███████╗███████╗"); - Utils.mc.player.sendChatMessage("██╔════╝╚════██║"); - Utils.mc.player.sendChatMessage("█████╗░░░░███╔═╝"); - Utils.mc.player.sendChatMessage("██╔══╝░░██╔══╝░░"); - Utils.mc.player.sendChatMessage("███████╗███████╗"); - Utils.mc.player.sendChatMessage("╚══════╝╚══════╝"); + for(String message : messages) { + MessageSignature messageSignature = ((ClientPlayerEntityAccessor) Utils.mc.player)._signChatMessage(ChatMessageSigner.create(Utils.mc.player.getUuid()), Text.literal(message)); + Utils.mc.getNetworkHandler().sendPacket(new ChatMessageC2SPacket(message, messageSignature, false)); + } return SINGLE_SUCCESS; }); } diff --git a/src/main/java/com/tangykiwi/kiwiclient/command/commands/FF.java b/src/main/java/com/tangykiwi/kiwiclient/command/commands/FF.java index 469714fb..cfb8860b 100644 --- a/src/main/java/com/tangykiwi/kiwiclient/command/commands/FF.java +++ b/src/main/java/com/tangykiwi/kiwiclient/command/commands/FF.java @@ -2,8 +2,12 @@ import com.tangykiwi.kiwiclient.command.Command; import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.tangykiwi.kiwiclient.mixin.ClientPlayerEntityAccessor; import com.tangykiwi.kiwiclient.util.Utils; import net.minecraft.command.CommandSource; +import net.minecraft.network.message.ChatMessageSigner; +import net.minecraft.network.message.MessageSignature; +import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket; import net.minecraft.text.Text; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; @@ -17,7 +21,9 @@ public FF() { @Override public void build(LiteralArgumentBuilder builder) { builder.executes(context -> { - Utils.mc.player.sendChatMessage("I'm gonna FF, gg go next."); + String message = "I'm gonna FF, gg go next."; + MessageSignature messageSignature = ((ClientPlayerEntityAccessor) Utils.mc.player)._signChatMessage(ChatMessageSigner.create(Utils.mc.player.getUuid()), Text.literal(message)); + Utils.mc.getNetworkHandler().sendPacket(new ChatMessageC2SPacket(message, messageSignature, false)); Utils.mc.player.networkHandler.getConnection().disconnect(Text.literal("Literally just FFed.")); return SINGLE_SUCCESS; }); diff --git a/src/main/java/com/tangykiwi/kiwiclient/command/commands/Say.java b/src/main/java/com/tangykiwi/kiwiclient/command/commands/Say.java index 9359cce3..511d4234 100644 --- a/src/main/java/com/tangykiwi/kiwiclient/command/commands/Say.java +++ b/src/main/java/com/tangykiwi/kiwiclient/command/commands/Say.java @@ -3,9 +3,13 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.tangykiwi.kiwiclient.command.Command; +import com.tangykiwi.kiwiclient.mixin.ClientPlayerEntityAccessor; import com.tangykiwi.kiwiclient.util.Utils; import net.minecraft.command.CommandSource; +import net.minecraft.network.message.ChatMessageSigner; +import net.minecraft.network.message.MessageSignature; import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket; +import net.minecraft.text.Text; import static com.mojang.brigadier.Command.SINGLE_SUCCESS; @@ -17,8 +21,9 @@ public Say() { @Override public void build(LiteralArgumentBuilder builder) { builder.then(argument("message", StringArgumentType.greedyString()).executes(context -> { - String msg = context.getArgument("message", String.class); - Utils.mc.player.sendChatMessage(msg); + String message = context.getArgument("message", String.class); + MessageSignature messageSignature = ((ClientPlayerEntityAccessor) Utils.mc.player)._signChatMessage(ChatMessageSigner.create(Utils.mc.player.getUuid()), Text.literal(message)); + Utils.mc.getNetworkHandler().sendPacket(new ChatMessageC2SPacket(message, messageSignature, false)); return SINGLE_SUCCESS; })); diff --git a/src/main/java/com/tangykiwi/kiwiclient/mixin/ClientPlayerEntityAccessor.java b/src/main/java/com/tangykiwi/kiwiclient/mixin/ClientPlayerEntityAccessor.java new file mode 100644 index 00000000..31f35d17 --- /dev/null +++ b/src/main/java/com/tangykiwi/kiwiclient/mixin/ClientPlayerEntityAccessor.java @@ -0,0 +1,14 @@ +package com.tangykiwi.kiwiclient.mixin; + +import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.network.message.ChatMessageSigner; +import net.minecraft.network.message.MessageSignature; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(ClientPlayerEntity.class) +public interface ClientPlayerEntityAccessor { + @Invoker("signChatMessage") + MessageSignature _signChatMessage(ChatMessageSigner signer, Text message); +} diff --git a/src/main/java/com/tangykiwi/kiwiclient/mixin/ClientPlayerEntityMixin.java b/src/main/java/com/tangykiwi/kiwiclient/mixin/ClientPlayerEntityMixin.java index e18f6444..8ae92475 100644 --- a/src/main/java/com/tangykiwi/kiwiclient/mixin/ClientPlayerEntityMixin.java +++ b/src/main/java/com/tangykiwi/kiwiclient/mixin/ClientPlayerEntityMixin.java @@ -3,8 +3,6 @@ import com.mojang.authlib.GameProfile; import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.tangykiwi.kiwiclient.KiwiClient; -import com.tangykiwi.kiwiclient.command.Command; -import com.tangykiwi.kiwiclient.command.CommandManager; import com.tangykiwi.kiwiclient.event.OnMoveEvent; import com.tangykiwi.kiwiclient.event.SendChatMessageEvent; import com.tangykiwi.kiwiclient.event.TickEvent; @@ -18,6 +16,7 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.world.ClientWorld; import net.minecraft.entity.MovementType; +import net.minecraft.network.encryption.PlayerPublicKey; import net.minecraft.text.Text; import net.minecraft.util.math.Vec3d; import org.spongepowered.asm.mixin.Mixin; @@ -27,6 +26,8 @@ import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import javax.annotation.Nullable; + @Mixin(ClientPlayerEntity.class) public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity implements IClientPlayerEntity { @Shadow @@ -36,9 +37,9 @@ public abstract class ClientPlayerEntityMixin extends AbstractClientPlayerEntity @Shadow public abstract void sendChatMessage(String string); - public ClientPlayerEntityMixin(ClientWorld world, GameProfile gameProfile) + public ClientPlayerEntityMixin(ClientWorld world, GameProfile gameProfile, @Nullable PlayerPublicKey publicKey) { - super(world, gameProfile, Utils.mc.player.getPublicKey()); + super(world, gameProfile, publicKey); } @Inject(method = "tick()V", at = @At("RETURN"), cancellable = true) @@ -58,8 +59,8 @@ private void onMove(MovementType type, Vec3d offset, CallbackInfo callbackInfo) KiwiClient.eventBus.post(event); } - @Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true) - public void onChatMessage(String message, CallbackInfo callbackInfo) { + @Inject(method = "sendChatMessage(Ljava/lang/String;Lnet/minecraft/text/Text;)V", at = @At("HEAD"), cancellable = true) + private void onSendChatMessage(String message, Text preview, CallbackInfo callbackInfo) { if (ignoreChatMessage) return; if (!message.startsWith(KiwiClient.PREFIX) && !message.startsWith("/")) { @@ -86,12 +87,6 @@ public void onChatMessage(String message, CallbackInfo callbackInfo) { } } - @Override - public void setNoClip(boolean noClip) - { - this.noClip = noClip; - } - @Override protected boolean clipAtLedge() { return super.clipAtLedge() || KiwiClient.moduleManager.getModule(SafeWalk.class).isEnabled(); diff --git a/src/main/java/com/tangykiwi/kiwiclient/mixin/SimpleOptionMixin.java b/src/main/java/com/tangykiwi/kiwiclient/mixin/SimpleOptionMixin.java new file mode 100644 index 00000000..0b1a4e28 --- /dev/null +++ b/src/main/java/com/tangykiwi/kiwiclient/mixin/SimpleOptionMixin.java @@ -0,0 +1,37 @@ +package com.tangykiwi.kiwiclient.mixin; + +import com.tangykiwi.kiwiclient.mixininterface.ISimpleOption; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.option.SimpleOption; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +import java.util.Objects; +import java.util.function.Consumer; + +@Mixin(SimpleOption.class) +public class SimpleOptionMixin implements ISimpleOption { + @Shadow + T value; + + @Shadow + @Final + private Consumer changeCallback; + + @Override + public void forceSetValue(T newValue) + { + if(!MinecraftClient.getInstance().isRunning()) + { + value = newValue; + return; + } + + if(!Objects.equals(value, newValue)) + { + value = newValue; + changeCallback.accept(value); + } + } +} diff --git a/src/main/java/com/tangykiwi/kiwiclient/mixininterface/IClientPlayerEntity.java b/src/main/java/com/tangykiwi/kiwiclient/mixininterface/IClientPlayerEntity.java index b44c3fc7..af6a3aa7 100644 --- a/src/main/java/com/tangykiwi/kiwiclient/mixininterface/IClientPlayerEntity.java +++ b/src/main/java/com/tangykiwi/kiwiclient/mixininterface/IClientPlayerEntity.java @@ -1,5 +1,4 @@ package com.tangykiwi.kiwiclient.mixininterface; public interface IClientPlayerEntity { - void setNoClip(boolean noClip); } diff --git a/src/main/java/com/tangykiwi/kiwiclient/mixininterface/ISimpleOption.java b/src/main/java/com/tangykiwi/kiwiclient/mixininterface/ISimpleOption.java new file mode 100644 index 00000000..8015ad2c --- /dev/null +++ b/src/main/java/com/tangykiwi/kiwiclient/mixininterface/ISimpleOption.java @@ -0,0 +1,5 @@ +package com.tangykiwi.kiwiclient.mixininterface; + +public interface ISimpleOption { + public void forceSetValue(T newValue); +} diff --git a/src/main/java/com/tangykiwi/kiwiclient/modules/render/FullBright.java b/src/main/java/com/tangykiwi/kiwiclient/modules/render/FullBright.java index b65971b6..07591c66 100644 --- a/src/main/java/com/tangykiwi/kiwiclient/modules/render/FullBright.java +++ b/src/main/java/com/tangykiwi/kiwiclient/modules/render/FullBright.java @@ -2,8 +2,10 @@ import com.google.common.eventbus.Subscribe; import com.tangykiwi.kiwiclient.event.TickEvent; +import com.tangykiwi.kiwiclient.mixininterface.ISimpleOption; import com.tangykiwi.kiwiclient.modules.Category; import com.tangykiwi.kiwiclient.modules.Module; +import net.minecraft.client.option.SimpleOption; public class FullBright extends Module { @@ -13,12 +15,22 @@ public FullBright() { @Subscribe public void onTick(TickEvent e) { - if(mc.options.getGamma().getValue() < 15) mc.options.getGamma().setValue(mc.options.getGamma().getValue() + 0.5); + if(mc.options.getGamma().getValue() < 16) { + SimpleOption gammaOption = mc.options.getGamma(); + @SuppressWarnings("unchecked") + ISimpleOption gammaOption2 = (ISimpleOption)(Object)gammaOption; + gammaOption2.forceSetValue(gammaOption.getValue() + 0.5); + } } @Override public void onDisable() { super.onDisable(); - while(mc.options.getGamma().getValue() > 1) mc.options.getGamma().setValue(mc.options.getGamma().getValue() - 0.5); + while(mc.options.getGamma().getValue() > 1) { + SimpleOption gammaOption = mc.options.getGamma(); + @SuppressWarnings("unchecked") + ISimpleOption gammaOption2 = (ISimpleOption)(Object)gammaOption; + gammaOption2.forceSetValue(gammaOption.getValue() - 0.5); + } } } diff --git a/src/main/java/com/tangykiwi/kiwiclient/modules/render/XRay.java b/src/main/java/com/tangykiwi/kiwiclient/modules/render/XRay.java index 0dc7d37a..fa6e1cf0 100644 --- a/src/main/java/com/tangykiwi/kiwiclient/modules/render/XRay.java +++ b/src/main/java/com/tangykiwi/kiwiclient/modules/render/XRay.java @@ -5,6 +5,7 @@ import com.tangykiwi.kiwiclient.event.RenderBlockEvent; import com.tangykiwi.kiwiclient.event.RenderFluidEvent; import com.tangykiwi.kiwiclient.event.TickEvent; +import com.tangykiwi.kiwiclient.mixininterface.ISimpleOption; import com.tangykiwi.kiwiclient.modules.Category; import com.tangykiwi.kiwiclient.modules.Module; import com.tangykiwi.kiwiclient.modules.settings.SliderSetting; @@ -13,6 +14,7 @@ import net.minecraft.block.Blocks; import net.minecraft.block.FernBlock; import net.minecraft.block.TallPlantBlock; +import net.minecraft.client.option.SimpleOption; import net.minecraft.client.render.RenderLayer; import java.util.ArrayList; @@ -74,7 +76,10 @@ public void onEnable() { @Override public void onDisable() { - mc.options.getGamma().setValue(gamma); + SimpleOption gammaOption = mc.options.getGamma(); + @SuppressWarnings("unchecked") + ISimpleOption gammaOption2 = (ISimpleOption)(Object)gammaOption; + gammaOption2.forceSetValue(gamma); mc.chunkCullingEnabled = true; mc.worldRenderer.reload(); @@ -84,7 +89,10 @@ public void onDisable() { @Subscribe @AllowConcurrentEvents public void onTick(TickEvent e) { - mc.options.getGamma().setValue(69.420); + SimpleOption gammaOption = mc.options.getGamma(); + @SuppressWarnings("unchecked") + ISimpleOption gammaOption2 = (ISimpleOption)(Object)gammaOption; + gammaOption2.forceSetValue(16.0); } @Subscribe diff --git a/src/main/resources/kiwiclient.mixins.json b/src/main/resources/kiwiclient.mixins.json index 047da16c..530e62ea 100644 --- a/src/main/resources/kiwiclient.mixins.json +++ b/src/main/resources/kiwiclient.mixins.json @@ -16,6 +16,7 @@ "ChunkOcclusionDataBuilderMixin", "ChunkRebuildTaskMixin", "ClientConnectionMixin", + "ClientPlayerEntityAccessor", "ClientPlayerEntityMixin", "ClientPlayerInteractionManagerAccessor", "ClientPlayNetworkHandlerMixin", @@ -49,6 +50,7 @@ "ScreenMixin", "ShaderMixin", "ShulkerBoxBlockMixin", + "SimpleOptionMixin", "SodiumBlockOcclusionCacheMixin", "SplashScreenMixin", "TitleScreenMixin",