From 68da75f08f226668d4489b7f4e05cf8cf33afd1c Mon Sep 17 00:00:00 2001 From: jackh Date: Sun, 12 Jan 2025 11:54:08 -0700 Subject: [PATCH] edged. --- .../components/impl/BindComponent.java | 64 ++++++-- .../components/impl/ModuleComponent.java | 16 +- .../impl/entity/MixinEntityPlayerSP.java | 3 +- .../network/MixinNetHandlerPlayClient.java | 23 +++ .../module/impl/combat/KillAura.java | 132 ++++++++--------- .../module/impl/movement/LongJump.java | 26 +--- .../module/impl/movement/NoSlow.java | 30 ++-- .../module/impl/movement/Sprint.java | 2 +- .../module/impl/player/BedAura.java | 57 ++++++-- .../module/impl/player/NoFall.java | 31 ++-- .../module/impl/player/NoRotate.java | 108 +++----------- .../module/impl/player/Scaffold.java | 137 ++++++++++-------- .../module/impl/player/Tower.java | 6 +- .../module/impl/render/Nametags.java | 2 +- .../module/setting/impl/KeySetting.java | 51 +++++++ .../keystrokesmod/utility/ModuleUtils.java | 21 +-- .../java/keystrokesmod/utility/Utils.java | 16 ++ .../utility/profile/ProfileManager.java | 9 +- src/main/resources/mixins.raven.json | 3 +- 19 files changed, 409 insertions(+), 328 deletions(-) create mode 100644 src/main/java/keystrokesmod/mixins/impl/network/MixinNetHandlerPlayClient.java create mode 100644 src/main/java/keystrokesmod/module/setting/impl/KeySetting.java diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java index 8de45a3..c8df042 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/BindComponent.java @@ -4,6 +4,7 @@ import keystrokesmod.Raven; import keystrokesmod.clickgui.components.Component; import keystrokesmod.module.Module; import keystrokesmod.module.impl.client.Gui; +import keystrokesmod.module.setting.impl.KeySetting; import keystrokesmod.utility.Theme; import keystrokesmod.utility.profile.ProfileModule; import net.minecraft.client.Minecraft; @@ -13,47 +14,66 @@ import org.lwjgl.opengl.GL11; public class BindComponent extends Component { public boolean isBinding; private ModuleComponent moduleComponent; - private int bind; + private int o; private int x; private int y; + private KeySetting keySetting; - public BindComponent(ModuleComponent moduleComponent, int bind) { + public BindComponent(ModuleComponent moduleComponent, int o) { this.moduleComponent = moduleComponent; this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; - this.bind = bind; + this.o = o; + } + + public BindComponent(ModuleComponent moduleComponent, KeySetting keySetting, int o) { + this.moduleComponent = moduleComponent; + this.x = moduleComponent.categoryComponent.getX() + moduleComponent.categoryComponent.getWidth(); + this.y = moduleComponent.categoryComponent.getY() + moduleComponent.yPos; + this.keySetting = keySetting; + this.o = o; } public void updateHeight(int n) { - this.bind = n; + this.o = n; } public void render() { GL11.glPushMatrix(); GL11.glScaled(0.5D, 0.5D, 0.5D); - this.drawString(!this.moduleComponent.mod.canBeEnabled() && this.moduleComponent.mod.script == null ? "Module cannot be bound." : this.isBinding ? "Press a key..." : "Current bind: '§e" + (this.moduleComponent.mod.getKeycode() >= 1000 ? "M" + (this.moduleComponent.mod.getKeycode() - 1000) : Keyboard.getKeyName(this.moduleComponent.mod.getKeycode())) + "§r'"); + if (keySetting == null) { + this.drawString(!this.moduleComponent.mod.canBeEnabled() && this.moduleComponent.mod.script == null ? "Module cannot be bound." : this.isBinding ? "Press a key..." : "Current bind: '§e" + (this.moduleComponent.mod.getKeycode() >= 1000 ? "M" + (this.moduleComponent.mod.getKeycode() - 1000) : Keyboard.getKeyName(this.moduleComponent.mod.getKeycode())) + "§r'"); + } + else { + this.drawString(this.isBinding ? "Press a key..." : "" + this.keySetting.getName() + ": '§e" + (this.keySetting.getKey() >= 1000 ? "M" + (this.keySetting.getKey() - 1000) : Keyboard.getKeyName(this.keySetting.getKey())) + "§r'"); + } GL11.glPopMatrix(); } public void drawScreen(int x, int y) { - this.y = this.moduleComponent.categoryComponent.getModuleY() + this.bind; + this.y = this.moduleComponent.categoryComponent.getModuleY() + this.o; this.x = this.moduleComponent.categoryComponent.getX(); } - public boolean onClick(int x, int y, int b) { + public boolean onClick(int x, int y, int button) { if (this.i(x, y) && this.moduleComponent.isOpened && this.moduleComponent.mod.canBeEnabled()) { - if (b == 0) { + if (button == 0) { this.isBinding = !this.isBinding; } - else if (b == 1 && this.moduleComponent.mod.moduleCategory() != Module.category.profiles) { + else if (button == 1 && this.moduleComponent.mod.moduleCategory() != Module.category.profiles) { this.moduleComponent.mod.setHidden(!this.moduleComponent.mod.isHidden()); if (Raven.currentProfile != null) { ((ProfileModule) Raven.currentProfile.getModule()).saved = false; } } - else if (b > 1) { + else if (button > 1) { if (this.isBinding) { - this.moduleComponent.mod.setBind(b + 1000); + if (this.keySetting != null) { + this.keySetting.setKey(button + 1000); + } + else { + this.moduleComponent.mod.setBind(button + 1000); + } if (Raven.currentProfile != null) { ((ProfileModule) Raven.currentProfile.getModule()).saved = false; } @@ -69,8 +89,14 @@ public class BindComponent extends Component { if (keybind == Keyboard.KEY_0 || keybind == Keyboard.KEY_ESCAPE) { if (this.moduleComponent.mod instanceof Gui) { this.moduleComponent.mod.setBind(54); - } else { - this.moduleComponent.mod.setBind(0); + } + else { + if (this.keySetting != null) { + this.keySetting.setKey(0); + } + else { + this.moduleComponent.mod.setBind(0); + } } if (Raven.currentProfile != null) { ((ProfileModule) Raven.currentProfile.getModule()).saved = false; @@ -80,7 +106,12 @@ public class BindComponent extends Component { if (Raven.currentProfile != null) { ((ProfileModule) Raven.currentProfile.getModule()).saved = false; } - this.moduleComponent.mod.setBind(keybind); + if (this.keySetting != null) { + this.keySetting.setKey(keybind); + } + else { + this.moduleComponent.mod.setBind(keybind); + } } this.isBinding = false; @@ -92,11 +123,14 @@ public class BindComponent extends Component { } public int getHeight() { + if (this.keySetting != null) { + return 0; + } return 16; } private void drawString(String s) { - Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(s, (float) ((this.moduleComponent.categoryComponent.getX() + 4) * 2), (float) ((this.moduleComponent.categoryComponent.getY() + this.bind + 3) * 2), !this.moduleComponent.mod.hidden ? Theme.getGradient(Theme.descriptor[0], Theme.descriptor[1], 0) : Theme.getGradient(Theme.hiddenBind[0], Theme.hiddenBind[1], 0)); + Minecraft.getMinecraft().fontRendererObj.drawStringWithShadow(s, (float) ((this.moduleComponent.categoryComponent.getX() + 4) * 2), (float) ((this.moduleComponent.categoryComponent.getY() + this.o + (this.keySetting == null ? 3 : 4)) * 2), !this.moduleComponent.mod.hidden ? Theme.getGradient(Theme.descriptor[0], Theme.descriptor[1], 0) : Theme.getGradient(Theme.hiddenBind[0], Theme.hiddenBind[1], 0)); } public void onGuiClosed() { diff --git a/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java b/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java index 3cc6c5c..f9e1d22 100644 --- a/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java +++ b/src/main/java/keystrokesmod/clickgui/components/impl/ModuleComponent.java @@ -6,6 +6,7 @@ import keystrokesmod.module.Module; import keystrokesmod.module.setting.Setting; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.KeySetting; import keystrokesmod.module.setting.impl.SliderSetting; import keystrokesmod.utility.RenderUtils; import keystrokesmod.utility.Timer; @@ -52,17 +53,25 @@ public class ModuleComponent extends Component { SliderComponent s = new SliderComponent(n, this, y); this.settings.add(s); y += 12; - } else if (v instanceof ButtonSetting) { + } + else if (v instanceof ButtonSetting) { ButtonSetting b = (ButtonSetting) v; ButtonComponent c = new ButtonComponent(mod, b, this, y); this.settings.add(c); y += 12; - } else if (v instanceof DescriptionSetting) { + } + else if (v instanceof DescriptionSetting) { DescriptionSetting d = (DescriptionSetting) v; DescriptionComponent m = new DescriptionComponent(d, this, y); this.settings.add(m); y += 12; } + else if (v instanceof KeySetting) { + KeySetting setting = (KeySetting) v; + BindComponent keyComponent = new BindComponent(this, setting, y); + this.settings.add(keyComponent); + y += 12; + } } } this.settings.add(new BindComponent(this, y)); @@ -79,7 +88,8 @@ public class ModuleComponent extends Component { co.updateHeight(y); if (co instanceof SliderComponent) { y += 16; - } else if (co instanceof ButtonComponent || co instanceof BindComponent || co instanceof DescriptionComponent) { + } + else if (co instanceof ButtonComponent || co instanceof BindComponent || co instanceof DescriptionComponent) { y += 12; } } diff --git a/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java b/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java index b1582bf..7b3bbe9 100644 --- a/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java +++ b/src/main/java/keystrokesmod/mixins/impl/entity/MixinEntityPlayerSP.java @@ -16,6 +16,7 @@ import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.network.play.client.C03PacketPlayer; import net.minecraft.network.play.client.C0BPacketEntityAction; import net.minecraft.network.play.client.C0CPacketInput; @@ -288,7 +289,7 @@ public abstract class MixinEntityPlayerSP extends AbstractClientPlayer { this.setSprinting(true); } - if (this.isSprinting() && (!ModuleManager.sprint.omniSprint() && !NoSlow.groundSpeed() && (this.movementInput.moveForward < f || !flag3)) || this.isCollidedHorizontally || (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && (!ModuleManager.scaffold.sprint() || ModuleManager.tower.canTower())) || (ModuleManager.wTap.isEnabled() && WTap.stopSprint)) { + if (this.isSprinting() && (!ModuleManager.sprint.omniSprint() && !NoSlow.groundSpeed() && (this.movementInput.moveForward < f || !flag3)) || this.isCollidedHorizontally || this.mc.gameSettings.keyBindSneak.isKeyDown() || (ModuleManager.scaffold != null && ModuleManager.scaffold.isEnabled && (!ModuleManager.scaffold.sprint() || ModuleManager.tower.canTower())) || (ModuleManager.wTap.isEnabled() && WTap.stopSprint)) { this.setSprinting(false); WTap.stopSprint = false; } diff --git a/src/main/java/keystrokesmod/mixins/impl/network/MixinNetHandlerPlayClient.java b/src/main/java/keystrokesmod/mixins/impl/network/MixinNetHandlerPlayClient.java new file mode 100644 index 0000000..f49d1a5 --- /dev/null +++ b/src/main/java/keystrokesmod/mixins/impl/network/MixinNetHandlerPlayClient.java @@ -0,0 +1,23 @@ +package keystrokesmod.mixins.impl.network; + +import keystrokesmod.module.ModuleManager; +import net.minecraft.client.network.NetHandlerPlayClient; +import net.minecraft.network.play.server.S08PacketPlayerPosLook; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(NetHandlerPlayClient.class) +public class MixinNetHandlerPlayClient { + + @Inject(method = "handlePlayerPosLook", at = @At("HEAD")) + public void handlePlayerPosLookPre(S08PacketPlayerPosLook packetIn, CallbackInfo ci) { + ModuleManager.noRotate.handlePlayerPosLookPre(); + } + + @Inject(method = "handlePlayerPosLook", at = @At("RETURN")) + public void handlePlayerPosLook(S08PacketPlayerPosLook packetIn, CallbackInfo ci) { + ModuleManager.noRotate.handlePlayerPosLook(packetIn); + } +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java index a2f72e1..56358c5 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java +++ b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java @@ -88,10 +88,11 @@ public class KillAura extends Module { private boolean firstCycle; private boolean partialDown; private int partialTicks; + private int firstEdge; + private boolean blocked; // blink related private ConcurrentLinkedQueue blinkedPackets = new ConcurrentLinkedQueue<>(); - private ConcurrentLinkedQueue regularPackets = new ConcurrentLinkedQueue<>(); private AtomicBoolean blinking = new AtomicBoolean(false); public boolean lag; public boolean swapped; @@ -108,7 +109,7 @@ public class KillAura extends Module { private int delayTicks = 0; private boolean lastPressedLeft; private boolean lastPressedRight; - public boolean fixStates; + private boolean sendDig = true; public KillAura() { super("KillAura", category.combat); @@ -177,6 +178,10 @@ public class KillAura extends Module { @SubscribeEvent public void onPreUpdate(PreUpdateEvent e) { + if (sendDig && !isTargeting) { + sendDigPacket(); + sendDig = false; + } if (mc.currentScreen == null || mc.currentScreen.allowUserInput) { boolean pressedLeft = Mouse.isButtonDown(0); if (pressedLeft && !lastPressedLeft) { @@ -234,6 +239,14 @@ public class KillAura extends Module { handleBlocking(false); return; } + double distanceToBB = getDistanceToBoundingBox(target); + boolean inBlockRange = distanceToBB <= blockRange.getInput(); + if ((blinkAutoBlock() && !Utils.holdingSword()) || !inBlockRange) { // for blink autoblocks + if (blinking.get() || lag) { + resetBlinkState(true); + //Utils.print("2"); + } + } if (delayTicks >= 0) { return; } @@ -241,20 +254,12 @@ public class KillAura extends Module { resetYaw(); reset = false; } - double distanceToBB = getDistanceToBoundingBox(target); - boolean inBlockRange = distanceToBB <= blockRange.getInput(); if (!autoBlockOverride() || !inBlockRange) { // regular swing & attack if autoblock isnt overriding or isnt in autoblock range handleSwingAndAttack(distanceToBB, false); } if (inBlockRange && autoBlockOverride() && manualBlock()) { handleAutoBlock(distanceToBB); } - if ((blinkAutoBlock() && !Utils.holdingSword()) || !inBlockRange) { // for blink autoblocks - if (blinking.get() || lag) { - resetBlinkState(true); - //Utils.print("2"); - } - } if (inBlockRange && manualBlock()) { handleBlocking(true); } @@ -329,7 +334,6 @@ public class KillAura extends Module { } if (attackingEntity != null && inRange(target, attackRange.getInput())) { isTargeting = true; - fixStates = false; } else if (isTargeting) { isTargeting = false; @@ -378,12 +382,6 @@ public class KillAura extends Module { return; } blinkedPackets.add(packet); - if (packet instanceof C08PacketPlayerBlockPlacement || packet instanceof C09PacketHeldItemChange || packet instanceof C02PacketUseEntity || packet instanceof C07PacketPlayerDigging) { - // Nothing - } - else { - regularPackets.add(packet); - } e.setCanceled(true); } } @@ -391,15 +389,17 @@ public class KillAura extends Module { @SubscribeEvent public void onMouse(MouseEvent e) { if (e.button == 0 || e.button == 1) { - if (!Utils.holdingWeapon() || target == null || rotationMode.getInput() != 0) { + if (!Utils.holdingWeapon() || target == null) { return; } e.setCanceled(true); + KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false); + //hypixUtils.print("Set false?"); } } public void onCustomMouse(int button, boolean state) { - if (blinkAutoBlock() || autoBlockMode.getInput() == 3 || rotationMode.getInput() != 0) { + if (blinkAutoBlock() || autoBlockMode.getInput() == 3) { return; } if (button == 1) { @@ -681,12 +681,6 @@ public class KillAura extends Module { setKeyBindState(keyCode, blockState, false); this.blockingClient = blockState; break; - case 3: // interact a - case 4: // interact b - case 5: // interact c - case 6: // interact d - Reflection.setItemInUse(this.blockingClient = blockState); - break; case 2: // partial if (!blockState) { rightClick(partialDown = false); @@ -702,6 +696,12 @@ public class KillAura extends Module { rightClick(partialDown = true); } break; + case 3: // interact a + case 4: // interact b + case 5: // hypixel + case 6: // hypixel 2 + Reflection.setItemInUse(this.blockingClient = blockState); + break; } previousAutoBlockMode = (int) autoBlockMode.getInput(); } @@ -724,7 +724,7 @@ public class KillAura extends Module { } public boolean blinkAutoBlock() { - return (autoBlockMode.getInput() == 4 || autoBlockMode.getInput() == 5 || autoBlockMode.getInput() == 6 || autoBlockMode.getInput() == 7); + return (autoBlockMode.getInput() == 4 || autoBlockMode.getInput() == 5 || autoBlockMode.getInput() == 6); } private float unwrapYaw(float yaw, float prevYaw) { @@ -753,7 +753,6 @@ public class KillAura extends Module { if (ModuleManager.bedAura.stopAutoblock) { resetBlinkState(false); blockingServer = false; - lag = false; return; } switch ((int) autoBlockMode.getInput()) { @@ -764,14 +763,16 @@ public class KillAura extends Module { interactTicks++; switch (interactTicks) { case 1: - blinking.set(true); if (lag) { - sendDigPacket(); + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); + blocked = false; } break; case 2: + blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); + blocked = true; releasePackets(); // release lag = true; break; @@ -784,18 +785,20 @@ public class KillAura extends Module { interactTicks++; switch (interactTicks) { case 1: - blinking.set(true); if (lag) { setSwapSlot(); - swapped = true; + swapped = blocked = false; } break; case 2: if (lag) { setCurrentSlot(); + swapped = true; } + blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); + blocked = true; releasePackets(); // release lag = true; break; @@ -808,18 +811,16 @@ public class KillAura extends Module { interactTicks++; switch (interactTicks) { case 1: - blinking.set(true); if (lag) { - setSwapSlot(); - swapped = true; + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); + blocked = false; } break; case 2: - if (lag) { - setCurrentSlot(); - } + blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); + blocked = true; releasePackets(); // release lag = true; break; @@ -833,18 +834,16 @@ public class KillAura extends Module { if (!firstCycle) { switch (interactTicks) { case 1: - blinking.set(true); if (lag) { - setSwapSlot(); - swapped = true; + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); + blocked = false; } break; case 2: - if (lag) { - setCurrentSlot(); - } + blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); + blocked = true; releasePackets(); // release lag = true; break; @@ -852,31 +851,28 @@ public class KillAura extends Module { firstCycle = true; break; } - break; } else { switch (interactTicks) { case 1: - blinking.set(true); if (lag) { - setSwapSlot(); - swapped = true; + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); + blocked = false; } break; case 2: - if (lag) { - setCurrentSlot(); - } + blinking.set(true); handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); + blocked = true; releasePackets(); // release + lag = true; firstCycle = false; interactTicks = 0; - lag = true; break; } - break; } + break; } } @@ -1098,20 +1094,27 @@ public class KillAura extends Module { } public void resetBlinkState(boolean unblock) { - blinking.set(false); - blinkedPackets.clear(); - releasePackets(); //Utils.print("blink state reset"); blockingServer = false; - fixStates = true; interactTicks = 0; + blinking.set(false); + releasePackets(); + if (Raven.packetsHandler.playerSlot.get() != mc.thePlayer.inventory.currentItem && swapped) { + mc.thePlayer.sendQueue.addToSendQueue(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); + Raven.packetsHandler.playerSlot.set(mc.thePlayer.inventory.currentItem); + } + else if (unblock && lag && !ModuleManager.scaffold.isEnabled && blocked) { + sendDig = true; + } + swapped = blocked = false; + lag = false; } public void sendDigPacket() { if (!Utils.holdingSword()) { return; } - PacketUtils.sendPacketNoEvent(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); + mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); //Utils.print("Unblock"); } @@ -1121,7 +1124,6 @@ public class KillAura extends Module { for (Packet packet : blinkedPackets) { Raven.packetsHandler.handlePacket(packet); PacketUtils.sendPacketNoEvent(packet); - regularPackets.clear(); //Utils.print("blink packets"); } } @@ -1131,20 +1133,6 @@ public class KillAura extends Module { Utils.sendModuleMessage(this, "&cThere was an error releasing blinked packets"); } blinkedPackets.clear(); - try { - synchronized (regularPackets) { - for (Packet packet : regularPackets) { - Raven.packetsHandler.handlePacket(packet); - PacketUtils.sendPacketNoEvent(packet); - //Utils.print("regular packets"); - } - } - } - catch (Exception e) { - e.printStackTrace(); - Utils.sendModuleMessage(this, "&cThere was an error releasing regular packets"); - } - regularPackets.clear(); } private boolean inRange(final Entity target, final double distance) { diff --git a/src/main/java/keystrokesmod/module/impl/movement/LongJump.java b/src/main/java/keystrokesmod/module/impl/movement/LongJump.java index 622e412..6f177d1 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/LongJump.java +++ b/src/main/java/keystrokesmod/module/impl/movement/LongJump.java @@ -6,6 +6,7 @@ import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.DescriptionSetting; +import keystrokesmod.module.setting.impl.KeySetting; import keystrokesmod.module.setting.impl.SliderSetting; import keystrokesmod.utility.Reflection; import keystrokesmod.utility.Utils; @@ -16,6 +17,7 @@ import net.minecraft.network.play.server.*; import net.minecraft.potion.PotionEffect; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import org.lwjgl.input.Keyboard; public class LongJump extends Module { private SliderSetting boostSetting; @@ -28,7 +30,7 @@ public class LongJump extends Module { private ButtonSetting stopMovement; private ButtonSetting hideExplosion; - private SliderSetting temporaryFlightKey; + private KeySetting temporaryFlightKey; private SliderSetting pitchVal; private float yaw; @@ -56,7 +58,7 @@ public class LongJump extends Module { private String[] modes = new String[]{"Fireball", "Fireball Auto"}; public LongJump() { super("Long Jump", category.movement); - this.registerSetting(boostSetting = new SliderSetting("Horizontal boost", 1.7, 0.0, 2.0, 0.1)); + this.registerSetting(boostSetting = new SliderSetting("Horizontal boost", 1.7, 0.0, 2.0, 0.05)); this.registerSetting(verticalMotion = new SliderSetting("Vertical motion", 0, 0.4, 0.9, 0.01)); this.registerSetting(motionDecay = new SliderSetting("Motion decay", 17, 1, 40, 1)); this.registerSetting(allowStrafe = new ButtonSetting("Allow strafe", false)); @@ -64,24 +66,12 @@ public class LongJump extends Module { this.registerSetting(stopMovement = new ButtonSetting("Stop movement", false)); this.registerSetting(hideExplosion = new ButtonSetting("Hide explosion", false)); - this.registerSetting(temporaryFlightKey = new SliderSetting("Vertical key", 91, keyNames)); + this.registerSetting(temporaryFlightKey = new KeySetting("Vertical key", Keyboard.KEY_SPACE)); //this.registerSetting(new DescriptionSetting("Dev:")); //this.registerSetting(pitchVal = new SliderSetting("Stop movement Pitch", 55, 55, 80, 0.1)); } - String[] keyNames = { - "LMB", "RMB", "MMB", - "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", - "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", - "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", - "BACK", "CAPITAL", "COMMA", "DELETE", "DOWN", "END", "ESCAPE", "F1", "F2", "F3", "F4", "F5", - "F6", "F7", "HOME", "INSERT", "LBRACKET", "LCONTROL", "LMENU", "LMETA", "LSHIFT", "MINUS", - "NUMPAD0", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD4", "NUMPAD5", "NUMPAD6", "NUMPAD7", - "NUMPAD8", "NUMPAD9", "PERIOD", "RETURN", "RCONTROL", "RSHIFT", "RBRACKET", "SEMICOLON", - "SLASH", "SPACE", "TAB", "GRAVE" - }; - public void onEnable() { slotReset = false; slotResetTicks = 0; @@ -338,11 +328,7 @@ public class LongJump extends Module { private boolean temporaryFlightKey() { if (notMoving) return true; - if (temporaryFlightKey.getInput() > 2) { - return Utils.keybinds.isKeyDown(getKeyCode(keyNames[(int) temporaryFlightKey.getInput()])); - } else { - return Utils.keybinds.isMouseDown((int) temporaryFlightKey.getInput()); - } + return temporaryFlightKey.isPressed(); } private int getKeyCode(String keyName) { diff --git a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java index ac2fd46..460e616 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java +++ b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java @@ -7,10 +7,7 @@ import keystrokesmod.module.ModuleManager; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.DescriptionSetting; import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.ModuleUtils; -import keystrokesmod.utility.Reflection; -import keystrokesmod.utility.Utils; +import keystrokesmod.utility.*; import net.minecraft.item.*; import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; import net.minecraft.util.BlockPos; @@ -80,7 +77,8 @@ public class NoSlow extends Module { if (mc.thePlayer.onGround) { mc.thePlayer.jump(); break; - } else if (ModuleUtils.inAirTicks >= 2) { + } + else { mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, mc.thePlayer.getHeldItem()); canFloat = true; reSendConsume = false; @@ -150,20 +148,20 @@ public class NoSlow extends Module { @SubscribeEvent public void onPacketSend(SendPacketEvent e) { - if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && mode.getInput() == 4 && getSlowed() != 0.2f && holdingConsumable(((C08PacketPlayerBlockPlacement) e.getPacket()).getStack()) && !BlockUtils.isInteractable(mc.objectMouseOver) && holdingEdible(((C08PacketPlayerBlockPlacement) e.getPacket()).getStack())) { - if (ModuleManager.skyWars.isEnabled() && Utils.getSkyWarsStatus() == 1) { + if (e.getPacket() instanceof C08PacketPlayerBlockPlacement && mode.getInput() == 4 && getSlowed() != 0.2f && holdingConsumable(((C08PacketPlayerBlockPlacement) e.getPacket()).getStack()) && !BlockUtils.isInteractable(mc.objectMouseOver) && Utils.holdingEdible(((C08PacketPlayerBlockPlacement) e.getPacket()).getStack())) { + if (ModuleManager.skyWars.isEnabled() && Utils.getSkyWarsStatus() == 1 || canFloat) { return; } - if (!canFloat) { - if (!mc.thePlayer.onGround) { - canFloat = true; - } else { - if (mc.thePlayer.onGround) { - mc.thePlayer.jump(); - } - reSendConsume = true; - e.setCanceled(true); + if (!mc.thePlayer.onGround) { + canFloat = true; + } + else { + if (mc.thePlayer.onGround) { + mc.thePlayer.jump(); } + reSendConsume = true; + canFloat = false; + e.setCanceled(true); } } } diff --git a/src/main/java/keystrokesmod/module/impl/movement/Sprint.java b/src/main/java/keystrokesmod/module/impl/movement/Sprint.java index 1a956e0..9561da0 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Sprint.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Sprint.java @@ -49,7 +49,7 @@ public class Sprint extends Module { } if (ModuleManager.sprint.isEnabled() && ModuleManager.sprint.omniDirectional.getInput() == 2) { if (mc.thePlayer.onGround && mc.thePlayer.moveStrafing == 0 && mc.thePlayer.moveForward <= -0.5 && !Utils.jumpDown()) { - if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.safeWalk.canSafeWalk()) { + if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.safeWalk.canSafeWalk() && !ModuleManager.scaffold.isEnabled && !ModuleManager.bhop.isEnabled()) { float playerYaw = mc.thePlayer.rotationYaw; e.setYaw(playerYaw -= 55); } diff --git a/src/main/java/keystrokesmod/module/impl/player/BedAura.java b/src/main/java/keystrokesmod/module/impl/player/BedAura.java index e045048..85b9b83 100644 --- a/src/main/java/keystrokesmod/module/impl/player/BedAura.java +++ b/src/main/java/keystrokesmod/module/impl/player/BedAura.java @@ -4,7 +4,6 @@ import keystrokesmod.Raven; import keystrokesmod.event.*; import keystrokesmod.module.Module; import keystrokesmod.module.ModuleManager; -import keystrokesmod.module.impl.combat.KillAura; import keystrokesmod.module.impl.minigames.BedWars; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.SliderSetting; @@ -62,6 +61,8 @@ public class BedAura extends Module { private int defaultOutlineColor = new Color(226, 65, 65).getRGB(); private boolean aiming; private int noAutoBlockTicks; + private BlockPos previousBlockBroken; + private BlockPos rotateLastBlock; public BedAura() { super("BedAura", category.player, 0); @@ -91,6 +92,7 @@ public class BedAura extends Module { @Override public void onDisable() { reset(true); + previousBlockBroken = null; } @SubscribeEvent(priority = EventPriority.HIGHEST) // takes priority over ka & antifireball @@ -105,9 +107,6 @@ public class BedAura extends Module { if (Utils.isBedwarsPractice()) { return; } - if (ModuleManager.scaffold.isEnabled) { - return; - } if (!mc.thePlayer.capabilities.allowEdit || mc.thePlayer.isSpectator()) { reset(true); return; @@ -173,13 +172,17 @@ public class BedAura extends Module { @SubscribeEvent(priority = EventPriority.LOWEST) public void onPreMotion(PreMotionEvent e) { - if ((rotate || breakProgress >= 1 || breakProgress == 0) && currentBlock != null) { - float[] rotations = RotationUtils.getRotations(currentBlock, e.getYaw(), e.getPitch()); - if (!RotationUtils.inRange(currentBlock, range.getInput())) { + aiming = false; + if ((rotate || breakProgress >= 1 || breakProgress == 0) && (currentBlock != null || rotateLastBlock != null)) { + float[] rotations = RotationUtils.getRotations(currentBlock == null ? rotateLastBlock : currentBlock, e.getYaw(), e.getPitch()); + if (currentBlock != null && !RotationUtils.inRange(currentBlock, range.getInput())) { return; } e.setYaw(RotationUtils.applyVanilla(rotations[0])); e.setPitch(rotations[1]); + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7rotating (&3" + mc.thePlayer.ticksExisted + "&7)."); + } rotate = false; if (groundSpoof.isToggled() && !mc.thePlayer.isInWater()) { e.setOnGround(true); @@ -206,7 +209,7 @@ public class BedAura extends Module { } private void resetSlot() { - if (Raven.packetsHandler.playerSlot.get() != mc.thePlayer.inventory.currentItem && mode.getInput() == 2) { + if (Raven.packetsHandler != null && Raven.packetsHandler.playerSlot != null && Utils.nullCheck() && Raven.packetsHandler.playerSlot.get() != mc.thePlayer.inventory.currentItem && mode.getInput() == 2) { setPacketSlot(mc.thePlayer.inventory.currentItem); } else if (lastSlot != -1) { @@ -215,7 +218,7 @@ public class BedAura extends Module { } public boolean cancelKnockback() { - return cancelKnockback.isToggled() && Utils.usingBedAura(); + return this.isEnabled() && this.currentBlock != null && this.cancelKnockback.isToggled(); } private BlockPos[] getBedPos() { @@ -276,7 +279,8 @@ public class BedAura extends Module { } List> sortedByDistance = sortByDistance(blockMap); List> sortedByEfficiency = sortByEfficiency(sortedByDistance); - return sortedByEfficiency.isEmpty() ? null : sortedByEfficiency.get(0).getKey(); + List> sortedByPreviousBlocks = sortByPreviousBlocks(sortedByEfficiency); + return sortedByPreviousBlocks.isEmpty() ? null : sortedByPreviousBlocks.get(0).getKey(); } private List> sortByDistance(HashMap blockMap) { @@ -290,6 +294,21 @@ public class BedAura extends Module { return blockList; } + private List> sortByPreviousBlocks(List> blockList) { + blockList.sort((entry1, entry2) -> { + boolean isEntry1Previous = entry1.getKey().equals(previousBlockBroken); + boolean isEntry2Previous = entry2.getKey().equals(previousBlockBroken); + if (isEntry1Previous && !isEntry2Previous) { + return -1; + } + if (!isEntry1Previous && isEntry2Previous) { + return 1; + } + return 0; + }); + return blockList; + } + private double getEfficiency(BlockPos pos) { Block block = BlockUtils.getBlock(pos); ItemStack tool = (mode.getInput() == 2 && Utils.getTool(block) != -1) ? mc.thePlayer.inventory.getStackInSlot(Utils.getTool(block)) : mc.thePlayer.getHeldItem(); @@ -318,6 +337,7 @@ public class BedAura extends Module { lastProgress = 0; stopAutoblock = false; noAutoBlockTicks = 0; + rotateLastBlock = null; } public void setPacketSlot(int slot) { @@ -328,10 +348,16 @@ public class BedAura extends Module { } private void startBreak(BlockPos blockPos) { + if (Raven.debug) { + Utils.sendModuleMessage(this, "sending c07 &astart &7break &7(&b" + mc.thePlayer.ticksExisted + "&7)"); + } mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.START_DESTROY_BLOCK, blockPos, EnumFacing.UP)); } private void stopBreak(BlockPos blockPos) { + if (Raven.debug) { + Utils.sendModuleMessage(this, "sending c07 &cstop &7break &7(&b" + mc.thePlayer.ticksExisted + "&7)"); + } mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.STOP_DESTROY_BLOCK, blockPos, EnumFacing.UP)); } @@ -387,6 +413,7 @@ public class BedAura extends Module { setPacketSlot(Utils.getTool(block)); } stopBreak(blockPos); + previousBlockBroken = currentBlock; reset(false); Iterator> iterator = breakProgressMap.entrySet().iterator(); while (iterator.hasNext()) { @@ -398,6 +425,8 @@ public class BedAura extends Module { if (!disableBreakEffects.isToggled()) { mc.playerController.onPlayerDestroyBlock(blockPos, EnumFacing.UP); } + rotate = true; + rotateLastBlock = previousBlockBroken; return; } else { @@ -410,11 +439,17 @@ public class BedAura extends Module { } } double progress = vanillaProgress = (float) (BlockUtils.getBlockHardness(block, (mode.getInput() == 2 && Utils.getTool(block) != -1) ? mc.thePlayer.inventory.getStackInSlot(Utils.getTool(block)) : mc.thePlayer.getHeldItem(), false, ignoreSlow.isToggled() || groundSpoof.isToggled()) * breakSpeed.getInput()); - if (lastProgress != 0 && breakProgress >= lastProgress) { + if (lastProgress != 0 && breakProgress >= lastProgress - vanillaProgress) { // tick before we break so here we've gotta stop autoblocking if (mode.getInput() == 2 && ModuleManager.killAura.autoBlockOverride()) { + if (Raven.debug) { + Utils.sendModuleMessage(this, "&7stopping autoblock &7(&b" + mc.thePlayer.ticksExisted + "&7)"); + } stopAutoblock = true; // if blocking then return and stop autoblocking } + if (breakProgress >= lastProgress) { + rotate = true; + } } breakProgress += progress; breakProgressMap.put(blockPos, breakProgress); diff --git a/src/main/java/keystrokesmod/module/impl/player/NoFall.java b/src/main/java/keystrokesmod/module/impl/player/NoFall.java index ef230e9..74d3eb7 100644 --- a/src/main/java/keystrokesmod/module/impl/player/NoFall.java +++ b/src/main/java/keystrokesmod/module/impl/player/NoFall.java @@ -1,6 +1,7 @@ package keystrokesmod.module.impl.player; import keystrokesmod.event.PreMotionEvent; +import keystrokesmod.event.PreUpdateEvent; import keystrokesmod.module.Module; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.SliderSetting; @@ -41,8 +42,8 @@ public class NoFall extends Module { Utils.resetTimer(); } - @SubscribeEvent(priority = EventPriority.LOWEST) - public void onPreMotion(PreMotionEvent e) { + @SubscribeEvent + public void onPreUpdate(PreUpdateEvent e) { if (reset()) { Utils.resetTimer(); initialY = mc.thePlayer.posY; @@ -57,13 +58,13 @@ public class NoFall extends Module { double predictedY = mc.thePlayer.posY + mc.thePlayer.motionY; double distanceFallen = initialY - predictedY; edging = ""; - if (mc.thePlayer.motionY >= -0.9) { + if (mc.thePlayer.motionY >= -1.1) { dynamic = 3; } - if (mc.thePlayer.motionY < -0.9) { + if (mc.thePlayer.motionY < -1.1) { dynamic = 3.5; } - if (mc.thePlayer.motionY < -1.7) { + if (mc.thePlayer.motionY < -1.8) { dynamic = 4; } if (mc.thePlayer.motionY < -2.4) { @@ -71,26 +72,32 @@ public class NoFall extends Module { } if (isFalling || mode.getInput() == 2) { switch ((int) mode.getInput()) { - case 0: - e.setOnGround(true); - break; case 1: if (distanceFallen >= dynamic) { Utils.getTimer().timerSpeed = (float) 0.72; - PacketUtils.sendPacketNoEvent(new C03PacketPlayer(true)); + mc.getNetHandler().addToSendQueue(new C03PacketPlayer(true)); initialY = mc.thePlayer.posY; edging = "nofall packet"; } break; - case 2: - e.setOnGround(false); - break; } } edging += " " + dynamic; //Utils.print("" + mc.thePlayer.ticksExisted + " " + mc.thePlayer.motionY + " " + edging); } + @SubscribeEvent(priority = EventPriority.LOWEST) + public void onPreMotion(PreMotionEvent e) { + switch ((int) mode.getInput()) { + case 0: + e.setOnGround(true); + break; + case 2: + e.setOnGround(false); + break; + } + } + @Override public String getInfo() { return modes[(int) mode.getInput()]; diff --git a/src/main/java/keystrokesmod/module/impl/player/NoRotate.java b/src/main/java/keystrokesmod/module/impl/player/NoRotate.java index a031644..2da170b 100644 --- a/src/main/java/keystrokesmod/module/impl/player/NoRotate.java +++ b/src/main/java/keystrokesmod/module/impl/player/NoRotate.java @@ -1,107 +1,37 @@ package keystrokesmod.module.impl.player; -import keystrokesmod.Raven; -import keystrokesmod.event.ReceivePacketEvent; -import keystrokesmod.event.SendPacketEvent; import keystrokesmod.module.Module; -import keystrokesmod.utility.PacketUtils; -import keystrokesmod.utility.Utils; -import net.minecraft.network.INetHandler; -import net.minecraft.network.Packet; -import net.minecraft.network.play.client.C03PacketPlayer; import net.minecraft.network.play.server.S08PacketPlayerPosLook; -import net.minecraft.util.Vec3; -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class NoRotate extends Module { - private S08Info s08PacketData; - private int receivedTick; - - private Packet sentPacket; - private Packet recievedPacket; + private float prevPitch = 0f; + private float prevYaw = 0f; public NoRotate() { super("NoRotate", category.player); } - @SubscribeEvent - public void onReceivePacket(ReceivePacketEvent e) { - if (e.getPacket() instanceof S08PacketPlayerPosLook && mc.thePlayer != null && ((S08PacketPlayerPosLook) e.getPacket()).getPitch() != 0) { - if (e.getPacket() == recievedPacket) { - return; - } - e.setCanceled(true); - S08PacketPlayerPosLook p = (S08PacketPlayerPosLook) e.getPacket(); - recievedPacket = (new S08PacketPlayerPosLook(p.getX(), p.getY(), p.getZ(), mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, p.func_179834_f())); - //((S08PacketPlayerPosLook) recievedPacket).processPacket(mc.getNetHandler()); - checkThreadAndEnqueue(recievedPacket); - s08PacketData = getPosAndRotation(p); - receivedTick = mc.thePlayer.ticksExisted; + public void handlePlayerPosLookPre() { + if (!this.isEnabled()) { + return; } + if (mc.thePlayer == null || (mc.thePlayer.rotationPitch % 1 == 0f && mc.thePlayer.rotationYaw % 1 == 0f)) { + return; + } + prevPitch = mc.thePlayer.rotationPitch % 360; + prevYaw = mc.thePlayer.rotationYaw % 360; } - @SubscribeEvent - public void onSendPacket(SendPacketEvent e) { - if (s08PacketData != null && mc.thePlayer != null && e.getPacket() instanceof C03PacketPlayer.C06PacketPlayerPosLook) { - if (Utils.timeBetween(mc.thePlayer.ticksExisted, receivedTick) >= 3) { - s08PacketData = null; - return; - } - if (e.getPacket() == sentPacket) { - return; - } - C03PacketPlayer.C06PacketPlayerPosLook p = (C03PacketPlayer.C06PacketPlayerPosLook) e.getPacket(); - e.setCanceled(true); - sentPacket = (new C03PacketPlayer.C06PacketPlayerPosLook(p.getPositionX(), p.getPositionY(), p.getPositionZ(), s08PacketData.yaw, s08PacketData.pitch, p.isOnGround())); - mc.getNetHandler().addToSendQueue(sentPacket); - if (Raven.debug) { - Utils.sendModuleMessage(this, "&7spoofing c06 immediately."); - } + public void handlePlayerPosLook(S08PacketPlayerPosLook packet) { + if (!this.isEnabled()) { + return; } - } - - public S08Info getPosAndRotation(final S08PacketPlayerPosLook packet) { - double x = packet.getX(); - double y = packet.getY(); - double z = packet.getZ(); - float yaw = packet.getYaw(); - float pitch = packet.getPitch(); - if (packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.X)) { - x += mc.thePlayer.posX; - } - if (packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Y)) { - y += mc.thePlayer.posY; - } - if (packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Z)) { - z += mc.thePlayer.posZ; - } - if (packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.X_ROT)) { - pitch += mc.thePlayer.rotationPitch; - } - if (packet.func_179834_f().contains(S08PacketPlayerPosLook.EnumFlags.Y_ROT)) { - yaw += mc.thePlayer.rotationYaw; - } - return new S08Info(new Vec3(x, y, z), yaw, pitch); - } - - public void checkThreadAndEnqueue(Packet packet) { - if (!mc.isCallingFromMinecraftThread()) { - mc.addScheduledTask(() -> packet.processPacket((T) mc.getNetHandler())); - } - } - - class S08Info { - Vec3 position; - float yaw, pitch; - - public S08Info(Vec3 position, float yaw, float pitch) { - this.position = position; - this.yaw = yaw; - this.pitch = pitch; - } - - public boolean samePos(Vec3 position) { - return this.position.xCoord == position.xCoord && this.position.yCoord == position.yCoord && this.position.zCoord == position.zCoord; + if (packet.getPitch() % 1.0f == 0.0f || mc.thePlayer == null) { + return; } + mc.thePlayer.prevRotationYaw = prevYaw; + mc.thePlayer.prevRotationPitch = prevPitch; + mc.thePlayer.rotationPitch = prevPitch; + mc.thePlayer.rotationYaw = prevYaw; } } \ No newline at end of file diff --git a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java index 8958569..1e64c2a 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java +++ b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java @@ -81,7 +81,7 @@ public class Scaffold extends Module { private int blockSlot = -1; private boolean modifyPitch; private boolean flipRotation; - private long lastSwap; + private long lastSwap, lastSwap2; private boolean floatJumped; private boolean floatStarted; @@ -193,7 +193,7 @@ public class Scaffold extends Module { } //Float - if (sprint.getInput() == 2 && mc.thePlayer.motionY <= -0.0784 && !usingFastScaffold() && !ModuleManager.bhop.isEnabled() && !ModuleManager.tower.canTower() && !ModuleManager.LongJump.isEnabled()) { + if (sprint.getInput() == 2 && !usingFastScaffold() && !ModuleManager.bhop.isEnabled() && !ModuleManager.tower.canTower() && !ModuleManager.LongJump.isEnabled()) { floatWasEnabled = true; if (!floatStarted) { if (onGroundTicks > 8 && mc.thePlayer.onGround) { @@ -240,35 +240,83 @@ public class Scaffold extends Module { e.setYaw(blockRotations[0]); e.setPitch(blockRotations[1]); + float yawBackwards = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); + float main = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); + float mainOffset = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); + float mainOffset2 = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); + float minOffset = 25; if (rotation.getInput() == 2) { - e.setYaw(offsetRotation()); - - float main = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); - if (main >= 0) { - if (flipRotation) e.setYaw(offsetRotation() + (!Utils.scaffoldDiagonal(false) ? 244.625F : 274.625F)); - //Utils.print("1 " + mainOffset); - } - else if (main <= -0) { - if (flipRotation) e.setYaw(offsetRotation() - (!Utils.scaffoldDiagonal(false) ? 244.625F : 274.625F)); - //Utils.print("2 " + mainOffset); - } - if (System.currentTimeMillis() - lastSwap > 250) { - if (main >= 0 && mainOffset >= 0 && mainOffset <= 20 || main <= -0 && mainOffset <= -0 && mainOffset >= -20) { - flipRotation = true; + if (blockRotations != null) { + lastBlockYaw = blockRotations[0]; + if (!flipRotation) { + if (main >= 0) { + //Utils.print("Main1"); + if (mainOffset >= 0) mainOffset = 0; + if (mainOffset <= -minOffset) mainOffset = -minOffset; + } else if (main <= -0) { + //Utils.print("Main2"); + if (mainOffset <= -0) mainOffset = -0; + if (mainOffset >= minOffset) mainOffset = minOffset; + } } else { - flipRotation = false; + if (main >= 0) { + //Utils.print("Main1"); + //Utils.print("1 " + mainOffset); + if (mainOffset <= -0) mainOffset2 = -0; + if (mainOffset >= minOffset) mainOffset2 = minOffset; + } else if (main <= -0) { + //Utils.print("Main2"); + //Utils.print("2 " + mainOffset); + if (mainOffset >= 0) mainOffset2 = 0; + if (mainOffset <= -minOffset) mainOffset2 = -minOffset; + } } - lastSwap = System.currentTimeMillis(); - //Utils.print("flip " + mainOffset); - } - - /*if (e.getPitch() >= 50 && !ModuleManager.tower.canTower() && mc.thePlayer.motionY <= 0.42F) { - e.setPitch(e.getPitch() + 8); } else { - e.setPitch(e.getPitch() + 5); + lastBlockYaw = ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedYaw(); + if (main >= 0) { + mainOffset = -35; + } + else if (main <= -0) { + mainOffset = 35; + } + } + e.setYaw(offsetRotation()); + if (main >= 0) { + if (flipRotation) { + e.setYaw(offsetRotation() + (!Utils.scaffoldDiagonal(false) ? straightRot * 2 : diagRot * 2)); + //Utils.print("1 "); + } + } + else if (main <= -0) { + if (flipRotation) { + e.setYaw(offsetRotation() - (!Utils.scaffoldDiagonal(false) ? straightRot * 2 : diagRot * 2)); + //Utils.print("2 "); + } + } + } + + if (System.currentTimeMillis() - lastSwap > 300) { + if (main >= 0 && mainOffset >= 0 || main <= -0 && mainOffset <= -0) { + flipRotation = true; + } else { + flipRotation = false; + } + lastSwap = System.currentTimeMillis(); + //Utils.print("flip " + mainOffset); + } + + if (!flipRotation) { + e.setYaw(e.getYaw() - mainOffset); + } + else { + /*if (main >= 0) { + e.setYaw(e.getYaw() - mainOffset2); + } else if (main <= -0) { + e.setYaw(e.getYaw() + mainOffset2); }*/ + e.setYaw(e.getYaw() - mainOffset2); } if (rotation.getInput() == 1) { @@ -307,52 +355,21 @@ public class Scaffold extends Module { } private float yaw; - float newYaw; - float mainOffset; - boolean hasEdged; + float straightRot = 130.625F; + float diagRot = 136.625F; private float offsetRotation() { - float yawBackwards = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); - float motionYaw = getMotionYaw(); - float main = MathHelper.wrapAngleTo180_float(motionYaw - yaw); - - if (blockRotations != null) { - lastBlockYaw = blockRotations[0]; - mainOffset = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); - float minOffset = 28; - if (main >= 0) { - //Utils.print("Main1"); - if (mainOffset >= 0) mainOffset = 0; - if (mainOffset <= -minOffset) mainOffset = -minOffset; - } - if (main <= -0) { - //Utils.print("Main2"); - if (mainOffset <= -0) mainOffset = -0; - if (mainOffset >= minOffset) mainOffset = minOffset; - } - } - else { - lastBlockYaw = ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedYaw(); - if (main >= 0) { - mainOffset = -25; - } - else if (main <= -0) { - mainOffset = 25; - } - lastSwap = System.currentTimeMillis(); - } if (!Utils.isMoving() || Utils.getHorizontalSpeed(mc.thePlayer) == 0.0D) { return yaw; } - float lastYaw = lastBlockYaw; - float newYaw = getMotionYaw() - (!Utils.scaffoldDiagonal(false) ? 128.625F : 138.625F) * Math.signum( + float newYaw = getMotionYaw() - (!Utils.scaffoldDiagonal(false) ? straightRot : diagRot) * Math.signum( MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw) ); yaw = applyGcd( - lastYaw + MathHelper.wrapAngleTo180_float(newYaw - lastYaw) - mainOffset + lastBlockYaw + MathHelper.wrapAngleTo180_float(newYaw - lastBlockYaw) ); return yaw; } @@ -410,7 +427,7 @@ public class Scaffold extends Module { } if (disabledModule) { - if (ModuleManager.tower.canTower() && ModuleManager.tower.dCount == 0 || floatStarted) { + if (ModuleManager.tower.canTower() && (ModuleManager.tower.dCount == 0 || !Utils.isMoving()) || floatStarted) { dontDisable = true; } diff --git a/src/main/java/keystrokesmod/module/impl/player/Tower.java b/src/main/java/keystrokesmod/module/impl/player/Tower.java index c0828ff..bdc986b 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Tower.java +++ b/src/main/java/keystrokesmod/module/impl/player/Tower.java @@ -155,10 +155,8 @@ public class Tower extends Module { } slowTicks = 0; } - if (towerMove.getInput() == 2) { - hasTowered = tower = firstJump = startedTowerInAir = setLowMotion = speed = false; - cMotionTicks = placeTicks = 0; - } + hasTowered = tower = firstJump = startedTowerInAir = setLowMotion = speed = false; + cMotionTicks = placeTicks = 0; reset(); } if (canTower() && !Utils.keysDown()) { diff --git a/src/main/java/keystrokesmod/module/impl/render/Nametags.java b/src/main/java/keystrokesmod/module/impl/render/Nametags.java index 65badf3..8afe44f 100644 --- a/src/main/java/keystrokesmod/module/impl/render/Nametags.java +++ b/src/main/java/keystrokesmod/module/impl/render/Nametags.java @@ -46,7 +46,7 @@ public class Nametags extends Module { public Nametags() { super("Nametags", category.render, 0); - this.registerSetting(scale = new SliderSetting("Scale", 1.0, 0.5, 5.0, 0.1)); + this.registerSetting(scale = new SliderSetting("Scale", 1.0, 0.1, 5.0, 0.1)); this.registerSetting(autoScale = new ButtonSetting("Auto-scale", true)); this.registerSetting(drawBackground = new ButtonSetting("Draw background", true)); this.registerSetting(onlyRenderName = new ButtonSetting("Only render name", false)); diff --git a/src/main/java/keystrokesmod/module/setting/impl/KeySetting.java b/src/main/java/keystrokesmod/module/setting/impl/KeySetting.java new file mode 100644 index 0000000..7934e47 --- /dev/null +++ b/src/main/java/keystrokesmod/module/setting/impl/KeySetting.java @@ -0,0 +1,51 @@ +package keystrokesmod.module.setting.impl; + +import com.google.gson.JsonObject; +import keystrokesmod.module.setting.Setting; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +public class KeySetting extends Setting { + private int key; + + public KeySetting(String name, int key) { + super(name); + this.key = key; + } + + public int getKey() { + return this.key; + } + + public String getName() { + return super.getName(); + } + + public void setKey(int key) { + this.key = key; + } + + public boolean isPressed() { + if (this.getKey() == 0) { + return false; + } + if (this.getKey() >= 1000) { + return Mouse.isButtonDown(this.getKey() - 1000); + } + else { + return Keyboard.isKeyDown(this.getKey()); + } + } + + @Override + public void loadProfile(JsonObject data) { + if (data.has(getName()) && data.get(getName()).isJsonPrimitive()) { + int keyValue = this.key; + try { + keyValue = data.getAsJsonPrimitive(getName()).getAsInt(); + } + catch (Exception ignored) {} + this.key = keyValue; + } + } +} \ No newline at end of file diff --git a/src/main/java/keystrokesmod/utility/ModuleUtils.java b/src/main/java/keystrokesmod/utility/ModuleUtils.java index 2b8abb4..4e59929 100644 --- a/src/main/java/keystrokesmod/utility/ModuleUtils.java +++ b/src/main/java/keystrokesmod/utility/ModuleUtils.java @@ -81,25 +81,6 @@ public class ModuleUtils { isBreakingTick = 0; } - if (ModuleManager.killAura.fixStates) { - if (!ModuleManager.killAura.isTargeting && ModuleManager.killAura.lag && !ModuleManager.scaffold.isEnabled) { - if (!Utils.holdingSword() && ModuleManager.killAura.swapped) { - PacketUtils.sendPacketNoEvent(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); - ModuleManager.killAura.swapped = false; - } else { - if (Utils.holdingSword()) { - PacketUtils.sendPacketNoEvent(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); - ModuleManager.killAura.swapped = false; - } - } - } - else { - ModuleManager.killAura.swapped = false; - } - ModuleManager.killAura.fixStates = false; - ModuleManager.killAura.lag = false; - } - if (ModuleManager.killAura.justUnTargeted) { if (++ModuleManager.killAura.unTargetTicks >= 2) { ModuleManager.killAura.unTargetTicks = 0; @@ -146,7 +127,7 @@ public class ModuleUtils { } if (ModuleManager.bhop.rotateYawOption.isToggled()) { if (ModuleManager.bhop.setRotation) { - if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow()) { + if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.scaffold.isEnabled) { float playerYaw = mc.thePlayer.rotationYaw; e.setYaw(playerYaw -= 55); } diff --git a/src/main/java/keystrokesmod/utility/Utils.java b/src/main/java/keystrokesmod/utility/Utils.java index 841527f..5b1f2df 100644 --- a/src/main/java/keystrokesmod/utility/Utils.java +++ b/src/main/java/keystrokesmod/utility/Utils.java @@ -61,6 +61,22 @@ public class Utils { return false; } + public static boolean holdingEdible(ItemStack stack) { + if (stack.getItem() instanceof ItemFood && mc.thePlayer.getFoodStats().getFoodLevel() == 20) { + ItemFood food = (ItemFood) stack.getItem(); + boolean alwaysEdible = false; + try { + alwaysEdible = Reflection.alwaysEdible.getBoolean(food); + } + catch (Exception e) { + Utils.sendMessage("&cError checking food edibility, check logs."); + e.printStackTrace(); + } + return alwaysEdible; + } + return true; + } + public static boolean removeEnemy(String name) { if (enemies.remove(name.toLowerCase())) { Utils.sendMessage("&7Removed &cenemy&7: &b" + name); diff --git a/src/main/java/keystrokesmod/utility/profile/ProfileManager.java b/src/main/java/keystrokesmod/utility/profile/ProfileManager.java index 84e79c7..a180873 100644 --- a/src/main/java/keystrokesmod/utility/profile/ProfileManager.java +++ b/src/main/java/keystrokesmod/utility/profile/ProfileManager.java @@ -10,6 +10,7 @@ import keystrokesmod.module.impl.render.HUD; import keystrokesmod.module.impl.render.TargetHUD; import keystrokesmod.module.setting.Setting; import keystrokesmod.module.setting.impl.ButtonSetting; +import keystrokesmod.module.setting.impl.KeySetting; import keystrokesmod.module.setting.impl.SliderSetting; import keystrokesmod.script.Manager; import keystrokesmod.utility.Utils; @@ -95,9 +96,13 @@ public class ProfileManager { for (Setting setting : module.getSettings()) { if (setting instanceof ButtonSetting && !((ButtonSetting) setting).isMethodButton) { moduleInformation.addProperty(setting.getName(), ((ButtonSetting) setting).isToggled()); - } else if (setting instanceof SliderSetting) { + } + else if (setting instanceof SliderSetting) { moduleInformation.addProperty(setting.getName(), ((SliderSetting) setting).getInput()); } + else if (setting instanceof KeySetting) { + moduleInformation.addProperty(setting.getName(), ((KeySetting) setting).getKey()); + } } return moduleInformation; } @@ -308,4 +313,4 @@ public class ProfileManager { public void failedMessage(String reason, String name) { Utils.sendMessage("&cFailed to " + reason + ": &b" + name); } -} +} \ No newline at end of file diff --git a/src/main/resources/mixins.raven.json b/src/main/resources/mixins.raven.json index e7d60d5..3d8de86 100644 --- a/src/main/resources/mixins.raven.json +++ b/src/main/resources/mixins.raven.json @@ -23,6 +23,7 @@ "client.MixinWorld", "render.MixinGuiChat", "render.MixinGuiScreen", - "entity.IAccessorEntityPlayerSP" + "entity.IAccessorEntityPlayerSP", + "network.MixinNetHandlerPlayClient" ] } \ No newline at end of file