diff --git a/src/main/java/net/wurstclient/hacks/AutoBuildHack.java b/src/main/java/net/wurstclient/hacks/AutoBuildHack.java index c6714e00c2..6139831a41 100644 --- a/src/main/java/net/wurstclient/hacks/AutoBuildHack.java +++ b/src/main/java/net/wurstclient/hacks/AutoBuildHack.java @@ -19,7 +19,6 @@ import net.minecraft.block.BlockState; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.HitResult; @@ -36,7 +35,13 @@ import net.wurstclient.settings.FileSetting; import net.wurstclient.settings.SliderSetting; import net.wurstclient.settings.SliderSetting.ValueDisplay; -import net.wurstclient.util.*; +import net.wurstclient.util.AutoBuildTemplate; +import net.wurstclient.util.BlockUtils; +import net.wurstclient.util.ChatUtils; +import net.wurstclient.util.DefaultAutoBuildTemplates; +import net.wurstclient.util.RegionPos; +import net.wurstclient.util.RenderUtils; +import net.wurstclient.util.RotationUtils; import net.wurstclient.util.json.JsonException; public final class AutoBuildHack extends Hack @@ -250,11 +255,7 @@ private boolean tryToPlace(BlockPos pos, Vec3d eyesPos, double rangeSq) continue; // face block - Rotation rotation = RotationUtils.getNeededRotations(hitVec); - PlayerMoveC2SPacket.LookAndOnGround packet = - new PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw(), - rotation.pitch(), MC.player.isOnGround()); - MC.player.networkHandler.sendPacket(packet); + RotationUtils.getNeededRotations(hitVec).sendPlayerLookPacket(); // place block IMC.getInteractionManager().rightClickBlock(neighbor, diff --git a/src/main/java/net/wurstclient/hacks/AutoPotionHack.java b/src/main/java/net/wurstclient/hacks/AutoPotionHack.java index e6f9a33a98..76bf0aa2be 100644 --- a/src/main/java/net/wurstclient/hacks/AutoPotionHack.java +++ b/src/main/java/net/wurstclient/hacks/AutoPotionHack.java @@ -12,7 +12,6 @@ import net.minecraft.entity.effect.StatusEffects; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.potion.PotionUtil; import net.wurstclient.Category; import net.wurstclient.SearchTags; @@ -20,6 +19,7 @@ import net.wurstclient.hack.Hack; import net.wurstclient.settings.SliderSetting; import net.wurstclient.settings.SliderSetting.ValueDisplay; +import net.wurstclient.util.Rotation; @SearchTags({"AutoPotion", "auto potion", "AutoSplashPotion", "auto splash potion"}) @@ -77,16 +77,13 @@ public void onUpdate() // throw potion in hotbar MC.player.getInventory().selectedSlot = potionInHotbar; - MC.player.networkHandler.sendPacket( - new PlayerMoveC2SPacket.LookAndOnGround(MC.player.getYaw(), 90, - MC.player.isOnGround())); + new Rotation(MC.player.getYaw(), 90).sendPlayerLookPacket(); IMC.getInteractionManager().rightClickItem(); // reset slot and rotation MC.player.getInventory().selectedSlot = oldSlot; - MC.player.networkHandler.sendPacket( - new PlayerMoveC2SPacket.LookAndOnGround(MC.player.getYaw(), - MC.player.getPitch(), MC.player.isOnGround())); + new Rotation(MC.player.getYaw(), MC.player.getPitch()) + .sendPlayerLookPacket(); // reset timer timer = 10; diff --git a/src/main/java/net/wurstclient/hacks/ClickAuraHack.java b/src/main/java/net/wurstclient/hacks/ClickAuraHack.java index 38818ae5f7..1987aeb8a1 100644 --- a/src/main/java/net/wurstclient/hacks/ClickAuraHack.java +++ b/src/main/java/net/wurstclient/hacks/ClickAuraHack.java @@ -14,7 +14,6 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.Hand; import net.wurstclient.Category; import net.wurstclient.SearchTags; @@ -27,7 +26,6 @@ import net.wurstclient.settings.SliderSetting.ValueDisplay; import net.wurstclient.settings.filterlists.EntityFilterList; import net.wurstclient.util.EntityUtils; -import net.wurstclient.util.Rotation; import net.wurstclient.util.RotationUtils; @SearchTags({"click aura", "ClickAimbot", "click aimbot"}) @@ -134,12 +132,8 @@ private void attack() WURST.getHax().autoSwordHack.setSlot(target); // face entity - Rotation rotation = RotationUtils - .getNeededRotations(target.getBoundingBox().getCenter()); - PlayerMoveC2SPacket.LookAndOnGround packet = - new PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw(), - rotation.pitch(), MC.player.isOnGround()); - MC.player.networkHandler.sendPacket(packet); + RotationUtils.getNeededRotations(target.getBoundingBox().getCenter()) + .sendPlayerLookPacket(); // attack entity WURST.getHax().criticalsHack.doCritical(); diff --git a/src/main/java/net/wurstclient/hacks/DerpHack.java b/src/main/java/net/wurstclient/hacks/DerpHack.java index bbecadae72..30c989dc24 100644 --- a/src/main/java/net/wurstclient/hacks/DerpHack.java +++ b/src/main/java/net/wurstclient/hacks/DerpHack.java @@ -9,11 +9,11 @@ import java.util.Random; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.wurstclient.Category; import net.wurstclient.SearchTags; import net.wurstclient.events.UpdateListener; import net.wurstclient.hack.Hack; +import net.wurstclient.util.Rotation; @SearchTags({"Retarded"}) public final class DerpHack extends Hack implements UpdateListener @@ -48,8 +48,6 @@ public void onUpdate() float yaw = MC.player.getYaw() + random.nextFloat() * 360F - 180F; float pitch = random.nextFloat() * 180F - 90F; - MC.player.networkHandler - .sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, - MC.player.isOnGround())); + new Rotation(yaw, pitch).sendPlayerLookPacket(); } } diff --git a/src/main/java/net/wurstclient/hacks/HeadRollHack.java b/src/main/java/net/wurstclient/hacks/HeadRollHack.java index 35cc4c4732..133321f2f6 100644 --- a/src/main/java/net/wurstclient/hacks/HeadRollHack.java +++ b/src/main/java/net/wurstclient/hacks/HeadRollHack.java @@ -7,12 +7,12 @@ */ package net.wurstclient.hacks; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.math.MathHelper; import net.wurstclient.Category; import net.wurstclient.SearchTags; import net.wurstclient.events.UpdateListener; import net.wurstclient.hack.Hack; +import net.wurstclient.util.Rotation; @SearchTags({"head roll", "nodding", "yes"}) public final class HeadRollHack extends Hack implements UpdateListener @@ -45,8 +45,6 @@ public void onUpdate() float timer = MC.player.age % 20 / 10F; float pitch = MathHelper.sin(timer * (float)Math.PI) * 90F; - MC.player.networkHandler.sendPacket( - new PlayerMoveC2SPacket.LookAndOnGround(MC.player.getYaw(), pitch, - MC.player.isOnGround())); + new Rotation(MC.player.getYaw(), pitch).sendPlayerLookPacket(); } } diff --git a/src/main/java/net/wurstclient/hacks/MultiAuraHack.java b/src/main/java/net/wurstclient/hacks/MultiAuraHack.java index 357ffb6fcd..c3d497b26b 100644 --- a/src/main/java/net/wurstclient/hacks/MultiAuraHack.java +++ b/src/main/java/net/wurstclient/hacks/MultiAuraHack.java @@ -13,7 +13,6 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.Hand; import net.wurstclient.Category; import net.wurstclient.SearchTags; @@ -25,7 +24,6 @@ import net.wurstclient.settings.SliderSetting.ValueDisplay; import net.wurstclient.settings.filterlists.EntityFilterList; import net.wurstclient.util.EntityUtils; -import net.wurstclient.util.Rotation; import net.wurstclient.util.RotationUtils; @SearchTags({"multi aura", "ForceField", "force field"}) @@ -116,12 +114,9 @@ public void onUpdate() // attack entities for(Entity entity : entities) { - Rotation rotation = RotationUtils - .getNeededRotations(entity.getBoundingBox().getCenter()); - - player.networkHandler.sendPacket( - new PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw(), - rotation.pitch(), MC.player.isOnGround())); + RotationUtils + .getNeededRotations(entity.getBoundingBox().getCenter()) + .sendPlayerLookPacket(); WURST.getHax().criticalsHack.doCritical(); MC.interactionManager.attackEntity(player, entity); diff --git a/src/main/java/net/wurstclient/hacks/ScaffoldWalkHack.java b/src/main/java/net/wurstclient/hacks/ScaffoldWalkHack.java index dcd0b62e64..01f399d4f5 100644 --- a/src/main/java/net/wurstclient/hacks/ScaffoldWalkHack.java +++ b/src/main/java/net/wurstclient/hacks/ScaffoldWalkHack.java @@ -14,7 +14,6 @@ import net.minecraft.block.FallingBlock; import net.minecraft.item.BlockItem; import net.minecraft.item.ItemStack; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; @@ -25,7 +24,6 @@ import net.wurstclient.events.UpdateListener; import net.wurstclient.hack.Hack; import net.wurstclient.util.BlockUtils; -import net.wurstclient.util.Rotation; import net.wurstclient.util.RotationUtils; @SearchTags({"scaffold walk", "BridgeWalk", "bridge walk", "AutoBridge", @@ -129,9 +127,7 @@ private void scaffoldTo(BlockPos belowPlayer) private boolean placeBlock(BlockPos pos) { - Vec3d eyesPos = new Vec3d(MC.player.getX(), - MC.player.getY() + MC.player.getEyeHeight(MC.player.getPose()), - MC.player.getZ()); + Vec3d eyesPos = RotationUtils.getEyesPos(); for(Direction side : Direction.values()) { @@ -155,11 +151,7 @@ private boolean placeBlock(BlockPos pos) continue; // place block - Rotation rotation = RotationUtils.getNeededRotations(hitVec); - PlayerMoveC2SPacket.LookAndOnGround packet = - new PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw(), - rotation.pitch(), MC.player.isOnGround()); - MC.player.networkHandler.sendPacket(packet); + RotationUtils.getNeededRotations(hitVec).sendPlayerLookPacket(); IMC.getInteractionManager().rightClickBlock(neighbor, side2, hitVec); MC.player.swingHand(Hand.MAIN_HAND); diff --git a/src/main/java/net/wurstclient/hacks/TiredHack.java b/src/main/java/net/wurstclient/hacks/TiredHack.java index 8d06100dcd..2518a7f0d8 100644 --- a/src/main/java/net/wurstclient/hacks/TiredHack.java +++ b/src/main/java/net/wurstclient/hacks/TiredHack.java @@ -7,10 +7,10 @@ */ package net.wurstclient.hacks; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.wurstclient.Category; import net.wurstclient.events.UpdateListener; import net.wurstclient.hack.Hack; +import net.wurstclient.util.Rotation; public final class TiredHack extends Hack implements UpdateListener { @@ -39,8 +39,7 @@ public void onDisable() @Override public void onUpdate() { - MC.player.networkHandler.sendPacket( - new PlayerMoveC2SPacket.LookAndOnGround(MC.player.getYaw(), - MC.player.age % 100, MC.player.isOnGround())); + new Rotation(MC.player.getYaw(), MC.player.age % 100) + .sendPlayerLookPacket(); } } diff --git a/src/main/java/net/wurstclient/hacks/TpAuraHack.java b/src/main/java/net/wurstclient/hacks/TpAuraHack.java index 8d2401edad..8bb5db1dc2 100644 --- a/src/main/java/net/wurstclient/hacks/TpAuraHack.java +++ b/src/main/java/net/wurstclient/hacks/TpAuraHack.java @@ -15,11 +15,9 @@ import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; import net.minecraft.entity.LivingEntity; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.Hand; import net.wurstclient.Category; import net.wurstclient.SearchTags; -import net.wurstclient.WurstClient; import net.wurstclient.events.UpdateListener; import net.wurstclient.hack.Hack; import net.wurstclient.settings.AttackSpeedSliderSetting; @@ -29,7 +27,6 @@ import net.wurstclient.settings.SliderSetting.ValueDisplay; import net.wurstclient.settings.filterlists.EntityFilterList; import net.wurstclient.util.EntityUtils; -import net.wurstclient.util.Rotation; import net.wurstclient.util.RotationUtils; @SearchTags({"TpAura", "tp aura", "EnderAura", "Ender-Aura", "ender aura"}) @@ -128,11 +125,8 @@ public void onUpdate() return; // attack entity - Rotation rotations = RotationUtils - .getNeededRotations(entity.getBoundingBox().getCenter()); - WurstClient.MC.player.networkHandler - .sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(rotations.yaw(), - rotations.pitch(), MC.player.isOnGround())); + RotationUtils.getNeededRotations(entity.getBoundingBox().getCenter()) + .sendPlayerLookPacket(); WURST.getHax().criticalsHack.doCritical(); MC.interactionManager.attackEntity(player, entity); diff --git a/src/main/java/net/wurstclient/settings/FacingSetting.java b/src/main/java/net/wurstclient/settings/FacingSetting.java index 276d811d29..079e88c6a9 100644 --- a/src/main/java/net/wurstclient/settings/FacingSetting.java +++ b/src/main/java/net/wurstclient/settings/FacingSetting.java @@ -9,17 +9,13 @@ import java.util.function.Consumer; -import net.minecraft.client.MinecraftClient; -import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.math.Vec3d; import net.wurstclient.WurstClient; -import net.wurstclient.util.Rotation; import net.wurstclient.util.RotationUtils; public final class FacingSetting extends EnumSetting { private static final WurstClient WURST = WurstClient.INSTANCE; - private static final MinecraftClient MC = WurstClient.MC; private FacingSetting(String name, String description, Facing[] values, Facing selected) @@ -55,13 +51,8 @@ public enum Facing CLIENT("Client-side", v -> WURST.getRotationFaker().faceVectorClient(v)), - SPAM("Packet spam", v -> { - Rotation rotation = RotationUtils.getNeededRotations(v); - PlayerMoveC2SPacket.LookAndOnGround packet = - new PlayerMoveC2SPacket.LookAndOnGround(rotation.yaw(), - rotation.pitch(), MC.player.isOnGround()); - MC.player.networkHandler.sendPacket(packet); - }); + SPAM("Packet spam", + v -> RotationUtils.getNeededRotations(v).sendPlayerLookPacket()); private String name; private Consumer face; diff --git a/src/main/java/net/wurstclient/util/Rotation.java b/src/main/java/net/wurstclient/util/Rotation.java index 9b6263c4a9..4a6e4b3ac4 100644 --- a/src/main/java/net/wurstclient/util/Rotation.java +++ b/src/main/java/net/wurstclient/util/Rotation.java @@ -7,13 +7,29 @@ */ package net.wurstclient.util; +import net.minecraft.client.MinecraftClient; +import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; import net.minecraft.util.math.MathHelper; +import net.wurstclient.WurstClient; public record Rotation(float yaw, float pitch) { + private static final MinecraftClient MC = WurstClient.MC; + public static Rotation wrapped(float yaw, float pitch) { return new Rotation(MathHelper.wrapDegrees(yaw), MathHelper.wrapDegrees(pitch)); } + + public void sendPlayerLookPacket() + { + sendPlayerLookPacket(MC.player.isOnGround()); + } + + public void sendPlayerLookPacket(boolean onGround) + { + MC.player.networkHandler.sendPacket( + new PlayerMoveC2SPacket.LookAndOnGround(yaw, pitch, onGround)); + } }