diff --git a/src/main/java/keystrokesmod/mixins/impl/entity/EntityLivingBaseAccessor.java b/src/main/java/keystrokesmod/mixins/impl/entity/EntityLivingBaseAccessor.java index 314b4eb5f..ba9f9a2b7 100644 --- a/src/main/java/keystrokesmod/mixins/impl/entity/EntityLivingBaseAccessor.java +++ b/src/main/java/keystrokesmod/mixins/impl/entity/EntityLivingBaseAccessor.java @@ -1,9 +1,12 @@ package keystrokesmod.mixins.impl.entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.potion.PotionEffect; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import java.util.Map; + @Mixin(EntityLivingBase.class) public interface EntityLivingBaseAccessor { @@ -24,4 +27,13 @@ public interface EntityLivingBaseAccessor { @Accessor("newPosRotationIncrements") int getNewPosRotationIncrements(); + + @Accessor("activePotionsMap") + Map getActivePotionsMap(); + + @Accessor("activePotionsMap") + void setActivePotionsMap(Map map); + + @Accessor("dead") + boolean isDead(); } diff --git a/src/main/java/keystrokesmod/mixins/impl/entity/EntityPlayerAccessor.java b/src/main/java/keystrokesmod/mixins/impl/entity/EntityPlayerAccessor.java new file mode 100644 index 000000000..98614f697 --- /dev/null +++ b/src/main/java/keystrokesmod/mixins/impl/entity/EntityPlayerAccessor.java @@ -0,0 +1,13 @@ +package keystrokesmod.mixins.impl.entity; + + +import net.minecraft.entity.player.EntityPlayer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(EntityPlayer.class) +public interface EntityPlayerAccessor { + + @Accessor("itemInUseCount") + void setItemInUseCount(int count); +} diff --git a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java index f84b02141..4272ceae7 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/KillAura.java +++ b/src/main/java/keystrokesmod/module/impl/combat/KillAura.java @@ -64,6 +64,7 @@ public class KillAura extends IAutoClicker { private final ModeSetting rotationMode; private final ModeSetting moveFixMode; private final ModeSetting rayCastMode; + private final SliderSetting rotationSpeed; private final ButtonSetting nearest; private final SliderSetting nearestAccuracy; private final ButtonSetting lazy; @@ -77,7 +78,14 @@ public class KillAura extends IAutoClicker { private final SliderSetting noiseDelay; private final ButtonSetting delayAim; private final SliderSetting delayAimAmount; - private final SliderSetting rotationSpeed; + private final ButtonSetting scale; + private final SliderSetting scaleHorizontal; + private final SliderSetting scaleVertical; + private final SliderSetting scaleChance; + private final ButtonSetting offset; + private final SliderSetting offsetHorizontal; + private final SliderSetting offsetVertical; + private final ModeSetting offsetTiming; private final ModeSetting sortMode; private final SliderSetting switchDelay; @@ -157,11 +165,19 @@ public KillAura() { this.registerSetting(constantOnlyIfNotMoving = new ButtonSetting("Constant only if not moving", false, doRotation.extend(constant::isToggled))); this.registerSetting(noise = new ButtonSetting("Noise", false, doRotation)); this.registerSetting(noiseHorizontal = new SliderSetting("Noise horizontal", 0.35, 0.01, 1, 0.01, doRotation.extend(noise::isToggled))); - this.registerSetting(noiseVertical = new SliderSetting("Noise vertical", 0.5, 0.01, 1, 0.01, doRotation.extend(noise::isToggled))); + this.registerSetting(noiseVertical = new SliderSetting("Noise vertical", 0.5, 0.01, 1.5, 0.01, doRotation.extend(noise::isToggled))); this.registerSetting(noiseAimSpeed = new SliderSetting("Noise aim speed", 0.35, 0.01, 1, 0.01, doRotation.extend(noise::isToggled))); this.registerSetting(noiseDelay = new SliderSetting("Noise delay", 100, 50, 500, 10, doRotation.extend(noise::isToggled))); this.registerSetting(delayAim = new ButtonSetting("Delay aim", false, doRotation)); - this.registerSetting(delayAimAmount = new SliderSetting("Delay aim amount", 5, 5, 100, 1, doRotation.extend(delayAim::isToggled))); + this.registerSetting(delayAimAmount = new SliderSetting("Delay aim amount", 5, 5, 150, 1, doRotation.extend(delayAim::isToggled))); + this.registerSetting(scale = new ButtonSetting("Scale", false, doRotation)); + this.registerSetting(scaleHorizontal = new SliderSetting("Scale horizontal", 1, 0.5, 1.5, 0.1, doRotation.extend(scale::isToggled))); + this.registerSetting(scaleVertical = new SliderSetting("Scale vertical", 1, 0.5, 1.5, 0.1, doRotation.extend(scale::isToggled))); + this.registerSetting(scaleChance = new SliderSetting("Scale chance", 100, 0, 100, 1, "%", doRotation.extend(scale::isToggled))); + this.registerSetting(offset = new ButtonSetting("Offset", false, doRotation)); + this.registerSetting(offsetHorizontal = new SliderSetting("Offset horizontal", 0, -1, 1, 0.05, doRotation.extend(offset::isToggled))); + this.registerSetting(offsetVertical = new SliderSetting("Offset vertical", -0.5, -1.5, 1, 0.05, doRotation.extend(offset::isToggled))); + this.registerSetting(offsetTiming = new ModeSetting("Offset timing", new String[]{"Pre", "Post"}, 0, doRotation.extend(offset::isToggled))); this.registerSetting(new DescriptionSetting("Targets")); String[] sortModes = new String[]{"Health", "HurtTime", "Distance", "Yaw"}; this.registerSetting(sortMode = new ModeSetting("Sort mode", sortModes, 0)); @@ -213,6 +229,12 @@ private float[] getRotations() { new Pair<>((float) noiseHorizontal.getInput(), (float) noiseVertical.getInput()), noiseAimSpeed.getInput(), (long) noiseDelay.getInput()); aimSimulator.setDelay(delayAim.isToggled(), (int) delayAimAmount.getInput()); + if (scale.isToggled() && Math.random() > scaleChance.getInput()) { + aimSimulator.setScale(scale.isToggled(), scaleHorizontal.getInput(), scaleVertical.getInput()); + } else { + aimSimulator.setScale(scale.isToggled(), 1, 1); + } + aimSimulator.setOffset(offset.isToggled(), offsetHorizontal.getInput(), offsetVertical.getInput(), offsetTiming.getInput() == 0); if (constant.isToggled() && !noAimToEntity() && !(constantOnlyIfNotMoving.isToggled() && (MoveUtil.isMoving() || MoveUtil.isMoving(target)))) return rotations; diff --git a/src/main/java/keystrokesmod/module/impl/combat/autoclicker/DragClickAutoClicker.java b/src/main/java/keystrokesmod/module/impl/combat/autoclicker/DragClickAutoClicker.java index b3d177d92..ca7911bbc 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/autoclicker/DragClickAutoClicker.java +++ b/src/main/java/keystrokesmod/module/impl/combat/autoclicker/DragClickAutoClicker.java @@ -35,7 +35,7 @@ public void guiUpdate() { @SubscribeEvent public void onPreMotion(PreMotionEvent event) { - if (!always && left ? !Mouse.isButtonDown(0) : !Mouse.isButtonDown(1)) + if (!always && (left ? !Mouse.isButtonDown(0) : !Mouse.isButtonDown(1))) return; if (nextLength < 0) { diff --git a/src/main/java/keystrokesmod/module/impl/combat/autoclicker/RecordAutoClicker.java b/src/main/java/keystrokesmod/module/impl/combat/autoclicker/RecordAutoClicker.java index f6b02ebab..555f45b87 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/autoclicker/RecordAutoClicker.java +++ b/src/main/java/keystrokesmod/module/impl/combat/autoclicker/RecordAutoClicker.java @@ -19,7 +19,7 @@ public RecordAutoClicker(String name, @NotNull IAutoClicker parent, boolean left @SubscribeEvent public void onPreMotion(PreMotionEvent event) { - if (!always && left ? !Mouse.isButtonDown(0) : !Mouse.isButtonDown(1)) + if (!always && (left ? !Mouse.isButtonDown(0) : !Mouse.isButtonDown(1))) return; if (System.currentTimeMillis() < RecordClick.getNextClickTime()) return; diff --git a/src/main/java/keystrokesmod/module/impl/combat/velocity/HypixelVelocity.java b/src/main/java/keystrokesmod/module/impl/combat/velocity/HypixelVelocity.java index 1717c3e46..ce79987f1 100644 --- a/src/main/java/keystrokesmod/module/impl/combat/velocity/HypixelVelocity.java +++ b/src/main/java/keystrokesmod/module/impl/combat/velocity/HypixelVelocity.java @@ -24,6 +24,7 @@ public class HypixelVelocity extends SubMode { private final SliderSetting chance; private final ButtonSetting cancelAir; private final ButtonSetting damageBoost; + private final ButtonSetting damageBoostOnlyOnGround; private final ButtonSetting onlyFirstHit; private final SliderSetting resetTime; @@ -38,6 +39,7 @@ public HypixelVelocity(String name, @NotNull Velocity parent) { this.registerSetting(chance = new SliderSetting("Chance", 100, 0, 100, 1, "%")); this.registerSetting(cancelAir = new ButtonSetting("Cancel air", false)); this.registerSetting(damageBoost = new ButtonSetting("Damage boost", false)); + this.registerSetting(damageBoostOnlyOnGround = new ButtonSetting("Damage boost only on ground", false, damageBoost::isToggled)); this.registerSetting(onlyFirstHit = new ButtonSetting("Only first hit", false)); this.registerSetting(resetTime = new SliderSetting("Reset time", 5000, 500, 10000, 500, "ms", onlyFirstHit::isToggled)); } @@ -71,7 +73,7 @@ public void onPreVelocity(@NotNull PreVelocityEvent event) { mc.thePlayer.motionY = choose(mc.thePlayer.motionY, motionY); - if (damageBoost.isToggled()) { + if (damageBoost.isToggled() && !(!mc.thePlayer.onGround && damageBoostOnlyOnGround.isToggled())) { MoveUtil.moveFlying(0.2); } diff --git a/src/main/java/keystrokesmod/module/impl/exploit/disabler/hypixel/HypixelMotionDisabler.java b/src/main/java/keystrokesmod/module/impl/exploit/disabler/hypixel/HypixelMotionDisabler.java index f5fe145bb..17f5f2ac4 100644 --- a/src/main/java/keystrokesmod/module/impl/exploit/disabler/hypixel/HypixelMotionDisabler.java +++ b/src/main/java/keystrokesmod/module/impl/exploit/disabler/hypixel/HypixelMotionDisabler.java @@ -95,6 +95,7 @@ public void onUpdate() { @Override public void onDisable() { isFinished = false; + offGroundTicks = 0; ProgressManager.remove(progress); } diff --git a/src/main/java/keystrokesmod/module/impl/movement/fly/HypixelTestFly.java b/src/main/java/keystrokesmod/module/impl/movement/fly/HypixelTestFly.java index c417be81a..a8ba4cf29 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/fly/HypixelTestFly.java +++ b/src/main/java/keystrokesmod/module/impl/movement/fly/HypixelTestFly.java @@ -25,7 +25,7 @@ public class HypixelTestFly extends SubMode { public HypixelTestFly(String name, @NotNull Fly parent) { super(name, parent); - this.registerSetting(speed = new SliderSetting("Speed", 1, 0.1, 2, 0.01)); + this.registerSetting(speed = new SliderSetting("Speed", 0.1, 0.01, 0.5, 0.01)); this.registerSetting(packet = new ButtonSetting("Packet", false)); } @@ -41,6 +41,7 @@ public void onPreMotion(PreMotionEvent event) { PacketUtils.sendPacket(new C03PacketPlayer(true)); event.setPosZ(event.getPosZ() + Utils.randomizeDouble(0.09, 0.12)); // 0.095 } + event.setPosY(event.getPosY() + speed.getInput()); mc.thePlayer.motionY = 0.0; MoveUtil.strafe(MoveUtil.isMoving() && active ? speed.getInput() / 10 : 0); diff --git a/src/main/java/keystrokesmod/module/impl/movement/longjump/HypixelBowLongJump.java b/src/main/java/keystrokesmod/module/impl/movement/longjump/HypixelBowLongJump.java index e85e86f0e..ff8d4f16e 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/longjump/HypixelBowLongJump.java +++ b/src/main/java/keystrokesmod/module/impl/movement/longjump/HypixelBowLongJump.java @@ -34,7 +34,7 @@ public class HypixelBowLongJump extends SubMode { public HypixelBowLongJump(String name, @NotNull LongJump parent) { super(name, parent); - this.registerSetting(speed = new SliderSetting("Speed", 1, 0.5, 1.5, 0.1)); + this.registerSetting(speed = new SliderSetting("Speed", 1, 0, 1.5, 0.1)); this.registerSetting(autoDisable = new ButtonSetting("Auto disable", true)); } @@ -100,7 +100,8 @@ public void onPrePlayerInput(PrePlayerInputEvent event) { } break; case BOOST: - MoveUtil.strafe(speed.getInput()); + if (speed.getInput() > 0) + MoveUtil.strafe(speed.getInput()); state = State.NONE; break; case NONE: diff --git a/src/main/java/keystrokesmod/module/impl/movement/speed/hypixel/GroundStrafeSpeed.java b/src/main/java/keystrokesmod/module/impl/movement/speed/hypixel/GroundStrafeSpeed.java index bc4943b7d..1bb0143c4 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/speed/hypixel/GroundStrafeSpeed.java +++ b/src/main/java/keystrokesmod/module/impl/movement/speed/hypixel/GroundStrafeSpeed.java @@ -18,7 +18,7 @@ public void onPrePlayerInput(PrePlayerInputEvent event) { if (parent.parent.noAction()) return; if (!Utils.jumpDown() && Utils.isMoving() && mc.currentScreen == null && mc.thePlayer.onGround) { - MoveUtil.strafe(MoveUtil.getAllowedHorizontalDistance()); + MoveUtil.strafe(MoveUtil.getAllowedHorizontalDistance() - Math.random() / 100f); mc.thePlayer.jump(); } } diff --git a/src/main/java/keystrokesmod/module/impl/movement/step/HypixelStep.java b/src/main/java/keystrokesmod/module/impl/movement/step/HypixelStep.java index e3375010e..639958753 100644 --- a/src/main/java/keystrokesmod/module/impl/movement/step/HypixelStep.java +++ b/src/main/java/keystrokesmod/module/impl/movement/step/HypixelStep.java @@ -70,9 +70,6 @@ public void onMove(MoveEvent event) { event.setY(mc.thePlayer.motionY = 0.4198479950428009); MoveUtil.strafe(speed - randomAmount()); break; - case 1: - event.setY(Math.floor(mc.thePlayer.posY + 1.0) - mc.thePlayer.posY); - break; case 5: if (mc.thePlayer.isCollidedHorizontally || !BlockUtils.blockRelativeToPlayer(0, -1, 0).isFullCube()) return; diff --git a/src/main/java/keystrokesmod/module/impl/other/Anticheat.java b/src/main/java/keystrokesmod/module/impl/other/Anticheat.java index 9b9a4d647..1b9a1c280 100644 --- a/src/main/java/keystrokesmod/module/impl/other/Anticheat.java +++ b/src/main/java/keystrokesmod/module/impl/other/Anticheat.java @@ -10,7 +10,6 @@ import keystrokesmod.module.setting.impl.SliderSetting; import lombok.Getter; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.jetbrains.annotations.NotNull; @@ -49,6 +48,8 @@ public class Anticheat extends Module { private static ButtonSetting movementCheck; @Getter private static ButtonSetting scaffoldingCheck; + @Getter + private static ButtonSetting simulationCheck; private PlayerManager manager = new PlayerManager(); public Anticheat() { @@ -64,18 +65,15 @@ public Anticheat() { this.registerSetting(shouldPing = new ButtonSetting("Should ping", true)); this.registerSetting(pingSound = new ModeSetting("Ping sound", new String[]{"Note", "Augustus"}, 0, shouldPing::isToggled)); this.registerSetting(autoReport = new ModeSetting("Auto report", new String[]{"None", "/wdr", "/report"}, 0)); - this.registerSetting(experimentalMode = new ButtonSetting("Experimental mode", true)); + this.registerSetting(experimentalMode = new ButtonSetting("Experimental mode", false)); this.registerSetting(aimCheck = new ButtonSetting("Aim checks", true)); this.registerSetting(combatCheck = new ButtonSetting("Combat checks", true)); this.registerSetting(movementCheck = new ButtonSetting("Movement checks", true)); this.registerSetting(scaffoldingCheck = new ButtonSetting("Scaffolding checks", true)); + this.registerSetting(simulationCheck = new ButtonSetting("Simulation checks", false)); } public void onUpdate() { - if (mc.isSingleplayer()) { - return; - } - manager.update(Raven.mc); } @@ -87,8 +85,11 @@ public void onEntityJoin(@NotNull WorldChangeEvent e) { @Override public void onDisable() throws Throwable { - manager.dataMap.values().forEach(trPlayer -> trPlayer.manager.onCustomAction(MinecraftForge.EVENT_BUS::unregister)); - manager = null; + //noinspection SynchronizeOnNonFinalField + synchronized (manager) { + manager.dataMap.values().forEach(trPlayer -> trPlayer.manager.onCustomAction(MinecraftForge.EVENT_BUS::unregister)); + manager = null; + } } @Override diff --git a/src/main/java/keystrokesmod/module/impl/other/anticheats/Check.java b/src/main/java/keystrokesmod/module/impl/other/anticheats/Check.java index fbc157ce8..43249fa9a 100644 --- a/src/main/java/keystrokesmod/module/impl/other/anticheats/Check.java +++ b/src/main/java/keystrokesmod/module/impl/other/anticheats/Check.java @@ -6,6 +6,8 @@ import net.minecraftforge.common.MinecraftForge; import org.jetbrains.annotations.NotNull; +import java.lang.ref.WeakReference; + public abstract class Check { protected final @NotNull TRPlayer player; public String checkName; @@ -18,7 +20,7 @@ public Check(String checkName, @NotNull TRPlayer player) { } @Override - protected void finalize() throws Throwable { + protected void finalize() { MinecraftForge.EVENT_BUS.unregister(this); } diff --git a/src/main/java/keystrokesmod/module/impl/other/anticheats/CheckManager.java b/src/main/java/keystrokesmod/module/impl/other/anticheats/CheckManager.java index b78964981..2c7c80820 100644 --- a/src/main/java/keystrokesmod/module/impl/other/anticheats/CheckManager.java +++ b/src/main/java/keystrokesmod/module/impl/other/anticheats/CheckManager.java @@ -1,5 +1,6 @@ package keystrokesmod.module.impl.other.anticheats; +import keystrokesmod.module.impl.other.anticheats.checks.simulation.Simulation; import keystrokesmod.module.impl.other.anticheats.utils.world.EntityUtils; import keystrokesmod.module.impl.other.anticheats.checks.aim.*; import keystrokesmod.module.impl.other.anticheats.checks.combat.*; @@ -51,6 +52,7 @@ public CheckManager(@NotNull Map, Check> preChecks, normal.put(ScaffoldB.class, new ScaffoldB(player)); normal.put(NoFallA.class, new NoFallA(player)); normal.put(AutoClickerA.class, new AutoClickerA(player)); +// post.put(Simulation.class, new Simulation(player)); buggy return new CheckManager(pre, normal, post, player); } @@ -89,7 +91,6 @@ public void onJump() { } public void onCustomAction(Consumer action) { - if (player == null) return; for (Check check : preChecks.values()) action.accept(check); for (Check check : normalChecks.values()) action.accept(check); for (Check check : postChecks.values()) action.accept(check); diff --git a/src/main/java/keystrokesmod/module/impl/other/anticheats/TRPlayer.java b/src/main/java/keystrokesmod/module/impl/other/anticheats/TRPlayer.java index 047fa6a77..be48b767c 100644 --- a/src/main/java/keystrokesmod/module/impl/other/anticheats/TRPlayer.java +++ b/src/main/java/keystrokesmod/module/impl/other/anticheats/TRPlayer.java @@ -63,7 +63,7 @@ public class TRPlayer { public PlayerData compatPlayerData = new PlayerData(); - public @NotNull ScheduledExecutorService timeTask = Executors.newScheduledThreadPool(4); + public @NotNull ScheduledExecutorService timeTask = Executors.newScheduledThreadPool(1); @Contract("_ -> new") public static @NotNull TRPlayer create(@NotNull AbstractClientPlayer player) { return new TRPlayer(player, false); diff --git a/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoBlockA.java b/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoBlockA.java index 51983cd79..803db5158 100644 --- a/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoBlockA.java +++ b/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoBlockA.java @@ -5,11 +5,18 @@ import keystrokesmod.module.impl.other.anticheats.Check; import keystrokesmod.module.impl.other.anticheats.TRPlayer; import keystrokesmod.module.impl.other.anticheats.config.AdvancedConfig; +import keystrokesmod.utility.RotationUtils; +import keystrokesmod.utility.Utils; import net.minecraft.network.play.server.S0BPacketAnimation; +import net.minecraft.network.play.server.S14PacketEntity; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.jetbrains.annotations.NotNull; +import static keystrokesmod.Raven.mc; + public class AutoBlockA extends Check { + private boolean needToCheck = false; + public AutoBlockA(@NotNull TRPlayer player) { super("AutoBlockA", player); } @@ -18,9 +25,20 @@ public AutoBlockA(@NotNull TRPlayer player) { public void onReceivePacket(@NotNull ReceivePacketEvent event) { if (event.getPacket() instanceof S0BPacketAnimation) { if (((S0BPacketAnimation) event.getPacket()).getEntityID() == player.fabricPlayer.getEntityId()) { - if (player.fabricPlayer.isBlocking()) - flag("Impossible hit."); + if (RotationUtils.rayCast( + Utils.getEyePos(player.fabricPlayer).toVec3(), 3, + player.fabricPlayer.rotationYaw, player.fabricPlayer.rotationPitch) == null + ) { + needToCheck = false; + return; + } + + needToCheck = true; } + } else if (event.getPacket() instanceof S14PacketEntity) { + if (((S14PacketEntity) event.getPacket()).getEntity(mc.theWorld) == player.fabricPlayer + && player.fabricPlayer.isBlocking() && needToCheck) + flag("Impossible hit."); } } diff --git a/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoClickerA.java b/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoClickerA.java index 53fcfcbe1..bca0418a3 100644 --- a/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoClickerA.java +++ b/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/combat/AutoClickerA.java @@ -27,10 +27,11 @@ public void onReceivePacket(@NotNull ReceivePacketEvent event) { private void onClick() { final long time = System.currentTimeMillis(); - if (clicks.size() == 15) { + if (clicks.size() >= 15) { final long lastClick = clicks.dequeueLong(); - if (time - lastClick < 1000) { - flag(String.format("High cps: %.1f", (time - lastClick) / 1000.0 * 15)); + final double lastCPS = (time - lastClick) / 1000.0 * 15; + if (time - lastClick < 1000 && lastCPS >= 15) { + flag(String.format("High cps: %.1f", lastCPS)); clicks.clear(); } } diff --git a/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/simulation/Simulation.java b/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/simulation/Simulation.java index 5d852aa97..41133018d 100644 --- a/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/simulation/Simulation.java +++ b/src/main/java/keystrokesmod/module/impl/other/anticheats/checks/simulation/Simulation.java @@ -1,12 +1,108 @@ package keystrokesmod.module.impl.other.anticheats.checks.simulation; +import it.unimi.dsi.fastutil.objects.ObjectArraySet; +import keystrokesmod.module.impl.other.Anticheat; import keystrokesmod.module.impl.other.anticheats.Check; import keystrokesmod.module.impl.other.anticheats.TRPlayer; +import keystrokesmod.module.impl.other.anticheats.utils.phys.PredictEngine; +import keystrokesmod.script.classes.Vec3; +import net.minecraft.util.MovementInput; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; +import java.util.Queue; +import java.util.Set; +import java.util.concurrent.ConcurrentLinkedQueue; + public class Simulation extends Check { - public Simulation(String checkName, @NotNull TRPlayer player) { - super(checkName, player); + public static final Set MOVEMENTS = new ObjectArraySet<>(); + public static final boolean[] BOOLEANS = {true, false}; + + static { + for (float forward = -1; forward <= 1; forward++) { + for (float strafe = -1; strafe <= 1; strafe++) { + for (boolean jump : BOOLEANS) { + for (boolean sneak: BOOLEANS) { + MovementInput input = new MovementInput(); + input.moveForward = forward; + input.moveStrafe = strafe; + input.jump = jump; + input.sneak = sneak; + + if (input.sneak) { + input.moveStrafe = (float)((double) input.moveStrafe * 0.3); + input.moveForward = (float)((double) input.moveForward * 0.3); + } + + MOVEMENTS.add(input); + } + } + } + } + } + + private final PredictEngine engine; + private final Queue nextPosition = new ConcurrentLinkedQueue<>(); + + public Simulation(@NotNull TRPlayer player) { + super("Simulation", player); + this.engine = new PredictEngine(player); + } + + @SubscribeEvent + public void onClientTick(TickEvent.ClientTickEvent event) { + try { + if (!nextPosition.isEmpty()) { + Vec3 nearestVec = nextPosition.poll(); + double nearestDist = nearestVec.distanceTo(player.fabricPlayer); + + while (!nextPosition.isEmpty()) { + final Vec3 curVec = nextPosition.poll(); + final double curDist = curVec.distanceTo(player.fabricPlayer); + + if (curDist < nearestDist) { + nearestVec = curVec; + nearestDist = curDist; + } + } + + if (nearestVec.distanceTo(player.fabricPlayer) > Anticheat.getThreshold().getInput()) { + flag(String.format( + "x:%.4f y:%.4f z:%.4f", + player.fabricPlayer.posX - nearestVec.x, + player.fabricPlayer.posY - nearestVec.y, + player.fabricPlayer.posZ - nearestVec.z + )); + } else { + customMsg(String.format( + "x:%.4f y:%.4f z:%.4f", + player.fabricPlayer.posX - nearestVec.x, + player.fabricPlayer.posY - nearestVec.y, + player.fabricPlayer.posZ - nearestVec.z + )); + } + } + + // prediction + engine.sync(); + nextPosition.clear(); + for (MovementInput movement : MOVEMENTS) { + for (boolean sprint : BOOLEANS) { + PredictEngine predict = engine.clone(); + + predict.setMovementInput(movement); + predict.setSprinting(sprint); + + predict.onUpdate(); + + nextPosition.add(new Vec3(predict)); + } + } + } catch (Throwable e) { + customMsg(Arrays.toString(e.getStackTrace())); + } } @Override @@ -16,6 +112,6 @@ public int getAlertBuffer() { @Override public boolean isDisabled() { - return false; + return !Anticheat.getSimulationCheck().isToggled(); } } diff --git a/src/main/java/keystrokesmod/module/impl/other/anticheats/utils/phys/PredictEngine.java b/src/main/java/keystrokesmod/module/impl/other/anticheats/utils/phys/PredictEngine.java index 543d2f718..5b634f664 100644 --- a/src/main/java/keystrokesmod/module/impl/other/anticheats/utils/phys/PredictEngine.java +++ b/src/main/java/keystrokesmod/module/impl/other/anticheats/utils/phys/PredictEngine.java @@ -1,10 +1,18 @@ package keystrokesmod.module.impl.other.anticheats.utils.phys; import keystrokesmod.mixins.impl.entity.EntityLivingBaseAccessor; +import keystrokesmod.mixins.impl.entity.EntityPlayerAccessor; import keystrokesmod.module.impl.other.anticheats.TRPlayer; import lombok.Getter; import lombok.Setter; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.StatList; +import net.minecraft.util.BlockPos; +import net.minecraft.util.MathHelper; +import net.minecraft.util.MovementInput; +import net.minecraft.world.WorldSettings; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -12,20 +20,10 @@ @Setter public class PredictEngine extends EntityPlayer implements Cloneable { private final TRPlayer player; - double posX; - double posY; - double posZ; - double newPosX; - double newPosY; - double newPosZ; - float rotationYaw; - float rotationPitch; - double newRotationYaw; - double newRotationPitch; - int newPosRotationIncrements; - private double motionX; - private double motionY; - private double motionZ; + @Setter + private MovementInput movementInput; + @Setter + private boolean sprinting = false; @Contract(pure = true) public PredictEngine(@NotNull TRPlayer player) { @@ -34,7 +32,7 @@ public PredictEngine(@NotNull TRPlayer player) { sync(); } - private void sync() { + public void sync() { this.posX = player.fabricPlayer.posX; this.posY = player.fabricPlayer.posY; this.posZ = player.fabricPlayer.posZ; @@ -49,6 +47,227 @@ private void sync() { this.motionX = player.lastPos.x - player.currentPos.x; this.motionY = player.lastPos.y - player.currentPos.y; this.motionZ = player.lastPos.z - player.currentPos.z; + this.fallDistance = player.fabricPlayer.fallDistance; + this.dead = ((EntityLivingBaseAccessor) player.fabricPlayer).isDead(); + this.isDead = player.fabricPlayer.isDead; + this.inventory = player.fabricPlayer.inventory; + + this.setPosition(this.posX, this.posY, this.posZ); + this.setItemInUse(player.fabricPlayer.getItemInUse(), player.fabricPlayer.getItemInUseCount()); + ((EntityLivingBaseAccessor) this).setActivePotionsMap(((EntityLivingBaseAccessor) player.fabricPlayer).getActivePotionsMap()); + } + + @Override + protected void updatePotionEffects() { + } + + @Override + public void onUpdate() { + this.noClip = this.isSpectator(); + if (this.isSpectator()) { + this.onGround = false; + } + + if (this.getItemInUse() != null) { + ItemStack itemstack = this.inventory.getCurrentItem(); + if (itemstack == this.getItemInUse()) { + if (this.getItemInUseCount() <= 0) { + this.onItemUseFinish(); + } else { + this.getItemInUse().getItem().onUsingTick(this.getItemInUse(), this, this.getItemInUseCount()); + if (this.getItemInUseCount() <= 25 && this.getItemInUseCount() % 4 == 0) { + this.updateItemUse(itemstack, 5); + } + + ((EntityPlayerAccessor) this).setItemInUseCount(this.getItemInUseCount() - 1); + if (this.getItemInUseCount() == 0 && !this.worldObj.isRemote) { + this.onItemUseFinish(); + } + } + } else { + this.clearItemInUse(); + } + } + + if (this.xpCooldown > 0) { + --this.xpCooldown; + } + + ((EntityLivingBase) this).onUpdate(); + + if (this.isBurning() && this.capabilities.disableDamage) { + this.extinguish(); + } + + this.prevChasingPosX = this.chasingPosX; + this.prevChasingPosY = this.chasingPosY; + this.prevChasingPosZ = this.chasingPosZ; + double d5 = this.posX - this.chasingPosX; + double d0 = this.posY - this.chasingPosY; + double d1 = this.posZ - this.chasingPosZ; + double d2 = 10.0; + if (d5 > d2) { + this.prevChasingPosX = this.chasingPosX = this.posX; + } + + if (d1 > d2) { + this.prevChasingPosZ = this.chasingPosZ = this.posZ; + } + + if (d0 > d2) { + this.prevChasingPosY = this.chasingPosY = this.posY; + } + + if (d5 < -d2) { + this.prevChasingPosX = this.chasingPosX = this.posX; + } + + if (d1 < -d2) { + this.prevChasingPosZ = this.chasingPosZ = this.posZ; + } + + if (d0 < -d2) { + this.prevChasingPosY = this.chasingPosY = this.posY; + } + + this.chasingPosX += d5 * 0.25; + this.chasingPosZ += d1 * 0.25; + this.chasingPosY += d0 * 0.25; + if (this.ridingEntity == null) { + return; + } + + if (!this.worldObj.isRemote) { + this.foodStats.onUpdate(this); + this.triggerAchievement(StatList.minutesPlayedStat); + if (this.isEntityAlive()) { + this.triggerAchievement(StatList.timeSinceDeathStat); + } + } + + double d3 = MathHelper.clamp_double(this.posX, -2.9999999E7, 2.9999999E7); + double d4 = MathHelper.clamp_double(this.posZ, -2.9999999E7, 2.9999999E7); + if (d3 != this.posX || d4 != this.posZ) { + this.setPosition(d3, this.posY, d4); + } + } + + private boolean isHeadspaceFree(BlockPos p_isHeadspaceFree_1_, int p_isHeadspaceFree_2_) { + for(int y = 0; y < p_isHeadspaceFree_2_; ++y) { + if (!this.isOpenBlockSpace(p_isHeadspaceFree_1_.add(0, y, 0))) { + return false; + } + } + + return true; + } + + protected boolean pushOutOfBlocks(double p_pushOutOfBlocks_1_, double p_pushOutOfBlocks_3_, double p_pushOutOfBlocks_5_) { + if (!this.noClip) { + BlockPos blockpos = new BlockPos(p_pushOutOfBlocks_1_, p_pushOutOfBlocks_3_, p_pushOutOfBlocks_5_); + double d0 = p_pushOutOfBlocks_1_ - (double) blockpos.getX(); + double d1 = p_pushOutOfBlocks_5_ - (double) blockpos.getZ(); + int entHeight = Math.max((int) Math.ceil((double) this.height), 1); + boolean inTranslucentBlock = !this.isHeadspaceFree(blockpos, entHeight); + if (inTranslucentBlock) { + int i = -1; + double d2 = 9999.0; + if (this.isHeadspaceFree(blockpos.west(), entHeight) && d0 < d2) { + d2 = d0; + i = 0; + } + + if (this.isHeadspaceFree(blockpos.east(), entHeight) && 1.0 - d0 < d2) { + d2 = 1.0 - d0; + i = 1; + } + + if (this.isHeadspaceFree(blockpos.north(), entHeight) && d1 < d2) { + d2 = d1; + i = 4; + } + + if (this.isHeadspaceFree(blockpos.south(), entHeight) && 1.0 - d1 < d2) { + i = 5; + } + + float f = 0.1F; + if (i == 0) { + this.motionX = -f; + } + + if (i == 1) { + this.motionX = f; + } + + if (i == 4) { + this.motionZ = -f; + } + + if (i == 5) { + this.motionZ = f; + } + } + + } + return false; + } + + private boolean isOpenBlockSpace(BlockPos p_isOpenBlockSpace_1_) { + return !this.worldObj.getBlockState(p_isOpenBlockSpace_1_).getBlock().isNormalCube(); + } + + public void onLivingUpdate() { + boolean flag = this.movementInput.jump; + this.movementInput.updatePlayerMoveState(); + if (this.isUsingItem() && !this.isRiding()) { + MovementInput var10000 = this.movementInput; + var10000.moveStrafe *= 0.2F; + var10000.moveForward *= 0.2F; + } + + this.pushOutOfBlocks(this.posX - (double)this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ + (double)this.width * 0.35); + this.pushOutOfBlocks(this.posX - (double)this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ - (double)this.width * 0.35); + this.pushOutOfBlocks(this.posX + (double)this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ - (double)this.width * 0.35); + this.pushOutOfBlocks(this.posX + (double)this.width * 0.35, this.getEntityBoundingBox().minY + 0.5, this.posZ + (double)this.width * 0.35); + + if (this.capabilities.allowFlying) { + if (player.currentGameType == WorldSettings.GameType.SPECTATOR) { + if (!this.capabilities.isFlying) { + this.capabilities.isFlying = true; + this.sendPlayerAbilities(); + } + } else if (!flag && this.movementInput.jump) { + if (this.flyToggleTimer == 0) { + this.flyToggleTimer = 7; + } else { + this.capabilities.isFlying = !this.capabilities.isFlying; + this.sendPlayerAbilities(); + this.flyToggleTimer = 0; + } + } + } + + if (this.capabilities.isFlying) { + if (this.movementInput.sneak) { + this.motionY -= this.capabilities.getFlySpeed() * 3.0F; + } + + if (this.movementInput.jump) { + this.motionY += this.capabilities.getFlySpeed() * 3.0F; + } + } + + super.onLivingUpdate(); + if (this.onGround && this.capabilities.isFlying && player.currentGameType != WorldSettings.GameType.SPECTATOR) { + this.capabilities.isFlying = false; + } + + } + + @Override + public boolean isSprinting() { + return sprinting; } @Override diff --git a/src/main/java/keystrokesmod/module/impl/player/AutoHeal.java b/src/main/java/keystrokesmod/module/impl/player/AutoHeal.java index a06e1c60b..251bd2320 100644 --- a/src/main/java/keystrokesmod/module/impl/player/AutoHeal.java +++ b/src/main/java/keystrokesmod/module/impl/player/AutoHeal.java @@ -4,9 +4,7 @@ import keystrokesmod.module.impl.other.SlotHandler; import keystrokesmod.module.setting.impl.ButtonSetting; import keystrokesmod.module.setting.impl.DescriptionSetting; -import keystrokesmod.module.setting.impl.ModeSetting; import keystrokesmod.module.setting.impl.SliderSetting; -import keystrokesmod.module.setting.utils.ModeOnly; import keystrokesmod.utility.ContainerUtils; import keystrokesmod.utility.Utils; import net.minecraft.item.ItemSkull; @@ -16,20 +14,25 @@ import net.minecraftforge.fml.common.gameevent.TickEvent; public class AutoHeal extends Module { - private final ModeSetting item; - private final ButtonSetting autoThrow; + private final ButtonSetting autoDrop; private final SliderSetting minHealth; private final SliderSetting healDelay; private final SliderSetting startDelay; + private final ButtonSetting goldenHead; + private final ButtonSetting soup; + private final ButtonSetting goldenHeadName; private long lastHeal = -1; private long lastSwitchTo = -1; private long lastDoneUse = -1; private int originalSlot = -1; + public AutoHeal() { super("AutoHeal", category.player); - this.registerSetting(new DescriptionSetting("help you win by auto use healing item.")); - this.registerSetting(item = new ModeSetting("Item", new String[]{"Golden head", "Soup"}, 0)); - this.registerSetting(autoThrow = new ButtonSetting("Auto throw", false, new ModeOnly(item, 1))); + this.registerSetting(new DescriptionSetting("Automatically uses healing items.")); + this.registerSetting(goldenHead = new ButtonSetting("Golden head", true)); + this.registerSetting(goldenHeadName = new ButtonSetting("Check golden Head name", true, goldenHead::isToggled)); + this.registerSetting(soup = new ButtonSetting("Soup", false)); + this.registerSetting(autoDrop = new ButtonSetting("Auto drop", false, soup::isToggled)); this.registerSetting(minHealth = new SliderSetting("Min health", 10, 0, 20, 1)); this.registerSetting(healDelay = new SliderSetting("Heal delay", 500, 0, 1500, 1)); this.registerSetting(startDelay = new SliderSetting("Start delay", 0, 0, 300, 1)); @@ -42,15 +45,30 @@ public void onRender(TickEvent.RenderTickEvent event) { if (mc.thePlayer.getHealth() <= minHealth.getInput()) { if (lastSwitchTo == -1) { - int toSlot; - switch ((int) item.getInput()) { - default: - case 0: - toSlot = ContainerUtils.getSlot(ItemSkull.class); - break; - case 1: - toSlot = ContainerUtils.getSlot(ItemSoup.class); - break; + int toSlot = -1; + + if (goldenHead.isToggled()) { + for (int slot = 0; slot <= 8; slot++) { + ItemStack itemInSlot = mc.thePlayer.inventory.getStackInSlot(slot); + if (itemInSlot != null && itemInSlot.getItem() instanceof ItemSkull) { + + if (goldenHeadName.isToggled()) { + String displayName = itemInSlot.getDisplayName().toLowerCase(); + if ((displayName.contains("golden") && displayName.contains("head"))) { + toSlot = slot; + break; + } + } else { + toSlot = slot; + break; + } + } + } + } + + + if (toSlot == -1 && soup.isToggled()) { + toSlot = ContainerUtils.getSlot(ItemSoup.class); } if (toSlot == -1) return; @@ -61,6 +79,7 @@ public void onRender(TickEvent.RenderTickEvent event) { } } + if (lastSwitchTo != -1) { ItemStack stack = SlotHandler.getHeldItem(); if (stack == null) return; @@ -70,8 +89,7 @@ public void onRender(TickEvent.RenderTickEvent event) { mc.playerController.sendUseItem(mc.thePlayer, mc.theWorld, stack); lastDoneUse = System.currentTimeMillis(); } else { - if (item.getInput() == 1 && autoThrow.isToggled()) { - mc.playerController.sendPacketDropItem(stack); + if (autoDrop.isToggled() && stack.getItem() instanceof ItemSoup) {mc.thePlayer.dropOneItem(true); } if (originalSlot != -1) { @@ -82,7 +100,11 @@ public void onRender(TickEvent.RenderTickEvent event) { lastSwitchTo = -1; lastDoneUse = -1; lastHeal = System.currentTimeMillis(); + + if (mc.thePlayer.getHealth() <= minHealth.getInput()) { + lastSwitchTo = -1; + } } } } -} \ No newline at end of file +} diff --git a/src/main/java/keystrokesmod/module/impl/render/Watermark.java b/src/main/java/keystrokesmod/module/impl/render/Watermark.java index 8069e7278..b4fa9aa0d 100644 --- a/src/main/java/keystrokesmod/module/impl/render/Watermark.java +++ b/src/main/java/keystrokesmod/module/impl/render/Watermark.java @@ -27,7 +27,7 @@ import java.util.Objects; public class Watermark extends Module { - public static final String VERSION = "2.8"; + public static final String VERSION = "2.8.1"; public static final HashMap WATERMARK = new HashMap<>(); public static String customName = "CustomClient"; diff --git a/src/main/java/keystrokesmod/module/impl/world/tower/HypixelTower.java b/src/main/java/keystrokesmod/module/impl/world/tower/HypixelTower.java index 6190371bc..033b65d1d 100644 --- a/src/main/java/keystrokesmod/module/impl/world/tower/HypixelTower.java +++ b/src/main/java/keystrokesmod/module/impl/world/tower/HypixelTower.java @@ -28,7 +28,7 @@ public class HypixelTower extends SubMode { private final ButtonSetting notWhileMoving; - private final SliderSetting verticalBlocks; + private final SliderSetting stopOnBlocks; public static final Set LIMIT_FACING = new HashSet<>(Collections.singleton(EnumFacing.SOUTH)); public static final MoveCorrect moveCorrect = new MoveCorrect(0.3, MoveCorrect.Mode.POSITION); @@ -42,7 +42,7 @@ public class HypixelTower extends SubMode { public HypixelTower(String name, @NotNull Tower parent) { super(name, parent); this.registerSetting(notWhileMoving = new ButtonSetting("Not while moving", true)); - this.registerSetting(verticalBlocks = new SliderSetting("Vertical blocks", 6, 6, 10, 1)); + this.registerSetting(stopOnBlocks = new SliderSetting("Stop on blocks", 6, 6, 10, 1)); } @SubscribeEvent @@ -73,7 +73,7 @@ public void onMove(MoveEvent event) throws IllegalAccessException { if (this.towerTicks == 2) { event.setY(Math.floor(mc.thePlayer.posY + 1.0) - mc.thePlayer.posY); } else if (this.towerTicks == 3) { - if (parent.canTower() && !airUnder) { + if (parent.canTower()) { event.setY(mc.thePlayer.motionY = 0.4198499917984009); if (MoveUtil.isMoving()) MoveUtil.strafe((float) towerSpeed - randomAmount()); @@ -108,7 +108,7 @@ public void onPreUpdate(PreUpdateEvent event) { } if (blockPlaceRequest && !Utils.isMoving()) { - if (verticalPlaced >= verticalBlocks.getInput() || mc.thePlayer.onGround) { + if (verticalPlaced >= stopOnBlocks.getInput() || mc.thePlayer.onGround) { towering = false; blockPlaceRequest = false; verticalPlaced = 0; diff --git a/src/main/java/keystrokesmod/utility/aim/AimSimulator.java b/src/main/java/keystrokesmod/utility/aim/AimSimulator.java index 50de9b37b..2208835fd 100644 --- a/src/main/java/keystrokesmod/utility/aim/AimSimulator.java +++ b/src/main/java/keystrokesmod/utility/aim/AimSimulator.java @@ -42,6 +42,15 @@ public class AimSimulator { private boolean delay = false; private int delayTicks = 1; + private boolean scale = false; + private double scaleX = 1; + private double scaleY = 1; + + private boolean offset = false; + private double offsetX = 0; + private double offsetY = 0; + private boolean offsetPre = true; + @Getter private Vec3 hitPos = Vec3.ZERO; @@ -67,8 +76,25 @@ public void setDelay(boolean value, int delayTicks) { this.delay = value; } + public void setScale(boolean value, double scaleX, double scaleY) { + this.scale = value; + this.scaleX = scaleX; + this.scaleY = scaleY; + } + + public void setOffset(boolean value, double offsetX, double offsetY, boolean offsetPre) { + this.offset = value; + this.offsetX = offsetX; + this.offsetY = offsetY; + this.offsetPre = offsetPre; + } + public @NotNull Pair getRotation(@NotNull EntityLivingBase target) { AxisAlignedBB targetBox = target.getEntityBoundingBox(); + if (scale) { + targetBox = targetBox.expand(scaleX, scaleY, scaleX); + } + if (boxHistory.size() >= 101) { boxHistory.remove(boxHistory.size() - 1); } @@ -90,6 +116,9 @@ public void setDelay(boolean value, int delayTicks) { targetPosition = new Vec3((aimBox.maxX + aimBox.minX) / 2, aimBox.minY + target.getEyeHeight() - 0.15, (aimBox.maxZ + aimBox.minZ) / 2); } + if (offset && offsetPre) { + targetPosition = targetPosition.add(offsetX, offsetY, offsetX); + } if (yDiff >= 0 && lazy) { if (targetPosition.y() - yDiff > target.posY) { @@ -118,6 +147,10 @@ public void setDelay(boolean value, int delayTicks) { targetPosition.z = normal(targetBox.maxZ, targetBox.minZ, targetPosition.z + lastNoiseDeltaZ); } + if (offset && !offsetPre) { + targetPosition = targetPosition.add(offsetX, offsetY, offsetX); + } + yaw = PlayerRotation.getYaw(targetPosition); pitch = PlayerRotation.getPitch(targetPosition); hitPos = targetPosition; diff --git a/src/main/resources/mixins.raven.json b/src/main/resources/mixins.raven.json index cff0fb8a1..25af823d0 100644 --- a/src/main/resources/mixins.raven.json +++ b/src/main/resources/mixins.raven.json @@ -7,6 +7,7 @@ "client.MixinInventoryPlayer", "entity.EntityAccessor", "entity.EntityLivingBaseAccessor", + "entity.EntityPlayerAccessor", "entity.MixinEntity", "entity.MixinEntityLivingBase", "entity.MixinEntityPlayer",