From 9a2eff4c42af20073efbd55f8d0a223361d13a53 Mon Sep 17 00:00:00 2001 From: jackh Date: Sun, 19 Jan 2025 00:48:12 -0700 Subject: [PATCH] recoded scaffold rotations (10000x better) and fixed some other issues --- .../keystrokesmod/event/PreMotionEvent.java | 10 +- .../module/impl/combat/KillAura.java | 61 ++-- .../module/impl/movement/Bhop.java | 2 +- .../module/impl/movement/NoSlow.java | 2 +- .../module/impl/movement/Sprint.java | 2 +- .../module/impl/player/Blink.java | 13 +- .../module/impl/player/Scaffold.java | 299 +++++++++--------- .../module/impl/player/Tower.java | 21 +- .../module/impl/render/BedESP.java | 89 ++++-- .../keystrokesmod/utility/ModuleUtils.java | 15 +- .../java/keystrokesmod/utility/Utils.java | 5 + 11 files changed, 269 insertions(+), 250 deletions(-) diff --git a/src/main/java/keystrokesmod/event/PreMotionEvent.java b/src/main/java/keystrokesmod/event/PreMotionEvent.java index 2888b46..ca45028 100644 --- a/src/main/java/keystrokesmod/event/PreMotionEvent.java +++ b/src/main/java/keystrokesmod/event/PreMotionEvent.java @@ -13,7 +13,6 @@ public class PreMotionEvent extends Event { private static boolean setRenderYaw; private boolean isSprinting; private boolean isSneaking; - public static boolean setRotations; public PreMotionEvent(double posX, double posY, double posZ, float yaw, float pitch, boolean onGround, boolean isSprinting, boolean isSneaking) { this.posX = posX; @@ -65,17 +64,20 @@ public class PreMotionEvent extends Event { public void setYaw(float yaw) { this.yaw = yaw; this.setRenderYaw = true; - setRotations = true; } public void setYawSilent(float yaw) { this.yaw = yaw; - setRotations = true; } public void setPitch(float pitch) { this.pitch = pitch; - setRotations = true; + } + + public void setRotations(float yaw, float pitch) { + this.yaw = yaw; + this.setRenderYaw = true; + this.pitch = pitch; } public void setOnGround(boolean onGround) { diff --git a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java index 70a00ba..b3ce70a 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java +++ b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java @@ -367,7 +367,7 @@ public class KillAura extends Module { return; } if (rotationMode.getInput() != 2) { - if (inRange(target, attackRange.getInput() - 0.005)) { + if (inRange(target, attackRange.getInput() - 0.006)) { float[] rotations = RotationUtils.getRotations(target, e.getYaw(), e.getPitch()); float[] smoothedRotations = getRotationsSmoothed(rotations); if (rotationMode.getInput() == 0) { // silent @@ -394,7 +394,7 @@ public class KillAura extends Module { public void onUpdate() { if (rotationMode.getInput() == 1 && target != null) { - if (inRange(target, attackRange.getInput() - 0.005)) { + if (inRange(target, attackRange.getInput() - 0.006)) { float[] rotations = RotationUtils.getRotations(target, mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch); float[] smoothedRotations = getRotationsSmoothed(rotations); mc.thePlayer.rotationYaw = smoothedRotations[0]; @@ -569,14 +569,14 @@ public class KillAura extends Module { continue; } } -// else if (entity instanceof EntityCreature && attackMobs.isToggled()) { -// if (((EntityCreature) entity).tasks == null || ((EntityCreature) entity).isAIDisabled() || ((EntityCreature) entity).deathTime != 0) { // no ai -// continue; -// } -// if (!entity.getClass().getCanonicalName().startsWith("net.minecraft.entity.monster.")) { -// continue; -// } -// } + else if (entity instanceof EntityCreature && attackMobs.isToggled()) { + if (((EntityCreature) entity).tasks == null || ((EntityCreature) entity).isAIDisabled() || ((EntityCreature) entity).deathTime != 0) { // no ai + continue; + } + if (!entity.getClass().getCanonicalName().startsWith("net.minecraft.entity.monster.")) { + continue; + } + } else { continue; } @@ -598,10 +598,10 @@ public class KillAura extends Module { if (distanceRayCasted > maxRange) { continue; } - if (target instanceof EntityCreature && !isHostile((EntityCreature) target)) { + if (!(target instanceof EntityPlayer) && attackMobs.isToggled() && !isHostile((EntityCreature) target)) { continue; } - if (!hitThroughBlocks.isToggled() && (!Utils.canPlayerBeSeen(target) || !inRange(target, attackRange.getInput() - 0.005))) { + if (!hitThroughBlocks.isToggled() && (!Utils.canPlayerBeSeen(target) || !inRange(target, attackRange.getInput() - 0.006))) { continue; } toClassTargets.add(new KillAuraTarget(distanceRayCasted, target.getHealth(), target.hurtTime, RotationUtils.distanceFromYaw(target, false), target.getEntityId(), (target instanceof EntityPlayer) ? Utils.isEnemy((EntityPlayer) target) : false)); @@ -640,7 +640,7 @@ public class KillAura extends Module { List attackTargets = new ArrayList<>(); for (KillAuraTarget killAuraTarget : toClassTargets) { - if (killAuraTarget.distance <= attackRange.getInput() - 0.005) { + if (killAuraTarget.distance <= attackRange.getInput() - 0.006) { attackTargets.add(killAuraTarget); } } @@ -655,7 +655,7 @@ public class KillAura extends Module { if (firstHit == null || ticksExisted - firstHit >= switchDelayTicks) { continue; } - if (auraTarget.distance < attackRange.getInput() - 0.005) { + if (auraTarget.distance < attackRange.getInput() - 0.006) { setTarget(mc.theWorld.getEntityByID(auraTarget.entityId)); return; } @@ -680,7 +680,7 @@ public class KillAura extends Module { } private void handleSwingAndAttack(double distance, boolean swung) { - boolean inAttackDistance = inRange(target, attackRange.getInput() - 0.005); + boolean inAttackDistance = inRange(target, attackRange.getInput() - 0.006); if ((distance <= swingRange.getInput() || inAttackDistance) && shouldAttack && !swung) { // swing if in swing range or needs to attack if (!mc.thePlayer.isBlocking() || !disableWhileBlocking.isToggled()) { swingItem(); @@ -765,7 +765,7 @@ public class KillAura extends Module { } private double getMaxRange() { - return Math.max(Math.max(swingRange.getInput(), attackRange.getInput() - 0.005), blockRange.getInput()); + return Math.max(Math.max(swingRange.getInput(), attackRange.getInput() - 0.006), blockRange.getInput()); } public boolean autoBlockOverride() { @@ -782,13 +782,13 @@ public class KillAura extends Module { private boolean isLookingAtEntity() { // if (rotationMode.getInput() == 0 && rotationSmoothing.getInput() > 0) { // silent - return RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - 0.005, RotationUtils.serverRotations); + return RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - 0.006, RotationUtils.serverRotations); } return true; } private void handleAutoBlock(double distance) { - boolean inAttackDistance = inRange(target, attackRange.getInput() - 0.005); + boolean inAttackDistance = inRange(target, attackRange.getInput() - 0.006); if (inAttackDistance) { attackingEntity = target; } @@ -855,24 +855,23 @@ public class KillAura extends Module { } break; case 5: // hypixel a - if (interactTicks >= 4) { + if (interactTicks >= 3) { interactTicks = 0; } interactTicks++; switch (interactTicks) { case 1: blinking.set(true); - if (lag) { + if (blocked) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); blocked = false; } break; - case 3: + case 2: handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); blocked = true; releasePackets(); // release - lag = true; break; } break; @@ -883,21 +882,20 @@ public class KillAura extends Module { interactTicks++; if (firstCycle) { switch (interactTicks) { - case 1: + case 2: blinking.set(true); - if (lag) { + if (blocked) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); blocked = false; } break; - case 2: + case 3: handleInteractAndAttack(distance, true, true, swung); sendBlockPacket(); blocked = true; releasePackets(); - lag = true; - firstEdge = 1; firstCycle = false; + lag = true; break; } } @@ -905,7 +903,7 @@ public class KillAura extends Module { switch (interactTicks) { case 1: blinking.set(true); - if (lag) { + if (blocked) { mc.thePlayer.sendQueue.addToSendQueue(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, DOWN)); blocked = false; } @@ -915,12 +913,9 @@ public class KillAura extends Module { sendBlockPacket(); blocked = true; releasePackets(); - lag = true; interactTicks = 0; - if (firstEdge == 0) { - firstEdge = 1; - } firstCycle = true; + lag = true; break; } } @@ -1066,7 +1061,7 @@ public class KillAura extends Module { } boolean sent = false; if (interactAt) { - boolean canHit = RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - 0.005, RotationUtils.serverRotations); + boolean canHit = RotationUtils.isPossibleToHit(attackingEntity, attackRange.getInput() - 0.006, RotationUtils.serverRotations); if (!canHit) { return; } diff --git a/src/main/java/keystrokesmod/module/impl/movement/Bhop.java b/src/main/java/keystrokesmod/module/impl/movement/Bhop.java index 5ce31c9..3958a19 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Bhop.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Bhop.java @@ -61,7 +61,7 @@ public class Bhop extends Module { collided = false; } if (mc.thePlayer.onGround) { - if (mc.thePlayer.moveForward <= -0.5 && mc.thePlayer.moveStrafing == 0) { + if (mc.thePlayer.moveForward <= -0.5 && mc.thePlayer.moveStrafing == 0 && !ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.scaffold.isEnabled && !mc.thePlayer.isCollidedHorizontally) { setRotation = true; } mc.thePlayer.jump(); diff --git a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java index 53155a6..900a18d 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java +++ b/src/main/java/keystrokesmod/module/impl/movement/NoSlow.java @@ -210,7 +210,7 @@ public class NoSlow extends Module { speedModifier = 0.37; break; } - return speedModifier; + return speedModifier - 0.005; } private boolean holdingConsumable(ItemStack itemStack) { diff --git a/src/main/java/keystrokesmod/module/impl/movement/Sprint.java b/src/main/java/keystrokesmod/module/impl/movement/Sprint.java index c72f78e..7e5e136 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/Sprint.java +++ b/src/main/java/keystrokesmod/module/impl/movement/Sprint.java @@ -64,7 +64,7 @@ public class Sprint extends Module { } public boolean disableBackwards() { - limit = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw - ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedYaw()); + limit = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw - Utils.getLastReportedYaw()); double limitVal = 135; if (!disableBackwards.isToggled()) { return false; diff --git a/src/main/java/keystrokesmod/module/impl/player/Blink.java b/src/main/java/keystrokesmod/module/impl/player/Blink.java index b7e2bf7..5780fd1 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Blink.java +++ b/src/main/java/keystrokesmod/module/impl/player/Blink.java @@ -88,12 +88,17 @@ public class Blink extends Module { return; } Packet packet = e.getPacket(); - if (e.isCanceled() || packet.getClass().getSimpleName().startsWith("S") || packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { + if (packet.getClass().getSimpleName().startsWith("S")) { return; } - started = true; - blinkedPackets.add(packet); - e.setCanceled(true); + if (packet instanceof C00PacketLoginStart || packet instanceof C00Handshake) { + return; + } + if (!e.isCanceled()) { + started = true; + blinkedPackets.add(packet); + e.setCanceled(true); + } } @Override diff --git a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java index 13cca31..cbefb49 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Scaffold.java +++ b/src/main/java/keystrokesmod/module/impl/player/Scaffold.java @@ -58,9 +58,7 @@ public class Scaffold extends Module { public boolean hasSwapped; private boolean rotateForward; - private int keepYDelay; private int onGroundTicks; - private int keepYPlaceTicks; private double startYPos = -1; public boolean fastScaffoldKeepY; private boolean firstKeepYPlace; @@ -69,10 +67,6 @@ public class Scaffold extends Module { private boolean lowhop; private int rotationDelay; private int blockSlot = -1; - private boolean modifyPitch; - private boolean flipRotation; - private long lastSwap, lastSwap2; - private boolean didFlip; public boolean canBlockFade; @@ -86,20 +80,17 @@ public class Scaffold extends Module { private Vec3 blockPos, hitVec, lookVec; private float[] blockRotations; private long lastPlaceTime, rotationTimeout = 250L; - private float getPitch; private float lastYaw = 0.0f; private float lastPitch = 0.0f; - private float lastBlockYaw; - - private static float rotOffset; - - private long firstStroke; + private float yaw, pitch, blockYaw; + private boolean set2; public boolean moduleEnabled; public boolean isEnabled; private boolean disabledModule; private boolean dontDisable; private int disableTicks; + private int scaffoldTicks; public Scaffold() { super("Scaffold", category.player); @@ -131,7 +122,6 @@ public class Scaffold extends Module { isEnabled = true; moduleEnabled = true; ModuleUtils.fadeEdge = 0; - firstStroke = System.currentTimeMillis(); FMLCommonHandler.instance().bus().register(scaffoldBlockCount = new ScaffoldBlockCount(mc)); lastSlot.set(-1); @@ -155,12 +145,18 @@ public class Scaffold extends Module { if (!isEnabled || !holdingBlocks()) { return; } + if (Utils.isMoving()) { + scaffoldTicks++; + } + else { + scaffoldTicks = 0; + } canBlockFade = true; int simpleY = (int) Math.round((e.posY % 1) * 10000); if (Utils.keysDown() && usingFastScaffold() && fastScaffold.getInput() >= 1 && !ModuleManager.tower.canTower() && !ModuleManager.LongJump.isEnabled()) { // jump mode if (mc.thePlayer.onGround && Utils.isMoving()) { - rotateForward = true; - if (++keepYDelay >= 2 || keepYPlaceTicks > 0 || onGroundTicks > 1) { + if (scaffoldTicks > 1) { + rotateForward = true; mc.thePlayer.jump(); Utils.setSpeed(getSpeed(getSpeedLevel()) - Utils.randomizeDouble(0.001, 0.0001)); if (fastScaffold.getInput() == 5 || fastScaffold.getInput() == 2 && firstKeepYPlace) { @@ -177,7 +173,7 @@ public class Scaffold extends Module { else if (fastScaffoldKeepY) { fastScaffoldKeepY = firstKeepYPlace = false; startYPos = -1; - keepYDelay = keepYTicks = keepYPlaceTicks = 0; + keepYTicks = 0; } if (lowhop) { switch (simpleY) { @@ -214,10 +210,12 @@ public class Scaffold extends Module { if (floatStarted && mc.thePlayer.onGround) { floatKeepY = false; startYPos = -1; - if (moduleEnabled && !Utils.jumpDown()) e.setPosY(e.getPosY() + 1E-11); - if (Utils.isMoving()) Utils.setSpeed(getFloatSpeed(getSpeedLevel())); + if (moduleEnabled) { + e.setPosY(e.getPosY() + 1E-11); + if (Utils.isMoving()) Utils.setSpeed(getFloatSpeed(getSpeedLevel())); + } } - } else if (floatWasEnabled) { + } else if (floatWasEnabled && moduleEnabled) { if (floatKeepY) { startYPos = -1; } @@ -231,158 +229,138 @@ public class Scaffold extends Module { targetBlock = null; } - getPitch = 82; if (ModuleUtils.inAirTicks >= 1) { rotateForward = false; } - if (rotation.getInput() > 0 && (!rotateForward || !jumpFacingForward.isToggled())) { - rotatingForward = false; - if (rotation.getInput() > 0) { - float yawBackwards = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); - float main = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); - float mainOffset = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); - float rawOffset = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); - float mainOffset2 = MathHelper.wrapAngleTo180_float(yawBackwards - lastBlockYaw); - rotOffset = (!Utils.scaffoldDiagonal(false)) ? 135F : 140F; - float minOffset = (!Utils.scaffoldDiagonal(false)) ? 30 : 0; + + switch ((int) rotation.getInput()) { + case 1: + e.setRotations(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(), 82); + break; + + + + + + + + case 2: if (blockRotations != null) { - e.setYaw(blockRotations[0]); - e.setPitch(blockRotations[1]); - lastBlockYaw = MathHelper.wrapAngleTo180_float(blockRotations[0]); - - //Utils.print("" + MathHelper.wrapAngleTo180_float(blockRotations[0])); - - - - - - - if (rotation.getInput() == 2 && !ModuleManager.tower.isVerticalTowering()) { - 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 { - 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; - } - } - e.setYaw(offsetRotation()); - if (main >= 0) { - if (flipRotation) { - e.setYaw(offsetRotation() + rotOffset * 2); - //Utils.print("1 "); - } - } else if (main <= -0) { - if (flipRotation) { - e.setYaw(offsetRotation() - rotOffset * 2); - //Utils.print("2 "); - } - } - double minFlip = (!Utils.scaffoldDiagonal(false)) ? 6 : 14; - double minEdge = (!Utils.scaffoldDiagonal(false)) ? 0 : 10; - if (firstStroke > 0 && (System.currentTimeMillis() - firstStroke) > 200) { - if (!didFlip) { - if ((main >= 0 && rawOffset >= minEdge || main <= -0 && rawOffset <= -minEdge)) { - didFlip = true; - flipRotation = true; - } else { - didFlip = true; - flipRotation = false; - } - } else if ((main >= 0 && rawOffset >= minFlip || main >= 0 && rawOffset <= -minFlip || main <= -0 && rawOffset <= -minFlip || main <= -0 && rawOffset >= minFlip)) { - didFlip = false; - } - } - - 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 (e.getPitch() > 89) { - e.setPitch(89); - } - lastYaw = MathHelper.wrapAngleTo180_float(e.getYaw()); - lastPitch = e.getPitch(); - if (lastPlaceTime > 0 && (System.currentTimeMillis() - lastPlaceTime) > rotationTimeout) blockRotations = null; + blockYaw = blockRotations[0]; + pitch = blockRotations[1]; } else { - lastBlockYaw = lastYaw; - if (rotation.getInput() == 2) { - /*if (main >= 0) { - mainOffset2 = 25; + blockYaw = 0; + pitch = 82F; + } + float side = MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw); + float offset = 137.625F; + float minOffset = (!Utils.scaffoldDiagonal(false)) ? 30 : 0; + float yawBackwards = MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(); + float yawOffset = MathHelper.wrapAngleTo180_float(yawBackwards - blockYaw); + + if (!Utils.isMoving() || Utils.getHorizontalSpeed() == 0.0D) { + e.setRotations(yaw, pitch); + break; + } + + float motionYaw = getMotionYaw(); + + float lastYaw = Utils.getLastReportedYaw(); + float newYaw = motionYaw - offset * Math.signum( + MathHelper.wrapAngleTo180_float(motionYaw - yaw) + ); + yaw = applyGcd( + lastYaw + MathHelper.wrapAngleTo180_float(newYaw - lastYaw) + ); + + double minSwitch = (!Utils.scaffoldDiagonal(false)) ? 0 : 13; + if (side >= 0) { + if (yawOffset <= -minSwitch) { + set2 = false; + } + else if (yawOffset >= 0) { + if (yawOffset >= minSwitch) { + set2 = true; } - else if (main <= -0) { - mainOffset2 = -25; - }*/ - e.setYaw(offsetRotation()); } - - - - - - else { - e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw()); + if (set2) { + if (yawOffset <= -0) yawOffset = -0; + if (yawOffset >= minOffset) yawOffset = minOffset; + e.setRotations((yaw + offset * 2) - yawOffset, pitch); + break; + } + } else if (side <= -0) { + if (yawOffset >= minSwitch) { + set2 = false; + } + else if (yawOffset <= 0) { + if (yawOffset <= -minSwitch) { + set2 = true; + } + } + if (set2) { + if (yawOffset >= 0) yawOffset = 0; + if (yawOffset <= -minOffset) yawOffset = -minOffset; + e.setRotations((yaw - offset * 2) - yawOffset, pitch); + break; } - e.setPitch(getPitch); } - if (rotation.getInput() == 1) { - e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw()); + + if (side >= 0) { + if (yawOffset >= 0) yawOffset = 0; + if (yawOffset <= -minOffset) yawOffset = -minOffset; + } else if (side <= -0) { + if (yawOffset <= -0) yawOffset = -0; + if (yawOffset >= minOffset) yawOffset = minOffset; } + e.setRotations(yaw - yawOffset, pitch); + break; + + case 3: + if (blockRotations != null) { + e.setRotations(blockRotations[0], blockRotations[1]); + } + else { + e.setRotations(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw(), 82); + } + break; + } + + + + //jump facing forward + if (rotateForward && jumpFacingForward.isToggled()) { + if (rotation.getInput() > 0) { + if (!rotatingForward) { + rotationDelay = 2; + rotatingForward = true; + } + e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw() - 180 - (float) Utils.randomizeDouble(-5, 5)); + e.setPitch(10 - (float) Utils.randomizeDouble(1, 5)); } } else { - if (rotation.getInput() > 0) { - e.setYaw(MathHelper.wrapAngleTo180_float(mc.thePlayer.rotationYaw) - hardcodedYaw() - 180 - (float) Utils.randomizeDouble(-5, 5)); - e.setPitch(10 - (float) Utils.randomizeDouble(1, 5)); - } - if (!rotatingForward) { - rotationDelay = 2; - rotatingForward = true; - } + rotatingForward = false; } + + if (ModuleManager.tower.isVerticalTowering()) { + if (blockRotations != null) { + e.setYaw(blockRotations[0]); + } + e.setPitch(ModuleManager.tower.pitch); + } + + //pitch fix + if (e.getPitch() >= 89.9F) { + e.setPitch(89.9F); + } + lastYaw = MathHelper.wrapAngleTo180_float(e.getYaw()); + lastPitch = e.getPitch(); + if (lastPlaceTime > 0 && (System.currentTimeMillis() - lastPlaceTime) > rotationTimeout) blockRotations = null; if (rotationDelay > 0) --rotationDelay; } - private float yaw; - - private float offsetRotation() { - if (!Utils.isMoving() || Utils.getHorizontalSpeed() == 0.0D) { - return yaw; - } - - float newYaw = getMotionYaw() - rotOffset * Math.signum( - MathHelper.wrapAngleTo180_float(getMotionYaw() - yaw) - ); - yaw = applyGcd( - lastBlockYaw + MathHelper.wrapAngleTo180_float(newYaw - lastBlockYaw) - ); - return yaw; - } - @SubscribeEvent public void onPreUpdate(PreUpdateEvent e) { if (!isEnabled) { @@ -435,12 +413,16 @@ public class Scaffold extends Module { handleMotion(); } + + + + if (disabledModule) { - if (ModuleManager.tower.canTower() && (ModuleManager.tower.dCount == 0 || !Utils.isMoving()) || floatStarted) { + if (ModuleManager.tower.canTower() && (ModuleManager.tower.dCount == 0 || !Utils.isMoving()) || floatStarted && Utils.isMoving()) { dontDisable = true; } - if (dontDisable && ++disableTicks >= 2) { + if (dontDisable && ++disableTicks >= 3) { isEnabled = false; //Utils.print("Extra tick"); } @@ -474,7 +456,7 @@ public class Scaffold extends Module { blockRotations = null; startYPos = -1; fastScaffoldKeepY = firstKeepYPlace = rotateForward = rotatingForward = lowhop = floatStarted = floatJumped = floatWasEnabled = false; - keepYDelay = rotationDelay = keepYTicks = keepYPlaceTicks = 0; + rotationDelay = keepYTicks = scaffoldTicks = 0; startYPos = -1; lookVec = null; } @@ -612,6 +594,9 @@ public class Scaffold extends Module { private void placeBlock(int yOffset, int xOffset) { locateAndPlaceBlock(yOffset, xOffset); int input = (int) multiPlace.getInput(); + if (sprint.getInput() == 0 && mc.thePlayer.onGround && !ModuleManager.tower.canTower() && !usingFastScaffold()) { + return; + } if (input >= 1) { locateAndPlaceBlock(yOffset, xOffset); if (input >= 2) { @@ -823,7 +808,7 @@ public class Scaffold extends Module { } private void handleMotion() { - if (usingFastScaffold()) { + if (handleFastScaffolds() > 0 || ModuleManager.tower.canTower()) { return; } mc.thePlayer.motionX *= motion.getInput(); diff --git a/src/main/java/keystrokesmod/module/impl/player/Tower.java b/src/main/java/keystrokesmod/module/impl/player/Tower.java index 62a1703..901a4dc 100644 --- a/src/main/java/keystrokesmod/module/impl/player/Tower.java +++ b/src/main/java/keystrokesmod/module/impl/player/Tower.java @@ -35,6 +35,8 @@ public class Tower extends Module { private int cMotionTicks, placeTicks; public int dCount; + public float pitch; + //vertical tower private boolean aligning, aligned, placed; private int firstX; @@ -127,7 +129,7 @@ public class Tower extends Module { else if (setLowMotion) { ++cMotionTicks; if (cMotionTicks == 1) { - mc.thePlayer.motionY = 0.04f; + mc.thePlayer.motionY = 0.05F; } else if (cMotionTicks == 3) { cMotionTicks = 0; @@ -175,17 +177,14 @@ public class Tower extends Module { if (aligning && (int) mc.thePlayer.posX > firstX) { aligned = true; } - //e.setYaw(90F); - e.setPitch(85F); + pitch = 85F; } if (aligned) { if (placed) { - //e.setYaw(270F); - e.setPitch(89.9F); + pitch = 89.9F; } else { - //e.setYaw(90F); - e.setPitch(85F); + pitch = 85F; } placeExtraBlock = true; mc.thePlayer.motionX = 0; @@ -207,21 +206,21 @@ public class Tower extends Module { @SubscribeEvent public void onPostPlayerInput(PostPlayerInputEvent e) { - /*if (canTower() && Utils.keysDown() && towerMove.getInput() > 0) { + if (canTower() && Utils.keysDown() && towerMove.getInput() > 0) { mc.thePlayer.movementInput.jump = false; if (!firstJump) { if (!mc.thePlayer.onGround) { if (!startedTowerInAir) { - Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel()) - 0.04); + //Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel()) - 0.04); } startedTowerInAir = true; } else if (mc.thePlayer.onGround) { - Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); + //Utils.setSpeed(getTowerGroundSpeed(getSpeedLevel())); firstJump = true; } } - }*/ + } if (canTower() && !Utils.keysDown() && verticalTower.getInput() > 0) { mc.thePlayer.movementInput.jump = false; } diff --git a/src/main/java/keystrokesmod/module/impl/render/BedESP.java b/src/main/java/keystrokesmod/module/impl/render/BedESP.java index bca8c93..84ab5a5 100644 --- a/src/main/java/keystrokesmod/module/impl/render/BedESP.java +++ b/src/main/java/keystrokesmod/module/impl/render/BedESP.java @@ -4,10 +4,7 @@ import keystrokesmod.Raven; import keystrokesmod.module.Module; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.utility.BlockUtils; -import keystrokesmod.utility.RenderUtils; -import keystrokesmod.utility.Theme; -import keystrokesmod.utility.Utils; +import keystrokesmod.utility.*; import net.minecraft.block.BlockBed; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; @@ -17,12 +14,14 @@ import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraftforge.client.event.RenderWorldLastEvent; import net.minecraftforge.event.entity.EntityJoinWorldEvent; +import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.opengl.GL11; +import java.util.Collections; +import java.util.HashMap; import java.util.Iterator; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Map; public class BedESP extends Module { public SliderSetting theme; @@ -30,8 +29,9 @@ public class BedESP extends Module { private SliderSetting rate; private ButtonSetting firstBed; private ButtonSetting renderFullBlock; - private BlockPos[] bed = null; - private Set beds = ConcurrentHashMap.newKeySet(); + private BlockPos[] bed; + private Timer firstBedTimer; + private Map beds = Collections.synchronizedMap(new HashMap<>()); private long lastCheck = 0; public BedESP() { @@ -65,12 +65,12 @@ public class BedESP extends Module { return; } else { - for (BlockPos[] pos : beds) { + for (BlockPos[] pos : beds.keySet()) { if (BlockUtils.isSamePos(blockPos, pos[0])) { continue priorityLoop; } } - this.beds.add(new BlockPos[]{blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING))}); + this.beds.put(new BlockPos[] { blockPos, blockPos.offset((EnumFacing) getBlockState.getValue((IProperty) BlockBed.FACING)) }, null); } } } @@ -87,29 +87,52 @@ public class BedESP extends Module { } } - @SubscribeEvent + @SubscribeEvent(priority = EventPriority.HIGHEST) public void onRenderWorld(RenderWorldLastEvent e) { if (Utils.nullCheck()) { float blockHeight = getBlockHeight(); if (firstBed.isToggled() && this.bed != null) { - if (!(mc.theWorld.getBlockState(bed[0]).getBlock() instanceof BlockBed)) { - this.bed = null; - return; + float customAlpha = 0.25f; + if (!(mc.theWorld.getBlockState(this.bed[0]).getBlock() instanceof BlockBed)) { + if (firstBedTimer == null) { + (firstBedTimer = (new Timer(300))).start(); + } + int alpha = firstBedTimer == null ? 230 : 230 - firstBedTimer.getValueInt(0, 230, 1); + if (alpha <= 0) { + this.bed = null; + return; + } + customAlpha = alpha / 255.0f; } - renderBed(this.bed, blockHeight); + else { + firstBedTimer = null; + } + renderBed(this.bed, blockHeight, customAlpha); return; } - if (this.beds.isEmpty()) { - return; - } - Iterator iterator = this.beds.iterator(); - while (iterator.hasNext()) { - BlockPos[] blockPos = iterator.next(); - if (!(mc.theWorld.getBlockState(blockPos[0]).getBlock() instanceof BlockBed)) { - iterator.remove(); - continue; + synchronized (beds) { + Iterator> iterator = this.beds.entrySet().iterator(); + while (iterator.hasNext()) { + float customAlpha = 0.25f; + Map.Entry entry = iterator.next(); + BlockPos[] blockPos = entry.getKey(); + if (!(mc.theWorld.getBlockState(blockPos[0]).getBlock() instanceof BlockBed)) { + if (entry.getValue() == null) { + entry.setValue(new Timer(300)); + entry.getValue().start(); + } + int alpha = entry.getValue() == null ? 230 : 230 - entry.getValue().getValueInt(0, 230, 1); + if (alpha <= 0) { + iterator.remove(); + continue; + } + customAlpha = alpha / 255.0f; + } + else { + entry.setValue(null); + } + renderBed(blockPos, blockHeight, customAlpha); } - renderBed(blockPos, blockHeight); } } } @@ -119,7 +142,7 @@ public class BedESP extends Module { this.beds.clear(); } - private void renderBed(final BlockPos[] array, float height) { + private void renderBed(final BlockPos[] array, float height, float alpha) { final double n = array[0].getX() - mc.getRenderManager().viewerPosX; final double n2 = array[0].getY() - mc.getRenderManager().viewerPosY; final double n3 = array[0].getZ() - mc.getRenderManager().viewerPosZ; @@ -129,12 +152,12 @@ public class BedESP extends Module { GL11.glDisable(3553); GL11.glDisable(2929); GL11.glDepthMask(false); - final int e = Theme.getGradient((int) theme.getInput(), 0); - final float n4 = (e >> 24 & 0xFF) / 255.0f; - final float n5 = (e >> 16 & 0xFF) / 255.0f; - final float n6 = (e >> 8 & 0xFF) / 255.0f; - final float n7 = (e & 0xFF) / 255.0f; - GL11.glColor4d(n5, n6, n7, n4); + final int color = Theme.getGradient((int) theme.getInput(), 0); + final float a = (color >> 24 & 0xFF) / 255.0f; + final float r = (color >> 16 & 0xFF) / 255.0f; + final float g = (color >> 8 & 0xFF) / 255.0f; + final float b = (color & 0xFF) / 255.0f; + GL11.glColor4d(r, g, b, a); AxisAlignedBB axisAlignedBB; if (array[0].getX() != array[1].getX()) { if (array[0].getX() > array[1].getX()) { @@ -147,7 +170,7 @@ public class BedESP extends Module { } else { axisAlignedBB = new AxisAlignedBB(n, n2, n3, n + 1.0, n2 + height, n3 + 2.0); } - RenderUtils.drawBoundingBox(axisAlignedBB, n5, n6, n7); + RenderUtils.drawBoundingBox(axisAlignedBB, r, g, b, alpha); GL11.glEnable(3553); GL11.glEnable(2929); GL11.glDepthMask(true); diff --git a/src/main/java/keystrokesmod/utility/ModuleUtils.java b/src/main/java/keystrokesmod/utility/ModuleUtils.java index 68ff78a..ff9af88 100644 --- a/src/main/java/keystrokesmod/utility/ModuleUtils.java +++ b/src/main/java/keystrokesmod/utility/ModuleUtils.java @@ -97,12 +97,17 @@ public class ModuleUtils { @SubscribeEvent public void onPreMotion(PreMotionEvent e) { + int simpleY = (int) Math.round((e.posY % 1) * 10000); - inAirTicks = mc.thePlayer.onGround ? 0 : ++inAirTicks; + if (inAirTicks <= 20) { + inAirTicks = mc.thePlayer.onGround ? 0 : ++inAirTicks; + } + else { + inAirTicks = 19; + } // 7 tick needs to always finish the motion or itll lag back if (!ModuleManager.bhop.isEnabled() && ModuleManager.bhop.mode.getInput() == 3 && ModuleManager.bhop.didMove) { - int simpleY = (int) Math.round((e.posY % 1) * 10000); if (mc.thePlayer.hurtTime == 0) { switch (simpleY) { @@ -124,9 +129,9 @@ public class ModuleUtils { } if (ModuleManager.bhop.setRotation) { - if (!ModuleManager.killAura.isTargeting && !Utils.noSlowingBackWithBow() && !ModuleManager.scaffold.isEnabled && !mc.thePlayer.isCollidedHorizontally) { - float yaw = mc.thePlayer.rotationYaw; - e.setYaw(yaw - 55); + if (!ModuleManager.killAura.isTargeting && !ModuleManager.scaffold.isEnabled) { + float yaw = mc.thePlayer.rotationYaw - 55; + e.setYaw(yaw); } if (mc.thePlayer.onGround) { ModuleManager.bhop.setRotation = false; diff --git a/src/main/java/keystrokesmod/utility/Utils.java b/src/main/java/keystrokesmod/utility/Utils.java index c64f4f5..01170e2 100644 --- a/src/main/java/keystrokesmod/utility/Utils.java +++ b/src/main/java/keystrokesmod/utility/Utils.java @@ -4,6 +4,7 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.gson.JsonObject; import keystrokesmod.Raven; +import keystrokesmod.mixin.impl.accessor.IAccessorEntityPlayerSP; import keystrokesmod.mixin.impl.accessor.IAccessorGuiIngame; import keystrokesmod.mixin.impl.accessor.IAccessorItemFood; import keystrokesmod.mixin.impl.accessor.IAccessorMinecraft; @@ -942,6 +943,10 @@ public class Utils { return mc.theWorld.getCollidingBoundingBoxes(entity, entity.getEntityBoundingBox().offset(entity.motionX / 3.0D, -1.0D, entity.motionZ / 3.0D)).isEmpty(); } + public static float getLastReportedYaw() { + return ((IAccessorEntityPlayerSP) mc.thePlayer).getLastReportedYaw(); + } + public static boolean lookingAtBlock() { return mc.objectMouseOver != null && mc.objectMouseOver.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && mc.objectMouseOver.getBlockPos() != null; }