From d40106b203bb725dd2a5c637eb57ec00676620df Mon Sep 17 00:00:00 2001 From: ThisTestUser Date: Fri, 8 Sep 2023 16:16:05 -0400 Subject: [PATCH] AntiForceLook --- .../java/net/wurstclient/hack/HackList.java | 1 + .../wurstclient/hacks/AntiForceLookHack.java | 48 +++++++++++++++++++ .../PlayerPositionLookS2CPacketAccessor.java | 26 ++++++++++ .../resources/assets/wurst/lang/en_us.json | 1 + src/main/resources/wurst.mixins.json | 1 + 5 files changed, 77 insertions(+) create mode 100644 src/main/java/net/wurstclient/hacks/AntiForceLookHack.java create mode 100644 src/main/java/net/wurstclient/mixin/PlayerPositionLookS2CPacketAccessor.java diff --git a/src/main/java/net/wurstclient/hack/HackList.java b/src/main/java/net/wurstclient/hack/HackList.java index cad7fe2040..b3443361e4 100644 --- a/src/main/java/net/wurstclient/hack/HackList.java +++ b/src/main/java/net/wurstclient/hack/HackList.java @@ -36,6 +36,7 @@ public final class HackList implements UpdateListener public final AntiCactusHack antiCactusHack = new AntiCactusHack(); public final AntiEntityPushHack antiEntityPushHack = new AntiEntityPushHack(); + public final AntiForceLookHack antiForceLookHack = new AntiForceLookHack(); public final AntiHungerHack antiHungerHack = new AntiHungerHack(); public final AntiKnockbackHack antiKnockbackHack = new AntiKnockbackHack(); public final AntiSpamHack antiSpamHack = new AntiSpamHack(); diff --git a/src/main/java/net/wurstclient/hacks/AntiForceLookHack.java b/src/main/java/net/wurstclient/hacks/AntiForceLookHack.java new file mode 100644 index 0000000000..923efbe8f6 --- /dev/null +++ b/src/main/java/net/wurstclient/hacks/AntiForceLookHack.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2014-2023 Wurst-Imperium and contributors. + * + * This source code is subject to the terms of the GNU General Public + * License, version 3. If a copy of the GPL was not distributed with this + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt + */ +package net.wurstclient.hacks; + +import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket; +import net.wurstclient.Category; +import net.wurstclient.SearchTags; +import net.wurstclient.events.PacketOutputListener; +import net.wurstclient.hack.Hack; +import net.wurstclient.mixin.PlayerPositionLookS2CPacketAccessor; + +@SearchTags({"anti force look", "no rotate"}) +public final class AntiForceLookHack extends Hack implements PacketOutputListener +{ + public AntiForceLookHack() + { + super("AntiForceLook"); + setCategory(Category.MOVEMENT); + } + + @Override + public void onEnable() + { + EVENTS.add(PacketOutputListener.class, this); + } + + @Override + public void onDisable() + { + EVENTS.remove(PacketOutputListener.class, this); + } + + @Override + public void onSentPacket(PacketOutputEvent event) + { + if(event.getPacket() instanceof PlayerPositionLookS2CPacket) + { + PlayerPositionLookS2CPacketAccessor packet = (PlayerPositionLookS2CPacketAccessor)event.getPacket(); + packet.setYaw(MC.player.getYaw()); + packet.setPitch(MC.player.getPitch()); + } + } +} diff --git a/src/main/java/net/wurstclient/mixin/PlayerPositionLookS2CPacketAccessor.java b/src/main/java/net/wurstclient/mixin/PlayerPositionLookS2CPacketAccessor.java new file mode 100644 index 0000000000..b142395c0c --- /dev/null +++ b/src/main/java/net/wurstclient/mixin/PlayerPositionLookS2CPacketAccessor.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2014-2023 Wurst-Imperium and contributors. + * + * This source code is subject to the terms of the GNU General Public + * License, version 3. If a copy of the GPL was not distributed with this + * file, You can obtain one at: https://www.gnu.org/licenses/gpl-3.0.txt + */ +package net.wurstclient.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket; + +@Mixin(PlayerPositionLookS2CPacket.class) +public interface PlayerPositionLookS2CPacketAccessor +{ + @Mutable + @Accessor("yaw") + void setYaw(float yaw); + + @Mutable + @Accessor("pitch") + void setPitch(float pitch); +} diff --git a/src/main/resources/assets/wurst/lang/en_us.json b/src/main/resources/assets/wurst/lang/en_us.json index 5dedadb077..13a0484080 100644 --- a/src/main/resources/assets/wurst/lang/en_us.json +++ b/src/main/resources/assets/wurst/lang/en_us.json @@ -6,6 +6,7 @@ "description.wurst.hack.antiblind": "Prevents blindness and darkness effects.\nIncompatible with OptiFine.", "description.wurst.hack.anticactus": "Protects you from cactus damage.", "description.wurst.hack.antientitypush": "Prevents you from getting pushed by players and mobs.", + "description.wurst.hack.antiforcelook": "Prevents the server from changing your yaw and pitch. This usually means you are triggering the anticheat.", "description.wurst.hack.antihunger": "Slows down your hunger when you are walking.", "description.wurst.hack.antiknockback": "Prevents you from taking knockback from players and mobs.", "description.wurst.hack.antispam": "Blocks chat spam by adding a counter to repeated messages.", diff --git a/src/main/resources/wurst.mixins.json b/src/main/resources/wurst.mixins.json index 55815552f3..bb3e30b398 100644 --- a/src/main/resources/wurst.mixins.json +++ b/src/main/resources/wurst.mixins.json @@ -57,6 +57,7 @@ "PackScreenMixin", "PlayerEntityMixin", "PlayerInventoryMixin", + "PlayerPositionLookS2CPacketAccessor", "PlayerSkinProviderMixin", "PowderSnowBlockMixin", "RenderTickCounterMixin",