diff --git a/bin/main/callback.html b/bin/main/callback.html new file mode 100644 index 00000000..ad541ea1 --- /dev/null +++ b/bin/main/callback.html @@ -0,0 +1,44 @@ + + + + + + + + Close this window and return to Minecraft! + + + + + +
+ Close this window and return to Minecraft! +
+ + + \ No newline at end of file diff --git a/bin/main/mcmod.info b/bin/main/mcmod.info new file mode 100644 index 00000000..7f2251d1 --- /dev/null +++ b/bin/main/mcmod.info @@ -0,0 +1,10 @@ +[ + { + "name": "Myau", + "version": "${version}", + "mcversion": "1.8.9", + "authorList": [ + "ksyz" + ] + } +] \ No newline at end of file diff --git a/bin/main/mixins.myau.json b/bin/main/mixins.myau.json new file mode 100644 index 00000000..e7993545 --- /dev/null +++ b/bin/main/mixins.myau.json @@ -0,0 +1,7 @@ +{ + "package": "${basePackage}.mixin", + "plugin": "${basePackage}.init.FMLLoadingPlugin", + "refmap": "mixins.${modid}.refmap.json", + "minVersion": "0.7", + "compatibilityLevel": "JAVA_8" +} diff --git a/bin/main/ssl.jks b/bin/main/ssl.jks new file mode 100644 index 00000000..0286754e Binary files /dev/null and b/bin/main/ssl.jks differ diff --git a/bin/main/version.json b/bin/main/version.json new file mode 100644 index 00000000..3e640ab7 --- /dev/null +++ b/bin/main/version.json @@ -0,0 +1,3 @@ +{ + "version": "${version}" +} \ No newline at end of file diff --git a/src/main/java/myau/Myau.java b/src/main/java/myau/Myau.java index a9301345..6cbeac9e 100644 --- a/src/main/java/myau/Myau.java +++ b/src/main/java/myau/Myau.java @@ -69,6 +69,7 @@ public void init() { moduleManager.modules.put(AutoAnduril.class, new AutoAnduril()); moduleManager.modules.put(AutoHeal.class, new AutoHeal()); moduleManager.modules.put(AutoTool.class, new AutoTool()); + moduleManager.modules.put(Backtrack.class, new Backtrack()); moduleManager.modules.put(BedNuker.class, new BedNuker()); moduleManager.modules.put(BedESP.class, new BedESP()); moduleManager.modules.put(BedTracker.class, new BedTracker()); @@ -76,8 +77,10 @@ public void init() { moduleManager.modules.put(Chams.class, new Chams()); moduleManager.modules.put(ChestESP.class, new ChestESP()); moduleManager.modules.put(ChestStealer.class, new ChestStealer()); + moduleManager.modules.put(Clutch.class, new Clutch()); moduleManager.modules.put(Eagle.class, new Eagle()); moduleManager.modules.put(ESP.class, new ESP()); + moduleManager.modules.put(FakeLag.class, new FakeLag()); moduleManager.modules.put(FastPlace.class, new FastPlace()); moduleManager.modules.put(Freeze.class, new Freeze()); moduleManager.modules.put(Fly.class, new Fly()); @@ -120,6 +123,7 @@ public void init() { moduleManager.modules.put(Sprint.class, new Sprint()); moduleManager.modules.put(TargetHUD.class, new TargetHUD()); moduleManager.modules.put(TargetStrafe.class, new TargetStrafe()); + moduleManager.modules.put(Timer.class, new Timer()); moduleManager.modules.put(Tracers.class, new Tracers()); moduleManager.modules.put(Trajectories.class, new Trajectories()); moduleManager.modules.put(Velocity.class, new Velocity()); diff --git a/src/main/java/myau/mixin/IAccessorMinecraft.java b/src/main/java/myau/mixin/IAccessorMinecraft.java index 87b1f9c1..1c373fbb 100644 --- a/src/main/java/myau/mixin/IAccessorMinecraft.java +++ b/src/main/java/myau/mixin/IAccessorMinecraft.java @@ -7,6 +7,7 @@ import org.apache.logging.log4j.Logger; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.gen.Invoker; @SideOnly(Side.CLIENT) @Mixin({Minecraft.class}) @@ -22,4 +23,13 @@ public interface IAccessorMinecraft { @Accessor("rightClickDelayTimer") void setRightClickDelayTimer(int integer); -} + + @Accessor("leftClickCounter") + void setLeftClickCounter(int value); + + @Invoker("clickMouse") + void callClickMouse(); + + @Invoker("rightClickMouse") + void callRightClickMouse(); +} \ No newline at end of file diff --git a/src/main/java/myau/mixin/MixinEntityPlayerSP.java b/src/main/java/myau/mixin/MixinEntityPlayerSP.java index 4a39be73..00454e02 100644 --- a/src/main/java/myau/mixin/MixinEntityPlayerSP.java +++ b/src/main/java/myau/mixin/MixinEntityPlayerSP.java @@ -10,6 +10,7 @@ import myau.management.RotationState; import myau.module.modules.AntiDebuff; import myau.module.modules.NoSlow; +import myau.module.modules.Timer; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.potion.Potion; import net.minecraft.util.BlockPos; @@ -44,6 +45,20 @@ public abstract class MixinEntityPlayerSP extends MixinEntityPlayer { @Shadow public float prevRenderArmYaw; + @Inject( + method = {"onUpdate"}, + at = {@At("HEAD")}, + cancellable = true + ) + private void freezeUpdate(CallbackInfo callbackInfo) { + Timer timer = Myau.moduleManager != null + ? (Timer) Myau.moduleManager.modules.get(Timer.class) + : null; + if (timer != null && timer.isFreezing()) { + callbackInfo.cancel(); + } + } + @Inject( method = {"onUpdate"}, at = {@At("HEAD")} @@ -164,4 +179,4 @@ private boolean checkPotion(EntityPlayerSP entityPlayerSP, Potion potion) { } return ((IAccessorEntityLivingBase) entityPlayerSP).getActivePotionsMap().containsKey(potion.id); } -} +} \ No newline at end of file diff --git a/src/main/java/myau/mixin/MixinMinecraft.java b/src/main/java/myau/mixin/MixinMinecraft.java index f6fa618a..e612334e 100644 --- a/src/main/java/myau/mixin/MixinMinecraft.java +++ b/src/main/java/myau/mixin/MixinMinecraft.java @@ -94,13 +94,16 @@ private void updateFramebufferSize(CallbackInfo callbackInfo) { cancellable = true ) private void clickMouse(CallbackInfo callbackInfo) { - if (Myau.moduleManager != null && Myau.moduleManager.modules.get(NoHitDelay.class).isEnabled()) { - this.leftClickCounter = 0; - } - LeftClickMouseEvent event = new LeftClickMouseEvent(); - EventManager.call(event); - if (event.isCancelled()) { - callbackInfo.cancel(); + // Only fire event when actually clicking (not on cooldown) + if (this.leftClickCounter <= 0) { + if (Myau.moduleManager != null && Myau.moduleManager.modules.get(NoHitDelay.class).isEnabled()) { + this.leftClickCounter = 0; + } + LeftClickMouseEvent event = new LeftClickMouseEvent(); + EventManager.call(event); + if (event.isCancelled()) { + callbackInfo.cancel(); + } } } @@ -110,10 +113,14 @@ private void clickMouse(CallbackInfo callbackInfo) { cancellable = true ) private void rightClickMouse(CallbackInfo callbackInfo) { - RightClickMouseEvent event = new RightClickMouseEvent(); - EventManager.call(event); - if (event.isCancelled()) { - callbackInfo.cancel(); + // Only fire event when actually clicking (not on cooldown) + IAccessorMinecraft accessor = (IAccessorMinecraft) this; + if (accessor.getRightClickDelayTimer() <= 0) { + RightClickMouseEvent event = new RightClickMouseEvent(); + EventManager.call(event); + if (event.isCancelled()) { + callbackInfo.cancel(); + } } } @@ -159,4 +166,4 @@ private void changeCurrentItem(InventoryPlayer inventoryPlayer, int slot) { inventoryPlayer.changeCurrentItem(slot); } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/mixin/MixinTimer.java b/src/main/java/myau/mixin/MixinTimer.java new file mode 100644 index 00000000..e7061ea4 --- /dev/null +++ b/src/main/java/myau/mixin/MixinTimer.java @@ -0,0 +1,26 @@ +package myau.mixin; + +import net.minecraft.util.Timer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@SideOnly(Side.CLIENT) +@Mixin(value = {Timer.class}, priority = 9999) +public abstract class MixinTimer { + + @Shadow + public float timerSpeed; + + @Inject( + method = {"updateTimer"}, + at = @At("HEAD") + ) + private void updateTimer(CallbackInfo ci) { + this.timerSpeed = myau.module.modules.Timer.getRequestedSpeed(); + } +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Backtrack.java b/src/main/java/myau/module/modules/Backtrack.java new file mode 100644 index 00000000..f3ae6cc7 --- /dev/null +++ b/src/main/java/myau/module/modules/Backtrack.java @@ -0,0 +1,363 @@ +package myau.module.modules; + +import myau.Myau; +import myau.event.EventTarget; +import myau.event.types.EventType; +import myau.event.types.Priority; +import myau.events.AttackEvent; +import myau.events.PacketEvent; +import myau.events.Render3DEvent; +import myau.events.TickEvent; +import myau.mixin.IAccessorRenderManager; +import myau.module.Module; +import myau.property.properties.BooleanProperty; +import myau.property.properties.FloatProperty; +import myau.property.properties.IntProperty; +import myau.util.RenderUtil; +import myau.util.RotationUtil; +import myau.util.TeamUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S12PacketEntityVelocity; +import net.minecraft.network.play.server.S14PacketEntity; +import net.minecraft.network.play.server.S18PacketEntityTeleport; +import net.minecraft.network.play.server.S19PacketEntityHeadLook; +import net.minecraft.network.play.server.S0FPacketSpawnMob; +import net.minecraft.network.play.server.S27PacketExplosion; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; + +import java.awt.*; +import java.util.ArrayList; +import java.util.concurrent.ConcurrentLinkedQueue; + +public class Backtrack extends Module { + + private static final Minecraft mc = Minecraft.getMinecraft(); + + public final FloatProperty range; + public final BooleanProperty adaptive; + public final IntProperty normalDelay; + public final IntProperty adaptiveDelay; + public final BooleanProperty releaseOnHit; + public final BooleanProperty interruptLagRange; + public final BooleanProperty players; + public final BooleanProperty teams; + public final BooleanProperty botCheck; + public final BooleanProperty esp; + + private final ConcurrentLinkedQueue> incomingQueue = new ConcurrentLinkedQueue<>(); + + private Vec3 trackedPosition = null; + private EntityLivingBase target; + private EntityLivingBase lastAttacked; + private long lastAttackTime = 0L; + private static final long COMBAT_LOCK_MS = 3000L; + private AxisAlignedBB realAABB; + private long backtrackStartTime = 0L; + private boolean lagRangeInterrupted = false; + + public Backtrack() { + super("Backtrack", false); + this.range = new FloatProperty("range", 3.5F, 1.0F, 8.0F); + this.adaptive = new BooleanProperty("adaptive", true); + this.normalDelay = new IntProperty("normal-delay", 100, 50, 1000, () -> !this.adaptive.getValue()); + this.adaptiveDelay = new IntProperty("adaptive-delay", 100, 50, 1000, this.adaptive::getValue); + this.releaseOnHit = new BooleanProperty("release-on-hit", true); + this.interruptLagRange = new BooleanProperty("interrupt-lagrange", true); + this.players = new BooleanProperty("players", true); + this.teams = new BooleanProperty("teams", true); + this.botCheck = new BooleanProperty("bot-check", true); + this.esp = new BooleanProperty("esp", true); + } + + @Override + public void onEnabled() { + incomingQueue.clear(); + trackedPosition = null; + realAABB = null; + backtrackStartTime = 0L; + target = null; + lastAttacked = null; + lastAttackTime = 0L; + lagRangeInterrupted = false; + } + + @Override + public void onDisabled() { + setLagRangeEnabled(true); + releaseIncoming(); + incomingQueue.clear(); + trackedPosition = null; + realAABB = null; + target = null; + lastAttacked = null; + lastAttackTime = 0L; + } + + private int currentMaxDelay() { + return adaptive.getValue() ? adaptiveDelay.getValue() : normalDelay.getValue(); + } + + private LagRange getLagRange() { + Module m = Myau.moduleManager.getModule(LagRange.class); + return (m instanceof LagRange) ? (LagRange) m : null; + } + + private void setLagRangeEnabled(boolean enabled) { + if (!interruptLagRange.getValue()) return; + LagRange lr = getLagRange(); + if (lr == null) return; + if (enabled && lagRangeInterrupted) { + lagRangeInterrupted = false; + lr.setEnabled(true); + } else if (!enabled && !lagRangeInterrupted && lr.isEnabled()) { + lagRangeInterrupted = true; + lr.setEnabled(false); + } + } + + private boolean isInCombat() { + if (lastAttacked == null || lastAttacked != target || lastAttacked.isDead) return false; + return System.currentTimeMillis() - lastAttackTime <= COMBAT_LOCK_MS; + } + + private boolean canBacktrack() { + if (target == null || target.isDead) return false; + if (trackedPosition == null) return false; + if (distanceTo(trackedPosition) > range.getValue()) return false; + if (backtrackStartTime > 0 && System.currentTimeMillis() - backtrackStartTime > currentMaxDelay()) return false; + double distReal = distanceTo(trackedPosition); + double distCurrent = mc.thePlayer.getDistanceToEntity(target); + return adaptive.getValue() ? distReal > distCurrent : distReal > distCurrent + 0.1; + } + + private boolean shouldQueueIncoming(Packet p) { + if (p instanceof S12PacketEntityVelocity) return false; + if (p instanceof S27PacketExplosion) return false; + if (p instanceof S0FPacketSpawnMob) return false; + if (p instanceof S14PacketEntity) { + Entity e = ((S14PacketEntity) p).getEntity(mc.theWorld); + return e != null && e == target; + } + if (p instanceof S18PacketEntityTeleport) return ((S18PacketEntityTeleport) p).getEntityId() == target.getEntityId(); + if (p instanceof S19PacketEntityHeadLook) return ((S19PacketEntityHeadLook) p).getEntity(mc.theWorld) == target; + return false; + } + + private void releaseIncoming() { + if (mc.getNetHandler() == null) return; + Packet p; + while ((p = incomingQueue.poll()) != null) processPacketUnchecked(p); + backtrackStartTime = 0L; + } + + @SuppressWarnings("unchecked") + private static void processPacketUnchecked(Packet packet) { + packet.processPacket((T) Minecraft.getMinecraft().getNetHandler()); + } + + private void releaseAll() { + releaseIncoming(); + } + + private void updateRealPosition(Packet packet) { + if (target == null) return; + + if (packet instanceof S14PacketEntity) { + S14PacketEntity p = (S14PacketEntity) packet; + Entity e = p.getEntity(mc.theWorld); + if (e == null || e != target) return; + + Vec3 base = (trackedPosition != null) ? trackedPosition + : new Vec3(target.posX, target.posY, target.posZ); + + double dx = p.func_149062_c() / 32.0; + double dy = p.func_149061_d() / 32.0; + double dz = p.func_149064_e() / 32.0; + trackedPosition = base.addVector(dx, dy, dz); + + } else if (packet instanceof S18PacketEntityTeleport) { + S18PacketEntityTeleport p = (S18PacketEntityTeleport) packet; + if (p.getEntityId() != target.getEntityId()) return; + + trackedPosition = new Vec3(p.getX() / 32.0, p.getY() / 32.0, p.getZ() / 32.0); + } + + if (trackedPosition != null) { + double hw = target.width / 2.0; + realAABB = new AxisAlignedBB( + trackedPosition.xCoord - hw, trackedPosition.yCoord, + trackedPosition.zCoord - hw, + trackedPosition.xCoord + hw, trackedPosition.yCoord + target.height, + trackedPosition.zCoord + hw + ); + } + } + + @EventTarget + public void onAttack(AttackEvent event) { + if (!isEnabled() || mc.thePlayer == null) return; + if (event.getTarget() instanceof EntityLivingBase) { + lastAttacked = (EntityLivingBase) event.getTarget(); + lastAttackTime = System.currentTimeMillis(); + } + } + + @EventTarget + public void onPacket(PacketEvent event) { + if (!isEnabled() || mc.thePlayer == null || mc.theWorld == null) return; + Module scaffold = Myau.moduleManager.getModule(Scaffold.class); + if (scaffold != null && scaffold.isEnabled()) { + setLagRangeEnabled(true); + releaseAll(); + incomingQueue.clear(); + return; + } + if (event.getType() == EventType.RECEIVE) { + handleIncoming(event); + } + } + + private void handleIncoming(PacketEvent event) { + Packet packet = event.getPacket(); + updateRealPosition(packet); + if (target == null) return; + if (canBacktrack() && shouldQueueIncoming(packet)) { + if (backtrackStartTime == 0L) backtrackStartTime = System.currentTimeMillis(); + incomingQueue.add(packet); + event.setCancelled(true); + } else if (!canBacktrack() && !incomingQueue.isEmpty()) { + releaseIncoming(); + } + } + + @EventTarget(Priority.LOW) + public void onTick(TickEvent event) { + if (!isEnabled() || mc.thePlayer == null || mc.theWorld == null) return; + if (event.getType() == EventType.PRE) tickPre(); + } + + private void tickPre() { + EntityLivingBase newTarget = resolveTarget(); + if (newTarget != target) { + setLagRangeEnabled(true); + releaseAll(); + realAABB = null; + trackedPosition = null; + } + target = newTarget; + + if (target == null) { + setLagRangeEnabled(true); + return; + } + + if (trackedPosition == null) { + trackedPosition = new Vec3( + MathHelper.floor_double(target.posX * 32.0) / 32.0, + MathHelper.floor_double(target.posY * 32.0) / 32.0, + MathHelper.floor_double(target.posZ * 32.0) / 32.0 + ); + double hw = target.width / 2.0; + realAABB = new AxisAlignedBB( + trackedPosition.xCoord - hw, trackedPosition.yCoord, + trackedPosition.zCoord - hw, + trackedPosition.xCoord + hw, trackedPosition.yCoord + target.height, + trackedPosition.zCoord + hw + ); + } + + boolean shouldRelease = false; + if (mc.thePlayer.hurtTime == mc.thePlayer.maxHurtTime && mc.thePlayer.maxHurtTime > 0) shouldRelease = true; + if (distanceTo(trackedPosition) > range.getValue()) shouldRelease = true; + if (backtrackStartTime > 0 && System.currentTimeMillis() - backtrackStartTime > currentMaxDelay()) shouldRelease = true; + if (releaseOnHit.getValue() && target.hurtTime == 1) shouldRelease = true; + + if (shouldRelease) { + setLagRangeEnabled(true); + releaseAll(); + return; + } + + if (isInCombat() && !incomingQueue.isEmpty()) { + setLagRangeEnabled(false); + } else if (!isInCombat() || incomingQueue.isEmpty()) { + setLagRangeEnabled(true); + } + } + + @EventTarget(Priority.HIGH) + public void onRender3D(Render3DEvent event) { + if (!isEnabled() || !esp.getValue()) return; + if (target == null || realAABB == null) return; + AxisAlignedBB visual = target.getEntityBoundingBox(); + double dx = realAABB.minX - visual.minX; + double dy = realAABB.minY - visual.minY; + double dz = realAABB.minZ - visual.minZ; + if (Math.abs(dx) < 0.01 && Math.abs(dy) < 0.01 && Math.abs(dz) < 0.01) return; + Color color = (target instanceof EntityPlayer) + ? TeamUtil.getTeamColor((EntityPlayer) target, 1.0F) + : new Color(255, 60, 60); + IAccessorRenderManager rm = (IAccessorRenderManager) mc.getRenderManager(); + AxisAlignedBB aabb = new AxisAlignedBB( + realAABB.minX - rm.getRenderPosX(), + realAABB.minY - rm.getRenderPosY(), + realAABB.minZ - rm.getRenderPosZ(), + realAABB.maxX - rm.getRenderPosX(), + realAABB.maxY - rm.getRenderPosY(), + realAABB.maxZ - rm.getRenderPosZ() + ); + RenderUtil.enableRenderState(); + RenderUtil.drawFilledBox(aabb, color.getRed(), color.getGreen(), color.getBlue()); + RenderUtil.disableRenderState(); + } + + private EntityLivingBase resolveTarget() { + KillAura ka = (KillAura) Myau.moduleManager.modules.get(KillAura.class); + if (ka != null && ka.isEnabled() && ka.getTarget() != null) return ka.getTarget(); + if (lastAttacked != null && !lastAttacked.isDead + && System.currentTimeMillis() - lastAttackTime <= COMBAT_LOCK_MS + && mc.thePlayer.getDistanceToEntity(lastAttacked) <= range.getValue() * 2.0F) { + return lastAttacked; + } + ArrayList candidates = new ArrayList<>(); + for (Entity entity : mc.theWorld.loadedEntityList) { + if (!(entity instanceof EntityLivingBase)) continue; + EntityLivingBase e = (EntityLivingBase) entity; + if (isValidTarget(e) && mc.thePlayer.getDistanceToEntity(e) <= range.getValue()) candidates.add(e); + } + if (candidates.isEmpty()) return null; + candidates.sort((a, b) -> Float.compare(RotationUtil.angleToEntity(a), RotationUtil.angleToEntity(b))); + return candidates.get(0); + } + + private boolean isValidTarget(EntityLivingBase e) { + if (!mc.theWorld.loadedEntityList.contains(e)) return false; + if (e == mc.thePlayer || e == mc.thePlayer.ridingEntity) return false; + if (e == mc.getRenderViewEntity() || e == mc.getRenderViewEntity().ridingEntity) return false; + if (e.deathTime > 0) return false; + if (e instanceof EntityPlayer) { + if (!players.getValue()) return false; + EntityPlayer p = (EntityPlayer) e; + if (TeamUtil.isFriend(p)) return false; + if (teams.getValue() && TeamUtil.isSameTeam(p)) return false; + if (botCheck.getValue() && TeamUtil.isBot(p)) return false; + return true; + } + return false; + } + + private double distanceTo(Vec3 v) { + return mc.thePlayer.getDistance(v.xCoord, v.yCoord, v.zCoord); + } + + @Override + public String[] getSuffix() { + return new String[]{ currentMaxDelay() + "ms" }; + } +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/BedESP.java b/src/main/java/myau/module/modules/BedESP.java index 1a417241..a31e66c6 100644 --- a/src/main/java/myau/module/modules/BedESP.java +++ b/src/main/java/myau/module/modules/BedESP.java @@ -9,9 +9,8 @@ import myau.property.properties.*; import myau.property.properties.BooleanProperty; import myau.property.properties.ModeProperty; -import net.minecraft.block.BlockBed; +import net.minecraft.block.*; import net.minecraft.block.BlockBed.EnumPartType; -import net.minecraft.block.BlockObsidian; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.util.AxisAlignedBB; @@ -30,6 +29,9 @@ public class BedESP extends Module { public final ColorProperty customColor; public final PercentProperty opacity; public final BooleanProperty outline; + public final FloatProperty outlineWidth; + public final BooleanProperty expose; + public final ColorProperty exposeColor; public final BooleanProperty obsidian; private Color getColor() { @@ -44,26 +46,51 @@ private Color getColor() { } private void drawObsidianBox(AxisAlignedBB axisAlignedBB) { + int red = 170; + int green = 0; + int blue = 170; + if (this.outline.getValue()) { - RenderUtil.drawBoundingBox(axisAlignedBB, 170, 0, 170, 255, 1.5F); + RenderUtil.drawBoundingBox(axisAlignedBB, red, green, blue, 255, this.outlineWidth.getValue()); } - RenderUtil.drawFilledBox(axisAlignedBB, 170, 0, 170); + RenderUtil.drawFilledBox(axisAlignedBB, red, green, blue); } private void drawObsidian(BlockPos blockPos) { + int red = 170; + int green = 0; + int blue = 170; + if (this.outline.getValue()) { - RenderUtil.drawBlockBoundingBox(blockPos, 1.0, 170, 0, 170, 255, 1.5F); + RenderUtil.drawBlockBoundingBox(blockPos, 1.0, red, green, blue, 255, this.outlineWidth.getValue()); } - RenderUtil.drawBlockBox( - blockPos, 1.0, 170, 0, 170 - ); + RenderUtil.drawBlockBox(blockPos, 1.0, red, green, blue); } + private boolean isBlockExposed(BlockPos headPos, BlockPos footPos) { + for (EnumFacing facing : Arrays.asList(EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST)) { + BlockPos headOffset = headPos.offset(facing); + BlockPos footOffset = footPos.offset(facing); + + if (mc.theWorld.isAirBlock(headOffset) || mc.theWorld.isAirBlock(footOffset)) { + return true; + } + } + if (mc.theWorld.isAirBlock(headPos.up()) || mc.theWorld.isAirBlock(footPos.up())) { + return true; + } + return false; + } + + public BedESP() { super("BedESP", false); this.customColor = new ColorProperty("custom-color", (int) 8085714755840333141L, () -> this.color.getValue() == 0); this.opacity = new PercentProperty("opacity", 25); this.outline = new BooleanProperty("outline", false); + this.outlineWidth = new FloatProperty("outline-width", 1.5F, 0.5F, 5.0F, () -> this.outline.getValue()); + this.expose = new BooleanProperty("expose", false, () -> this.outline.getValue()); + this.exposeColor = new ColorProperty("expose-color", 0x00D1A4, () -> this.outline.getValue() && this.expose.getValue()); this.obsidian = new BooleanProperty("obsidian", true); } @@ -81,12 +108,17 @@ public void onRender3D(Render3DEvent event) { BlockPos opposite = blockPos.offset(state.getValue(BlockBed.FACING).getOpposite()); IBlockState oppositeState = mc.theWorld.getBlockState(opposite); if (oppositeState.getBlock() instanceof BlockBed && oppositeState.getValue(BlockBed.PART) == EnumPartType.FOOT) { + boolean bedExposed = this.expose.getValue() && this.isBlockExposed(blockPos, opposite); + if (this.obsidian.getValue()) { for (EnumFacing facing : Arrays.asList(EnumFacing.UP, EnumFacing.NORTH, EnumFacing.EAST, EnumFacing.SOUTH, EnumFacing.WEST)) { BlockPos offsetX = blockPos.offset(facing); BlockPos offsetZ = opposite.offset(facing); - boolean xObsidian = mc.theWorld.getBlockState(offsetX).getBlock() instanceof BlockObsidian; - boolean zObsidian = mc.theWorld.getBlockState(offsetZ).getBlock() instanceof BlockObsidian; + IBlockState stateX = mc.theWorld.getBlockState(offsetX); + IBlockState stateZ = mc.theWorld.getBlockState(offsetZ); + boolean xObsidian = stateX.getBlock() instanceof BlockObsidian; + boolean zObsidian = stateZ.getBlock() instanceof BlockObsidian; + if (xObsidian && zObsidian) { this.drawObsidianBox( new AxisAlignedBB( @@ -123,15 +155,24 @@ public void onRender3D(Render3DEvent event) { -((IAccessorRenderManager) mc.getRenderManager()).getRenderPosY(), -((IAccessorRenderManager) mc.getRenderManager()).getRenderPosZ() ); - Color color = this.getColor(); + + Color fillColor = this.getColor(); + if (this.outline.getValue()) { - RenderUtil.drawBoundingBox(aabb, color.getRed(), color.getGreen(), color.getBlue(), 255, 1.5F); + Color outlineColor; + if (bedExposed) { + outlineColor = new Color(this.exposeColor.getValue()); + } else { + outlineColor = ((HUD) Myau.moduleManager.modules.get(HUD.class)).getColor(System.currentTimeMillis()); + } + RenderUtil.drawBoundingBox(aabb, outlineColor.getRed(), outlineColor.getGreen(), outlineColor.getBlue(), 255, this.outlineWidth.getValue()); } + RenderUtil.drawFilledBox( aabb, - color.getRed(), - color.getGreen(), - color.getBlue() + fillColor.getRed(), + fillColor.getGreen(), + fillColor.getBlue() ); } } else { @@ -148,4 +189,4 @@ public void onEnabled() { mc.renderGlobal.loadRenderers(); } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/ChestESP.java b/src/main/java/myau/module/modules/ChestESP.java index c25f4f50..4fe5fcfc 100644 --- a/src/main/java/myau/module/modules/ChestESP.java +++ b/src/main/java/myau/module/modules/ChestESP.java @@ -45,9 +45,9 @@ public void onRender(Render3DEvent event) { maxX = maxZ = 0.9375; if (block instanceof BlockChest) { if (block.canProvidePower()) { - color = new Color(this.trappedChest.getValue(), true); + color = new Color(this.trappedChest.getValue()); } else { - color = new Color(this.chest.getValue(), true); + color = new Color(this.chest.getValue()); } EnumFacing facing = mc.theWorld.getBlockState(chest.getPos()).getValue(BlockChest.FACING); switch (facing) { @@ -83,9 +83,8 @@ public void onRender(Render3DEvent event) { continue; } } else { - color = new Color(this.enderChest.getValue(), true); + color = new Color(this.enderChest.getValue()); } - if (color.getAlpha() == 0) continue; AxisAlignedBB aabb = new AxisAlignedBB( (double) chest.getPos().getX() + minX, (double) chest.getPos().getY() + 0.0, @@ -100,7 +99,7 @@ public void onRender(Render3DEvent event) { -((IAccessorRenderManager) mc.getRenderManager()).getRenderPosZ() ); RenderUtil.drawBoundingBox( - aabb, color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha(), 1.5F + aabb, color.getRed(), color.getGreen(), color.getBlue(), 255, 1.5F ); if (this.tracers.getValue()) { Vec3 vec; @@ -167,4 +166,4 @@ public void onRender(Render3DEvent event) { RenderUtil.disableRenderState(); } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Clutch.java b/src/main/java/myau/module/modules/Clutch.java new file mode 100644 index 00000000..12dd092e --- /dev/null +++ b/src/main/java/myau/module/modules/Clutch.java @@ -0,0 +1,499 @@ +package myau.module.modules; + +import myau.event.EventTarget; +import myau.event.types.EventType; +import myau.event.types.Priority; +import myau.events.*; +import myau.management.RotationState; +import myau.module.Module; +import myau.property.properties.BooleanProperty; +import myau.property.properties.FloatProperty; +import myau.property.properties.IntProperty; +import myau.property.properties.ModeProperty; +import myau.util.MoveUtil; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.*; + +import java.util.*; + +public class Clutch extends Module { + private static final Minecraft mc = Minecraft.getMinecraft(); + private final Map BLOCK_SCORE = new HashMap<>(); + + private float serverYaw; + private float serverPitch; + private float aimYaw; + private float aimPitch; + private boolean hasAim; + private boolean resetting; + private BlockPos targetBlock; + private EnumFacing targetFacing; + private Vec3 targetHitVec; + private boolean placeQueued; + private int lastSlot = -1; + private int plannedSlot = -1; + private boolean slotSwapped = false; + private int clutchBlocksPlaced = 0; + private int lastPlacedX = Integer.MIN_VALUE; + private int lastPlacedY = Integer.MIN_VALUE; + private int lastPlacedZ = Integer.MIN_VALUE; + private BlockPos lockedBlock = null; + private EnumFacing lockedFacing = null; + private float lockedAimYaw; + private float lockedAimPitch; + + private static final double HW = 0.3; + private static final double[][] CORNERS = {{-HW, -HW}, {HW, -HW}, {-HW, HW}, {HW, HW}}; + private static final double INSET = 0.05; + private static final double STEP = 0.2; + private static final double JIT = STEP * 0.1; + + public final FloatProperty reach = new FloatProperty("reach", 4.5f, 0.5f, 6.0f); + public final IntProperty speed = new IntProperty("speed", 8, 1, 100); + public final IntProperty snapbackSpeed = new IntProperty("snapback-speed", 12, 1, 100); + public final IntProperty maxBlocks = new IntProperty("max-blocks", 10, 0, 50); + public final IntProperty rotationTolerance = new IntProperty("rotation-tolerance", 25, 5, 100); + public final BooleanProperty simulateFuture = new BooleanProperty("simulate-future-pos", true); + public final ModeProperty moveFix = new ModeProperty("move-fix", 1, new String[]{"NONE", "SILENT"}); + + public Clutch() { + super("Clutch", false); + BLOCK_SCORE.put("obsidian", 0); + BLOCK_SCORE.put("end_stone", 1); + BLOCK_SCORE.put("planks", 2); + BLOCK_SCORE.put("log", 2); + BLOCK_SCORE.put("log2", 2); + BLOCK_SCORE.put("glass", 3); + BLOCK_SCORE.put("stained_glass", 3); + BLOCK_SCORE.put("stainedGlass", 3); + BLOCK_SCORE.put("hardened_clay", 4); + BLOCK_SCORE.put("stained_hardened_clay", 4); + BLOCK_SCORE.put("hardenedClay", 4); + BLOCK_SCORE.put("stainedHardenedClay", 4); + BLOCK_SCORE.put("clay", 4); + BLOCK_SCORE.put("stone", 5); + BLOCK_SCORE.put("cloth", 5); + } + + @Override + public void onEnabled() { + if (mc.thePlayer == null) return; + serverYaw = mc.thePlayer.rotationYaw; + serverPitch = mc.thePlayer.rotationPitch; + aimYaw = serverYaw; + aimPitch = serverPitch; + hasAim = false; + resetting = false; + clutchBlocksPlaced = 0; + lastSlot = mc.thePlayer.inventory.currentItem; + targetBlock = null; + targetFacing = null; + targetHitVec = null; + placeQueued = false; + slotSwapped = false; + plannedSlot = -1; + lockedBlock = null; + lockedFacing = null; + } + + @Override + public void onDisabled() { + if (mc.thePlayer == null) return; + restoreSlot(); + targetBlock = null; + targetFacing = null; + targetHitVec = null; + hasAim = false; + resetting = false; + lockedBlock = null; + lockedFacing = null; + } + + @EventTarget(Priority.HIGH) + public void onUpdate(UpdateEvent event) { + if (!isEnabled()) return; + if (event.getType() != EventType.PRE) return; + if (mc.thePlayer == null || mc.theWorld == null) return; + if (mc.currentScreen != null) return; + + serverYaw = event.getYaw(); + serverPitch = event.getPitch(); + + if (mc.thePlayer.onGround) clutchBlocksPlaced = 0; + + BlockPos belowFeet = new BlockPos( + MathHelper.floor_double(mc.thePlayer.posX), + MathHelper.floor_double(mc.thePlayer.posY) - 1, + MathHelper.floor_double(mc.thePlayer.posZ) + ); + + if (!isReplaceable(belowFeet)) { + clearAim(); + return; + } + + plannedSlot = findBestBlockSlot(); + if (plannedSlot == -1) { + clearAim(); + return; + } + + if (mc.thePlayer.inventory.currentItem != plannedSlot) { + if (!slotSwapped) lastSlot = mc.thePlayer.inventory.currentItem; + mc.thePlayer.inventory.currentItem = plannedSlot; + slotSwapped = true; + } + + ItemStack held = mc.thePlayer.inventory.getCurrentItem(); + if (held == null || !(held.getItem() instanceof ItemBlock)) { + clearAim(); + return; + } + + // Validate existing lock before searching for a new one + boolean lockValid = lockedBlock != null && lockedFacing != null && isLockedTargetValid(); + if (!lockValid) { + lockedBlock = null; + lockedFacing = null; + findClutchTarget(); + } + + if (targetBlock != null && targetHitVec != null) { + aimYaw = lockedAimYaw; + aimPitch = lockedAimPitch; + hasAim = true; + resetting = false; + } + + if (resetting) { + float[] sm = smoothStep(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch, true); + if (Math.abs(sm[0] - mc.thePlayer.rotationYaw) < 0.5f && Math.abs(sm[1] - mc.thePlayer.rotationPitch) < 0.5f) { + resetting = false; + } else { + event.setRotation(sm[0], sm[1], 4); + if (moveFix.getValue() != 0) event.setPervRotation(sm[0], 4); + } + return; + } + + if (hasAim && targetBlock != null) { + float[] sm = smoothStep(aimYaw, aimPitch, false); + event.setRotation(sm[0], sm[1], 4); + if (moveFix.getValue() != 0) event.setPervRotation(sm[0], 4); + + if (withinTolerance(sm[0], sm[1])) { + int max = maxBlocks.getValue(); + if (max == 0 || clutchBlocksPlaced < max) { + MovingObjectPosition mop = rayTrace(sm[0], sm[1], reach.getValue()); + if (mop != null + && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK + && mop.getBlockPos().equals(targetBlock) + && mop.sideHit == targetFacing) { + targetHitVec = mop.hitVec; + placeQueued = true; + } + } + } + } + + if (placeQueued) { + placeQueued = false; + doPlace(); + } + } + + @EventTarget + public void onMoveInput(MoveInputEvent event) { + if (!isEnabled()) return; + if (moveFix.getValue() == 1 + && RotationState.isActived() + && RotationState.getPriority() == 4 + && MoveUtil.isForwardPressed()) { + MoveUtil.fixStrafe(RotationState.getSmoothedYaw()); + } + } + + @EventTarget + public void onSwap(SwapItemEvent event) { + if (isEnabled()) { + lastSlot = event.setSlot(lastSlot); + event.setCancelled(true); + } + } + + private boolean isLockedTargetValid() { + if (isReplaceable(lockedBlock)) return false; + MovingObjectPosition mop = rayTrace(lockedAimYaw, lockedAimPitch, reach.getValue()); + if (mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) return false; + if (!mop.getBlockPos().equals(lockedBlock)) return false; + if (mop.sideHit != lockedFacing) return false; + targetHitVec = mop.hitVec; + targetBlock = lockedBlock; + targetFacing = lockedFacing; + return true; + } + + private void findClutchTarget() { + double px = mc.thePlayer.posX, py = mc.thePlayer.posY, pz = mc.thePlayer.posZ; + Vec3 eye = mc.thePlayer.getPositionEyes(1.0f); + double reachD = reach.getValue(); + + double futureX = px, futureY = py, futureZ = pz; + if (simulateFuture.getValue()) { + double mx = mc.thePlayer.motionX, my = mc.thePlayer.motionY, mz = mc.thePlayer.motionZ; + for (int t = 0; t < 20; t++) { + my = (my - 0.08) * 0.98; + futureY += my; + futureX += mx * 0.91; + futureZ += mz * 0.91; + if (futureY < py - 2 || my >= 0) break; + } + } + + int feetX = MathHelper.floor_double(px); + int feetY = MathHelper.floor_double(py); + int feetZ = MathHelper.floor_double(pz); + + List candidates = new ArrayList<>(); + for (int y = feetY - 1; y >= feetY - 4; y--) { + for (int x = feetX - 5; x <= feetX + 4; x++) { + for (int z = feetZ - 5; z <= feetZ + 4; z++) { + BlockPos bp = new BlockPos(x, y, z); + if (isReplaceable(bp)) continue; + + double curDist = dist2AABB(px, py, pz, x, y, z); + double futureDist = dist2AABB(futureX, futureY, futureZ, x, y, z); + double score = simulateFuture.getValue() ? curDist * 0.3 + futureDist * 0.7 : curDist; + + if (x == lastPlacedX && y == lastPlacedY && z == lastPlacedZ) score *= 0.95; + + candidates.add(new Object[]{score, bp}); + } + } + } + + candidates.sort(Comparator.comparingDouble(o -> (Double) o[0])); + + for (Object[] cand : candidates) { + BlockPos bp = (BlockPos) cand[1]; + boolean underPlayer = isUnderPlayer(bp, px, py, pz); + if (tryAimAtBlock(bp, eye, reachD, underPlayer)) return; + } + + targetBlock = null; + targetFacing = null; + targetHitVec = null; + } + + private boolean tryAimAtBlock(BlockPos bp, Vec3 eye, double reachD, boolean underPlayer) { + boolean faceSouth = Math.abs(eye.zCoord - (bp.getZ() + 1)) < Math.abs(eye.zCoord - bp.getZ()); + boolean faceEast = Math.abs(eye.xCoord - (bp.getX() + 1)) < Math.abs(eye.xCoord - bp.getX()); + float baseYaw = serverYaw, basePit = serverPitch; + + int n = (int) Math.round(1.0 / STEP); + List rotCands = new ArrayList<>(); + rotCands.add(new float[]{0f, baseYaw, basePit}); + + for (int r = 0; r <= n; r++) { + double v = clamp(r * STEP + randJit(), 0, 1); + for (int c = 0; c <= n; c++) { + double u = clamp(c * STEP + randJit(), 0, 1); + + if (underPlayer) { + float[] rv = getRotationsWrapped(eye, bp.getX() + u, bp.getY() + 1 - INSET, bp.getZ() + v); + rotCands.add(new float[]{angCost(rv[0], rv[1], baseYaw, basePit), rv[0], rv[1]}); + } + + float[] rZ = getRotationsWrapped(eye, bp.getX() + u, bp.getY() + v, faceSouth ? bp.getZ() + 1 - INSET : bp.getZ() + INSET); + rotCands.add(new float[]{angCost(rZ[0], rZ[1], baseYaw, basePit), rZ[0], rZ[1]}); + + float[] rX = getRotationsWrapped(eye, faceEast ? bp.getX() + 1 - INSET : bp.getX() + INSET, bp.getY() + v, bp.getZ() + u); + rotCands.add(new float[]{angCost(rX[0], rX[1], baseYaw, basePit), rX[0], rX[1]}); + } + } + + rotCands.sort(Comparator.comparingDouble(a -> a[0])); + + for (float[] rc : rotCands) { + float yawTest = unwrapYaw(rc[1], serverYaw); + float pitTest = rc[2]; + + MovingObjectPosition mop = rayTrace(yawTest, pitTest, reachD); + if (mop == null || mop.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK) continue; + if (!mop.getBlockPos().equals(bp)) continue; + if (mop.sideHit == EnumFacing.DOWN) continue; + if (mop.sideHit == EnumFacing.UP && !underPlayer) continue; + + targetBlock = bp; + targetFacing = mop.sideHit; + targetHitVec = mop.hitVec; + lockedBlock = bp; + lockedFacing = mop.sideHit; + lockedAimYaw = yawTest; + lockedAimPitch = pitTest; + aimYaw = yawTest; + aimPitch = pitTest; + return true; + } + + return false; + } + + private void doPlace() { + if (targetBlock == null || targetFacing == null || targetHitVec == null) return; + ItemStack held = mc.thePlayer.inventory.getCurrentItem(); + if (held == null || !(held.getItem() instanceof ItemBlock)) return; + + boolean placed = mc.playerController.onPlayerRightClick(mc.thePlayer, mc.theWorld, held, targetBlock, targetFacing, targetHitVec); + + if (placed) { + if (targetFacing != EnumFacing.UP) clutchBlocksPlaced++; + lastPlacedX = targetBlock.getX(); + lastPlacedY = targetBlock.getY(); + lastPlacedZ = targetBlock.getZ(); + mc.thePlayer.swingItem(); + } + } + + private int findBestBlockSlot() { + int best = -1, bestScore = Integer.MIN_VALUE; + for (int slot = 8; slot >= 0; slot--) { + ItemStack s = mc.thePlayer.inventory.getStackInSlot(slot); + if (s == null || s.stackSize == 0) continue; + if (!(s.getItem() instanceof ItemBlock)) continue; + Block block = ((ItemBlock) s.getItem()).getBlock(); + String name = block.getUnlocalizedName().replace("tile.", "").replace("block.", ""); + Integer score = BLOCK_SCORE.get(name); + if (score == null) { + String lower = name.toLowerCase(); + if (lower.contains("clay")) score = 4; + else if (lower.contains("stone") || lower.contains("brick")) score = 5; + else if (lower.contains("plank") || lower.contains("log")) score = 2; + else if (lower.contains("glass")) score = 3; + else if (lower.contains("wool") || lower.contains("cloth")) score = 5; + else continue; + } + if (score > bestScore) { + bestScore = score; + best = slot; + } + } + return best; + } + + private void restoreSlot() { + if (slotSwapped && lastSlot != -1 && mc.thePlayer != null && mc.thePlayer.inventory.currentItem != lastSlot) { + mc.thePlayer.inventory.currentItem = lastSlot; + } + slotSwapped = false; + } + + private void clearAim() { + if (hasAim) resetting = true; + hasAim = false; + targetBlock = null; + targetFacing = null; + targetHitVec = null; + lockedBlock = null; + lockedFacing = null; + lastPlacedX = lastPlacedY = lastPlacedZ = Integer.MIN_VALUE; + clutchBlocksPlaced = 0; + restoreSlot(); + } + + private float[] smoothStep(float targetYaw, float targetPitch, boolean snapback) { + float curYaw = serverYaw, curPit = serverPitch; + float dYaw = targetYaw - curYaw, dPit = targetPitch - curPit; + + if (Math.abs(dYaw) < 0.1f) curYaw = targetYaw; + if (Math.abs(dPit) < 0.1f) curPit = targetPitch; + if (curYaw == targetYaw && curPit == targetPitch) return new float[]{curYaw, curPit}; + + float maxStep = snapback ? snapbackSpeed.getValue() : speed.getValue(); + maxStep *= (float) (1.0 - Math.random() * 0.2); + + float total = Math.abs(dYaw) + Math.abs(dPit); + if (total <= maxStep) return new float[]{targetYaw, targetPitch}; + + float scale = maxStep / total; + return new float[]{curYaw + dYaw * scale, curPit + dPit * scale}; + } + + private boolean withinTolerance(float yaw, float pitch) { + float dy = Math.abs(MathHelper.wrapAngleTo180_float(yaw - serverYaw)); + float dp = Math.abs(MathHelper.wrapAngleTo180_float(pitch - serverPitch)); + return dy <= rotationTolerance.getValue() && dp <= rotationTolerance.getValue(); + } + + private boolean isUnderPlayer(BlockPos bp, double px, double py, double pz) { + if (bp.getY() >= MathHelper.floor_double(py)) return false; + for (double[] c : CORNERS) { + if (bp.getX() == MathHelper.floor_double(px + c[0]) && bp.getZ() == MathHelper.floor_double(pz + c[1])) + return true; + } + return false; + } + + private boolean isReplaceable(BlockPos pos) { + Block b = mc.theWorld.getBlockState(pos).getBlock(); + return b == Blocks.air || b == Blocks.water || b == Blocks.flowing_water || b == Blocks.lava || b == Blocks.flowing_lava || b == Blocks.fire; + } + + private double dist2AABB(double px, double py, double pz, int bx, int by, int bz) { + double cx = clamp(px, bx, bx + 1); + double cy = clamp(py, by, by + 1); + double cz = clamp(pz, bz, bz + 1); + double dx = px - cx, dy = py - cy, dz = pz - cz; + return dx * dx + dy * dy + dz * dz; + } + + private float[] getRotationsWrapped(Vec3 eye, double tx, double ty, double tz) { + double dx = tx - eye.xCoord, dy = ty - eye.yCoord, dz = tz - eye.zCoord; + double hd = Math.sqrt(dx * dx + dz * dz); + float yaw = normYaw((float) Math.toDegrees(Math.atan2(dz, dx)) - 90f); + float pitch = (float) Math.toDegrees(-Math.atan2(dy, hd)); + return new float[]{yaw, pitch}; + } + + private MovingObjectPosition rayTrace(float yaw, float pitch, double range) { + double yr = Math.toRadians(yaw), pr = Math.toRadians(pitch); + double dirX = -Math.sin(yr) * Math.cos(pr); + double dirY = -Math.sin(pr); + double dirZ = Math.cos(yr) * Math.cos(pr); + Vec3 start = mc.thePlayer.getPositionEyes(1.0f); + Vec3 end = start.addVector(dirX * range, dirY * range, dirZ * range); + return mc.theWorld.rayTraceBlocks(start, end); + } + + private float normYaw(float y) { + y = ((y % 360f) + 360f) % 360f; + return y > 180f ? y - 360f : y; + } + + private float unwrapYaw(float yaw, float prev) { + return prev + ((((yaw - prev + 180f) % 360f) + 360f) % 360f - 180f); + } + + private float angCost(float y, float p, float baseY, float baseP) { + float dy = y - baseY; + while (dy <= -180f) dy += 360f; + while (dy > 180f) dy -= 360f; + return Math.abs(dy) + Math.abs(p - baseP); + } + + private double clamp(double v, double lo, double hi) { + return v < lo ? lo : Math.min(v, hi); + } + + private double randJit() { + return Math.random() * JIT * 2 - JIT; + } + + public int getSlot() { + return lastSlot; + } +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Eagle.java b/src/main/java/myau/module/modules/Eagle.java index dc6c99b9..ad7bafd1 100644 --- a/src/main/java/myau/module/modules/Eagle.java +++ b/src/main/java/myau/module/modules/Eagle.java @@ -23,9 +23,11 @@ public class Eagle extends Module { public final IntProperty minDelay = new IntProperty("min-delay", 2, 0, 10); public final IntProperty maxDelay = new IntProperty("max-delay", 3, 0, 10); public final BooleanProperty directionCheck = new BooleanProperty("direction-check", true); + public final BooleanProperty jumpCheck = new BooleanProperty("jump-check", true); public final BooleanProperty pitchCheck = new BooleanProperty("pitch-check", true); public final BooleanProperty blocksOnly = new BooleanProperty("blocks-only", true); public final BooleanProperty sneakOnly = new BooleanProperty("sneaking-only", false); + public final BooleanProperty rightOnly = new BooleanProperty("right-click-only", false); private boolean canMoveSafely() { double[] offset = MoveUtil.predictMovement(); @@ -35,9 +37,13 @@ private boolean canMoveSafely() { private boolean shouldSneak() { if (this.directionCheck.getValue() && mc.gameSettings.keyBindForward.isKeyDown()) { return false; + } else if (this.jumpCheck.getValue() && mc.gameSettings.keyBindJump.isKeyDown()) { + return false; } else if (this.pitchCheck.getValue() && mc.thePlayer.rotationPitch < 69.0F) { return false; - } else if(sneakOnly.getValue() && !Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode())){ + } else if (sneakOnly.getValue() && !Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode())) { + return false; + } else if (rightOnly.getValue() && !mc.gameSettings.keyBindUseItem.isKeyDown()) { return false; } else { return (!this.blocksOnly.getValue() || ItemUtil.isHoldingBlock()) && mc.thePlayer.onGround; @@ -64,13 +70,13 @@ public void onTick(TickEvent event) { public void onMoveInput(MoveInputEvent event) { if (this.isEnabled() && mc.currentScreen == null) { - if(sneakOnly.getValue() && Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode()) && shouldSneak()){ + if (sneakOnly.getValue() && Keyboard.isKeyDown(mc.gameSettings.keyBindSneak.getKeyCode()) && shouldSneak()) { mc.thePlayer.movementInput.sneak = false; mc.thePlayer.movementInput.moveForward /= 0.3F; mc.thePlayer.movementInput.moveStrafe /= 0.3F; } - if(!mc.thePlayer.movementInput.sneak) { + if (!mc.thePlayer.movementInput.sneak) { if (this.shouldSneak() && (this.sneakDelay > 0 || this.canMoveSafely())) { mc.thePlayer.movementInput.sneak = true; mc.thePlayer.movementInput.moveStrafe *= 0.3F; @@ -106,4 +112,4 @@ public String[] getSuffix() { ? new String[]{this.minDelay.getValue().toString()} : new String[]{String.format("%d-%d", this.minDelay.getValue(), this.maxDelay.getValue())}; } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/FakeLag.java b/src/main/java/myau/module/modules/FakeLag.java new file mode 100644 index 00000000..0a3fb4b3 --- /dev/null +++ b/src/main/java/myau/module/modules/FakeLag.java @@ -0,0 +1,104 @@ +package myau.module.modules; + +import myau.Myau; +import myau.event.EventTarget; +import myau.event.types.EventType; +import myau.events.PacketEvent; +import myau.events.UpdateEvent; +import myau.module.Module; +import myau.property.properties.IntProperty; +import myau.util.PacketUtil; +import net.minecraft.client.Minecraft; +import net.minecraft.network.Packet; + +import java.util.concurrent.ConcurrentLinkedQueue; + +public class FakeLag extends Module { + + private static final Minecraft mc = Minecraft.getMinecraft(); + + public final IntProperty delay = new IntProperty("delay-ms", 200, 50, 5000); + + private final ConcurrentLinkedQueue packetQueue = new ConcurrentLinkedQueue<>(); + private boolean isDispatching = false; + + public FakeLag() { + super("FakeLag", false); + } + + @Override + public void onEnabled() { + packetQueue.clear(); + this.isDispatching = false; + } + + @Override + public void onDisabled() { + this.isDispatching = true; + while (!packetQueue.isEmpty()) { + PacketUtil.sendPacket(packetQueue.poll().packet); + } + this.isDispatching = false; + } + + @EventTarget + public void onPacket(PacketEvent event) { + if(!this.enabled) return; + if (event.getType() == EventType.SEND) { + if (this.isDispatching) { + return; + } + + if (mc.thePlayer == null || mc.theWorld == null) { + return; + } + + Packet packet = event.getPacket(); + + event.setCancelled(true); + + packetQueue.add(new PacketData(packet, System.currentTimeMillis())); + } + } + + @EventTarget + public void onUpdate(UpdateEvent event) { + if (event.getType() == EventType.PRE) { + if (mc.thePlayer == null) return; + + long currentTime = System.currentTimeMillis(); + long delayTime = this.delay.getValue(); + + if (packetQueue.isEmpty()) return; + + while (!packetQueue.isEmpty()) { + PacketData data = packetQueue.peek(); + + if (currentTime - data.timestamp >= delayTime) { + packetQueue.poll(); + + this.isDispatching = true; + PacketUtil.sendPacket(data.packet); + this.isDispatching = false; + } else { + break; + } + } + } + } + + private static class PacketData { + private final Packet packet; + private final long timestamp; + + public PacketData(Packet packet, long timestamp) { + this.packet = packet; + this.timestamp = timestamp; + } + } + + @Override + public String[] getSuffix() { + return new String[]{String.format("%dms", this.delay.getValue())}; + } +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Freeze.java b/src/main/java/myau/module/modules/Freeze.java index 7a9002c8..81b64f29 100644 --- a/src/main/java/myau/module/modules/Freeze.java +++ b/src/main/java/myau/module/modules/Freeze.java @@ -16,6 +16,7 @@ import net.minecraft.client.gui.ScaledResolution; import net.minecraft.network.Packet; import net.minecraft.network.play.INetHandlerPlayClient; +import net.minecraft.network.play.client.C03PacketPlayer; import net.minecraft.network.play.server.S08PacketPlayerPosLook; import net.minecraft.network.play.server.S12PacketEntityVelocity; import net.minecraft.network.play.server.S19PacketEntityStatus; @@ -43,9 +44,13 @@ public Freeze() { super("Freeze", false); } + public void ignoreNextVelocity() { + + } + @EventTarget(Priority.HIGHEST) public void onPacket(PacketEvent event) { - if (!this.isEnabled() || event.getType() != EventType.RECEIVE || event.isCancelled()) { + if (!this.isEnabled() || event.isCancelled()) { return; } @@ -55,36 +60,41 @@ public void onPacket(PacketEvent event) { Packet packet = event.getPacket(); - // Check for S08 flag (teleport packet) + if (event.getType() == EventType.SEND && this.delaying && packet instanceof C03PacketPlayer) { + C03PacketPlayer c03 = (C03PacketPlayer) packet; + if (c03.getRotating()) { + return; + } + } + + if (event.getType() != EventType.RECEIVE) { + return; + } + if (!this.delaying && packet instanceof S08PacketPlayerPosLook) { this.s08 = true; } - // Check for velocity packet targeting player if (packet instanceof S12PacketEntityVelocity) { S12PacketEntityVelocity s12 = (S12PacketEntityVelocity) packet; if (s12.getEntityID() == mc.thePlayer.getEntityId()) { - // Ignore velocity right after teleport if (this.s08) { this.s08 = false; return; } - // Start delaying this.delaying = true; } } - // Check for damage (entity status packet with hurt animation) if (packet instanceof S19PacketEntityStatus) { S19PacketEntityStatus s19 = (S19PacketEntityStatus) packet; if (s19.getEntity(mc.theWorld) != null && s19.getEntity(mc.theWorld).equals(mc.thePlayer) && - s19.getOpCode() == 2) { // OpCode 2 = hurt animation + s19.getOpCode() == 2) { this.delaying = true; } } - // Buffer relevant packets when delaying if (this.delaying && (packet instanceof S12PacketEntityVelocity || packet instanceof S32PacketConfirmTransaction || packet instanceof S08PacketPlayerPosLook)) { @@ -106,13 +116,11 @@ public void onTick(TickEvent event) { } if (event.getType() == EventType.POST) { - // Check timeout if (this.delaying && ++this.timeout >= this.maxTimeout.getValue()) { this.flush(); ChatUtil.sendFormatted(Myau.clientName + "&cFreeze timed out."); } - // Reset S08 flag this.s08 = false; } } diff --git a/src/main/java/myau/module/modules/InvManager.java b/src/main/java/myau/module/modules/InvManager.java index 12cdec67..aa442edf 100644 --- a/src/main/java/myau/module/modules/InvManager.java +++ b/src/main/java/myau/module/modules/InvManager.java @@ -104,26 +104,32 @@ public void onUpdate(UpdateEvent event) { } int preferredSwordHotbarSlot = this.swordSlot.getValue() - 1; int inventorySwordSlot = ItemUtil.findSwordInInventorySlot(preferredSwordHotbarSlot, this.checkDurability.getValue()); - if (inventorySwordSlot == -1) inventorySwordSlot = ItemUtil.findSwordInInventorySlot(preferredSwordHotbarSlot, false); + if (inventorySwordSlot == -1) + inventorySwordSlot = ItemUtil.findSwordInInventorySlot(preferredSwordHotbarSlot, false); int preferredPickaxeHotbarSlot = this.pickaxeSlot.getValue() - 1; int inventoryPickaxeSlot = ItemUtil.findInventorySlot("pickaxe", preferredPickaxeHotbarSlot, this.checkDurability.getValue()); - if (inventoryPickaxeSlot == -1) inventoryPickaxeSlot = ItemUtil.findInventorySlot("pickaxe", preferredPickaxeHotbarSlot, false); + if (inventoryPickaxeSlot == -1) + inventoryPickaxeSlot = ItemUtil.findInventorySlot("pickaxe", preferredPickaxeHotbarSlot, false); int preferredShovelHotbarSlot = this.shovelSlot.getValue() - 1; int inventoryShovelSlot = ItemUtil.findInventorySlot("shovel", preferredShovelHotbarSlot, this.checkDurability.getValue()); - if (inventoryShovelSlot == -1) inventoryShovelSlot = ItemUtil.findInventorySlot("shovel", preferredShovelHotbarSlot, false); + if (inventoryShovelSlot == -1) + inventoryShovelSlot = ItemUtil.findInventorySlot("shovel", preferredShovelHotbarSlot, false); int preferredAxeHotbarSlot = this.axeSlot.getValue() - 1; int inventoryAxeSlot = ItemUtil.findInventorySlot("axe", preferredAxeHotbarSlot, this.checkDurability.getValue()); - if (inventoryAxeSlot == -1) inventoryAxeSlot = ItemUtil.findInventorySlot("axe", preferredAxeHotbarSlot, false); + if (inventoryAxeSlot == -1) + inventoryAxeSlot = ItemUtil.findInventorySlot("axe", preferredAxeHotbarSlot, false); int preferredBlocksHotbarSlot = this.blocksSlot.getValue() - 1; int inventoryBlocksSlot = ItemUtil.findInventorySlot(preferredBlocksHotbarSlot, ItemUtil.ItemType.Block); int preferredProjectileHotbarSlot = this.projectileSlot.getValue() - 1; int inventoryProjectileSlot = ItemUtil.findInventorySlot(preferredProjectileHotbarSlot, ItemUtil.ItemType.Projectile); - if (inventoryProjectileSlot == -1) inventoryProjectileSlot = ItemUtil.findInventorySlot(preferredProjectileHotbarSlot, ItemUtil.ItemType.FishRod); + if (inventoryProjectileSlot == -1) + inventoryProjectileSlot = ItemUtil.findInventorySlot(preferredProjectileHotbarSlot, ItemUtil.ItemType.FishRod); int preferredGoldAppleHotbarSlot = this.goldAppleSlot.getValue() - 1; int inventoryGoldAppleSlot = ItemUtil.findInventorySlot(preferredGoldAppleHotbarSlot, ItemUtil.ItemType.GoldApple); int preferredBowHotbarSlot = this.bowSlot.getValue() - 1; int inventoryBowSlot = ItemUtil.findBowInventorySlot(preferredBowHotbarSlot, this.checkDurability.getValue()); - if (inventoryBowSlot == -1) inventoryBowSlot = ItemUtil.findBowInventorySlot(preferredBowHotbarSlot, false); + if (inventoryBowSlot == -1) + inventoryBowSlot = ItemUtil.findBowInventorySlot(preferredBowHotbarSlot, false); if (this.autoArmor.getValue() && this.autoArmorTime.hasTimeElapsed(this.autoArmorInterval.getValue() * 50L)) { for (int i = 0; i < 4; i++) { int equippedSlot = equippedArmorSlots.get(i); @@ -228,7 +234,9 @@ public void onUpdate(UpdateEvent event) { if (isProjectile) { currentProjectileCount += stack.stackSize; } - if (ItemUtil.isNotSpecialItem(stack) &&( isBlock && currentBlockCount >= this.blocks.getValue() || isProjectile && currentProjectileCount >= this.projectiles.getValue())) { + if (isBlock ? currentBlockCount > this.blocks.getValue() : + isProjectile ? currentProjectileCount > this.projectiles.getValue() : + ItemUtil.isNotSpecialItem(stack)) { this.clickSlot(mc.thePlayer.inventoryContainer.windowId, this.convertSlotIndex(i), 1, 4); return; } @@ -261,4 +269,4 @@ public void verifyValue(String mode) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/KillAura.java b/src/main/java/myau/module/modules/KillAura.java index a6c7a3c0..5e866258 100644 --- a/src/main/java/myau/module/modules/KillAura.java +++ b/src/main/java/myau/module/modules/KillAura.java @@ -1,1026 +1,1069 @@ -package myau.module.modules; - -import com.google.common.base.CaseFormat; -import myau.Myau; -import myau.enums.BlinkModules; -import myau.event.EventManager; -import myau.event.EventTarget; -import myau.event.types.EventType; -import myau.event.types.Priority; -import myau.events.*; -import myau.management.RotationState; -import myau.mixin.IAccessorPlayerControllerMP; -import myau.module.Module; -import myau.property.properties.*; -import myau.util.*; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.DataWatcher.WatchableObject; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.boss.EntityDragon; -import net.minecraft.entity.boss.EntityWither; -import net.minecraft.entity.monster.EntityIronGolem; -import net.minecraft.entity.monster.EntityMob; -import net.minecraft.entity.monster.EntitySilverfish; -import net.minecraft.entity.monster.EntitySlime; -import net.minecraft.entity.passive.EntityAnimal; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.entity.passive.EntitySquid; -import net.minecraft.entity.passive.EntityVillager; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemSword; -import net.minecraft.network.play.client.C02PacketUseEntity; -import net.minecraft.network.play.client.C02PacketUseEntity.Action; -import net.minecraft.network.play.client.C07PacketPlayerDigging; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; -import net.minecraft.network.play.client.C09PacketHeldItemChange; -import net.minecraft.network.play.server.S06PacketUpdateHealth; -import net.minecraft.network.play.server.S1CPacketEntityMetadata; -import net.minecraft.util.*; -import net.minecraft.util.MovingObjectPosition.MovingObjectType; -import net.minecraft.world.WorldSettings.GameType; - -import java.awt.*; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.ArrayList; -import java.util.Locale; -import java.util.Random; - -public class KillAura extends Module { - private static final Minecraft mc = Minecraft.getMinecraft(); - private static final DecimalFormat df = new DecimalFormat("+0.0;-0.0", new DecimalFormatSymbols(Locale.US)); - private final TimerUtil timer = new TimerUtil(); - private AttackData target = null; - private int switchTick = 0; - private boolean hitRegistered = false; - private boolean blockingState = false; - private boolean isBlocking = false; - private boolean fakeBlockState = false; - private boolean blinkReset = false; - private long attackDelayMS = 0L; - private int blockTick = 0; - private int lastTickProcessed; - public final ModeProperty mode; - public final ModeProperty sort; - public final ModeProperty autoBlock; - public final BooleanProperty autoBlockRequirePress; - public final FloatProperty autoBlockMinCPS; - public final FloatProperty autoBlockMaxCPS; - public final FloatProperty autoBlockRange; - public final FloatProperty swingRange; - public final FloatProperty attackRange; - public final IntProperty fov; - public final IntProperty minCPS; - public final IntProperty maxCPS; - public final IntProperty switchDelay; - public final ModeProperty rotations; - public final ModeProperty moveFix; - public final PercentProperty smoothing; - public final IntProperty angleStep; - public final BooleanProperty throughWalls; - public final BooleanProperty requirePress; - public final BooleanProperty allowMining; - public final BooleanProperty weaponsOnly; - public final BooleanProperty allowTools; - public final BooleanProperty inventoryCheck; - public final BooleanProperty botCheck; - public final BooleanProperty players; - public final BooleanProperty bosses; - public final BooleanProperty mobs; - public final BooleanProperty animals; - public final BooleanProperty golems; - public final BooleanProperty silverfish; - public final BooleanProperty teams; - public final ModeProperty showTarget; - public final ModeProperty debugLog; - - private long getAttackDelay() { - return this.isBlocking ? (long) (1000.0F / RandomUtil.nextLong(this.autoBlockMinCPS.getValue().longValue(), this.autoBlockMaxCPS.getValue().longValue())) : 1000L / RandomUtil.nextLong(this.minCPS.getValue(), this.maxCPS.getValue()); - } - - private boolean performAttack(float yaw, float pitch) { - if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - if (this.isPlayerBlocking() && this.autoBlock.getValue() != 1) { - return false; - } else if (this.attackDelayMS > 0L) { - return false; - } else { - this.attackDelayMS = this.attackDelayMS + this.getAttackDelay(); - mc.thePlayer.swingItem(); - if ((this.rotations.getValue() != 0 || !this.isBoxInAttackRange(this.target.getBox())) - && RotationUtil.rayTrace(this.target.getBox(), yaw, pitch, this.attackRange.getValue()) == null) { - return false; - } else { - AttackEvent event = new AttackEvent(this.target.getEntity()); - EventManager.call(event); - ((IAccessorPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); - PacketUtil.sendPacket(new C02PacketUseEntity(this.target.getEntity(), Action.ATTACK)); - if (mc.playerController.getCurrentGameType() != GameType.SPECTATOR) { - PlayerUtil.attackEntity(this.target.getEntity()); - } - this.hitRegistered = true; - return true; - } - } - } else { - return false; - } - } - - private void sendUseItem() { - ((IAccessorPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); - this.startBlock(mc.thePlayer.getHeldItem()); - } - - private void startBlock(ItemStack itemStack) { - PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(itemStack)); - mc.thePlayer.setItemInUse(itemStack, itemStack.getMaxItemUseDuration()); - this.blockingState = true; - } - - private void stopBlock() { - PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN)); - mc.thePlayer.stopUsingItem(); - this.blockingState = false; - } - - private void interactAttack(float yaw, float pitch) { - if (this.target != null) { - MovingObjectPosition mop = RotationUtil.rayTrace(this.target.getBox(), yaw, pitch, 8.0); - if (mop != null) { - ((IAccessorPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); - PacketUtil.sendPacket( - new C02PacketUseEntity( - this.target.getEntity(), - new Vec3(mop.hitVec.xCoord - this.target.getX(), mop.hitVec.yCoord - this.target.getY(), mop.hitVec.zCoord - this.target.getZ()) - ) - ); - PacketUtil.sendPacket(new C02PacketUseEntity(this.target.getEntity(), Action.INTERACT)); - PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())); - mc.thePlayer.setItemInUse(mc.thePlayer.getHeldItem(), mc.thePlayer.getHeldItem().getMaxItemUseDuration()); - this.blockingState = true; - } - } - } - - private boolean canAttack() { - if (this.inventoryCheck.getValue() && mc.currentScreen instanceof GuiContainer) { - return false; - } else if (!(Boolean) this.weaponsOnly.getValue() - || ItemUtil.hasRawUnbreakingEnchant() - || this.allowTools.getValue() && ItemUtil.isHoldingTool()) { - if (((IAccessorPlayerControllerMP) mc.playerController).getIsHittingBlock()) { - return false; - } else if ((ItemUtil.isEating() || ItemUtil.isUsingBow()) && PlayerUtil.isUsingItem()) { - return false; - } else { - AutoHeal autoHeal = (AutoHeal) Myau.moduleManager.modules.get(AutoHeal.class); - if (autoHeal.isEnabled() && autoHeal.isSwitching()) { - return false; - } else { - BedNuker bedNuker = (BedNuker) Myau.moduleManager.modules.get(BedNuker.class); - AutoBlockIn autoBlockIn = (AutoBlockIn) Myau.moduleManager.modules.get(AutoBlockIn.class); - if (bedNuker.isEnabled() && bedNuker.isReady()) { - return false; - } else if (Myau.moduleManager.modules.get(Scaffold.class).isEnabled()) { - return false; - } else if (autoBlockIn.isEnabled()) { - return false; - } else if (this.requirePress.getValue()) { - return PlayerUtil.isAttacking(); - } else { - return !this.allowMining.getValue() || !mc.objectMouseOver.typeOfHit.equals(MovingObjectType.BLOCK) || !PlayerUtil.isAttacking(); - } - } - } - } else { - return false; - } - } - - private boolean canAutoBlock() { - if (!ItemUtil.isHoldingSword()) { - return false; - } else { - return !this.autoBlockRequirePress.getValue() || PlayerUtil.isUsingItem(); - } - } - - private boolean hasValidTarget() { - return mc.theWorld - .loadedEntityList - .stream() - .anyMatch( - entity -> entity instanceof EntityLivingBase - && this.isValidTarget((EntityLivingBase) entity) - && this.isInBlockRange((EntityLivingBase) entity) - ); - } - - private boolean isValidTarget(EntityLivingBase entityLivingBase) { - if (!mc.theWorld.loadedEntityList.contains(entityLivingBase)) { - return false; - } else if (entityLivingBase != mc.thePlayer && entityLivingBase != mc.thePlayer.ridingEntity) { - if (entityLivingBase == mc.getRenderViewEntity() || entityLivingBase == mc.getRenderViewEntity().ridingEntity) { - return false; - } else if (entityLivingBase.deathTime > 0) { - return false; - } else if (RotationUtil.angleToEntity(entityLivingBase) > this.fov.getValue().floatValue()) { - return false; - } else if (!this.throughWalls.getValue() && RotationUtil.rayTrace(entityLivingBase) != null) { - return false; - } else if (entityLivingBase instanceof EntityOtherPlayerMP) { - if (!this.players.getValue()) { - return false; - } else if (TeamUtil.isFriend((EntityPlayer) entityLivingBase)) { - return false; - } else { - return (!this.teams.getValue() || !TeamUtil.isSameTeam((EntityPlayer) entityLivingBase)) && (!this.botCheck.getValue() || !TeamUtil.isBot((EntityPlayer) entityLivingBase)); - } - } else if (entityLivingBase instanceof EntityDragon || entityLivingBase instanceof EntityWither) { - return this.bosses.getValue(); - } else if (!(entityLivingBase instanceof EntityMob) && !(entityLivingBase instanceof EntitySlime)) { - if (entityLivingBase instanceof EntityAnimal - || entityLivingBase instanceof EntityBat - || entityLivingBase instanceof EntitySquid - || entityLivingBase instanceof EntityVillager) { - return this.animals.getValue(); - } else if (!(entityLivingBase instanceof EntityIronGolem)) { - return false; - } else { - return this.golems.getValue() && (!this.teams.getValue() || !TeamUtil.hasTeamColor(entityLivingBase)); - } - } else if (!(entityLivingBase instanceof EntitySilverfish)) { - return this.mobs.getValue(); - } else { - return this.silverfish.getValue() && (!this.teams.getValue() || !TeamUtil.hasTeamColor(entityLivingBase)); - } - } else { - return false; - } - } - - private boolean isInRange(EntityLivingBase entityLivingBase) { - return this.isInBlockRange(entityLivingBase) || this.isInSwingRange(entityLivingBase) || this.isInAttackRange(entityLivingBase); - } - - private boolean isInBlockRange(EntityLivingBase entityLivingBase) { - return RotationUtil.distanceToEntity(entityLivingBase) <= (double) this.autoBlockRange.getValue(); - } - - private boolean isInSwingRange(EntityLivingBase entityLivingBase) { - return RotationUtil.distanceToEntity(entityLivingBase) <= (double) this.swingRange.getValue(); - } - - private boolean isBoxInSwingRange(AxisAlignedBB axisAlignedBB) { - return RotationUtil.distanceToBox(axisAlignedBB) <= (double) this.swingRange.getValue(); - } - - private boolean isInAttackRange(EntityLivingBase entityLivingBase) { - return RotationUtil.distanceToEntity(entityLivingBase) <= (double) this.attackRange.getValue(); - } - - private boolean isBoxInAttackRange(AxisAlignedBB axisAlignedBB) { - return RotationUtil.distanceToBox(axisAlignedBB) <= (double) this.attackRange.getValue(); - } - - private boolean isPlayerTarget(EntityLivingBase entityLivingBase) { - return entityLivingBase instanceof EntityPlayer && TeamUtil.isTarget((EntityPlayer) entityLivingBase); - } - - private int findEmptySlot(int currentSlot) { - for (int i = 0; i < 9; i++) { - if (i != currentSlot && mc.thePlayer.inventory.getStackInSlot(i) == null) { - return i; - } - } - for (int i = 0; i < 9; i++) { - if (i != currentSlot) { - ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); - if (stack != null && !stack.hasDisplayName()) { - return i; - } - } - } - return Math.floorMod(currentSlot - 1, 9); - } - - private int findSwordSlot(int currentSlot) { - for (int i = 0; i < 9; i++) { - if (i != currentSlot) { - ItemStack item = mc.thePlayer.inventory.getStackInSlot(i); - if (item != null && item.getItem() instanceof ItemSword) { - return i; - } - } - } - return -1; - } - - public KillAura() { - super("KillAura", false); - this.lastTickProcessed = 0; - this.mode = new ModeProperty("mode", 0, new String[]{"SINGLE", "SWITCH"}); - this.sort = new ModeProperty("sort", 0, new String[]{"DISTANCE", "HEALTH", "HURT_TIME", "FOV"}); - this.autoBlock = new ModeProperty( - "auto-block", 2, new String[]{"NONE", "VANILLA", "SPOOF", "HYPIXEL", "BLINK", "INTERACT", "SWAP", "LEGIT", "FAKE"} - ); - this.autoBlockRequirePress = new BooleanProperty("auto-block-require-press", false); - this.autoBlockMinCPS = new FloatProperty("auto-block-min-aps", 8.0F, 1.0F, 20.0F); - this.autoBlockMaxCPS = new FloatProperty("auto-block-max-aps", 10.0F, 1.0F, 20.0F); - this.autoBlockRange = new FloatProperty("auto-block-range", 6.0F, 3.0F, 8.0F); - this.swingRange = new FloatProperty("swing-range", 3.5F, 3.0F, 6.0F); - this.attackRange = new FloatProperty("attack-range", 3.0F, 3.0F, 6.0F); - this.fov = new IntProperty("fov", 360, 30, 360); - this.minCPS = new IntProperty("min-aps", 14, 1, 20); - this.maxCPS = new IntProperty("max-aps", 14, 1, 20); - this.switchDelay = new IntProperty("switch-delay", 150, 0, 1000); - this.rotations = new ModeProperty("rotations", 2, new String[]{"NONE", "LEGIT", "SILENT", "LOCK_VIEW"}); - this.moveFix = new ModeProperty("move-fix", 1, new String[]{"NONE", "SILENT", "STRICT"}); - this.smoothing = new PercentProperty("smoothing", 0); - this.angleStep = new IntProperty("angle-step", 90, 30, 180); - this.throughWalls = new BooleanProperty("through-walls", true); - this.requirePress = new BooleanProperty("require-press", false); - this.allowMining = new BooleanProperty("allow-mining", true); - this.weaponsOnly = new BooleanProperty("weapons-only", true); - this.allowTools = new BooleanProperty("allow-tools", false, this.weaponsOnly::getValue); - this.inventoryCheck = new BooleanProperty("inventory-check", true); - this.botCheck = new BooleanProperty("bot-check", true); - this.players = new BooleanProperty("players", true); - this.bosses = new BooleanProperty("bosses", false); - this.mobs = new BooleanProperty("mobs", false); - this.animals = new BooleanProperty("animals", false); - this.golems = new BooleanProperty("golems", false); - this.silverfish = new BooleanProperty("silverfish", false); - this.teams = new BooleanProperty("teams", true); - this.showTarget = new ModeProperty("show-target", 0, new String[]{"NONE", "DEFAULT", "HUD"}); - this.debugLog = new ModeProperty("debug-log", 0, new String[]{"NONE", "HEALTH"}); - } - - public EntityLivingBase getTarget() { - return this.target != null ? this.target.getEntity() : null; - } - - public boolean isAttackAllowed() { - Scaffold scaffold = (Scaffold) Myau.moduleManager.modules.get(Scaffold.class); - if (scaffold.isEnabled()) { - return false; - } else if (!this.weaponsOnly.getValue() - || ItemUtil.hasRawUnbreakingEnchant() - || this.allowTools.getValue() && ItemUtil.isHoldingTool()) { - return !this.requirePress.getValue() || KeyBindUtil.isKeyDown(mc.gameSettings.keyBindAttack.getKeyCode()); - } else { - return false; - } - } - - public boolean shouldAutoBlock() { - if (this.isPlayerBlocking() && this.isBlocking) { - return !mc.thePlayer.isInWater() && !mc.thePlayer.isInLava() && (this.autoBlock.getValue() == 3 // HYPIXEL - || this.autoBlock.getValue() == 4 // BLINK - || this.autoBlock.getValue() == 5 // INTERACT - || this.autoBlock.getValue() == 6 // SWAP - || this.autoBlock.getValue() == 7); // LEGIT - } else { - return false; - } - } - - public boolean isBlocking() { - return this.fakeBlockState && ItemUtil.isHoldingSword(); - } - - public boolean isPlayerBlocking() { - return (mc.thePlayer.isUsingItem() || this.blockingState) && ItemUtil.isHoldingSword(); - } - - @EventTarget(Priority.LOW) - public void onUpdate(UpdateEvent event) { - if (event.getType() == EventType.POST && this.blinkReset) { - this.blinkReset = false; - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - Myau.blinkManager.setBlinkState(true, BlinkModules.AUTO_BLOCK); - } - if (this.isEnabled() && event.getType() == EventType.PRE) { - if (this.attackDelayMS > 0L) { - this.attackDelayMS -= 50L; - } - boolean attack = this.target != null && this.canAttack(); - boolean block = attack && this.canAutoBlock(); - if (!block) { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - this.blockTick = 0; - } - if (attack) { - boolean swap = false; - boolean blocked = false; - if (block) { - switch (this.autoBlock.getValue()) { - case 0: // NONE - if (PlayerUtil.isUsingItem()) { - this.isBlocking = true; - if (!this.isPlayerBlocking() && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - swap = true; - } - } else { - this.isBlocking = false; - if (this.isPlayerBlocking() && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - this.stopBlock(); - } - } - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.fakeBlockState = false; - break; - case 1: // VANILLA - if (this.hasValidTarget()) { - if (!this.isPlayerBlocking() && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - swap = true; - } - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = true; - this.fakeBlockState = false; - } else { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - } - break; - case 2: // SPOOF - if (this.hasValidTarget()) { - int item = ((IAccessorPlayerControllerMP) mc.playerController).getCurrentPlayerItem(); - if (Myau.playerStateManager.digging - || Myau.playerStateManager.placing - || mc.thePlayer.inventory.currentItem != item - || this.isPlayerBlocking() && this.blockTick != 0 - || this.attackDelayMS > 0L && this.attackDelayMS <= 50L) { - this.blockTick = 0; - } else { - int slot = this.findEmptySlot(item); - PacketUtil.sendPacket(new C09PacketHeldItemChange(slot)); - PacketUtil.sendPacket(new C09PacketHeldItemChange(item)); - swap = true; - this.blockTick = 1; - } - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = true; - this.fakeBlockState = false; - } else { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - } - break; - case 3: // HYPIXEL - if (this.hasValidTarget()) { - if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - switch (this.blockTick) { - case 0: - if (!this.isPlayerBlocking()) { - swap = true; - } - blocked = true; - this.blockTick = 1; - break; - case 1: - if (this.isPlayerBlocking()) { - if(Myau.moduleManager.modules.get(NoSlow.class).isEnabled()){ - int randomSlot = new Random().nextInt(9); - while (randomSlot == mc.thePlayer.inventory.currentItem) { - randomSlot = new Random().nextInt(9); - } - PacketUtil.sendPacket(new C09PacketHeldItemChange(randomSlot)); - PacketUtil.sendPacket(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); - } - this.stopBlock(); - attack = false; - } - if (this.attackDelayMS <= 50L) { - this.blockTick = 0; - } - break; - default: - this.blockTick = 0; - } - } - this.isBlocking = true; - this.fakeBlockState = true; - } else { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - } - break; - case 4: // BLINK - if (this.hasValidTarget()) { - if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - switch (this.blockTick) { - case 0: - if (!this.isPlayerBlocking()) { - swap = true; - } - this.blinkReset = true; - this.blockTick = 1; - break; - case 1: - if (this.isPlayerBlocking()) { - this.stopBlock(); - attack = false; - } - if (this.attackDelayMS <= 50L) { - this.blockTick = 0; - } - break; - default: - this.blockTick = 0; - } - } - this.isBlocking = true; - this.fakeBlockState = true; - } else { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - } - break; - case 5: // INTERACT - if (this.hasValidTarget()) { - int item = ((IAccessorPlayerControllerMP) mc.playerController).getCurrentPlayerItem(); - if (mc.thePlayer.inventory.currentItem == item && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - switch (this.blockTick) { - case 0: - if (!this.isPlayerBlocking()) { - swap = true; - } - this.blinkReset = true; - this.blockTick = 1; - break; - case 1: - if (this.isPlayerBlocking()) { - int slot = this.findEmptySlot(item); - PacketUtil.sendPacket(new C09PacketHeldItemChange(slot)); - ((IAccessorPlayerControllerMP) mc.playerController).setCurrentPlayerItem(slot); - attack = false; - } - if (this.attackDelayMS <= 50L) { - this.blockTick = 0; - } - break; - default: - this.blockTick = 0; - } - } - this.isBlocking = true; - this.fakeBlockState = true; - } else { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - } - break; - case 6: // SWAP - if (this.hasValidTarget()) { - int item = ((IAccessorPlayerControllerMP) mc.playerController).getCurrentPlayerItem(); - if (mc.thePlayer.inventory.currentItem == item && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - switch (this.blockTick) { - case 0: - int slot = this.findSwordSlot(item); - if (slot != -1) { - if (!this.isPlayerBlocking()) { - swap = true; - } - this.blockTick = 1; - } - break; - case 1: - int swordsSlot = this.findSwordSlot(item); - if (swordsSlot == -1) { - this.blockTick = 0; - } else if (!this.isPlayerBlocking()) { - swap = true; - } else if (this.attackDelayMS <= 50L) { - PacketUtil.sendPacket(new C09PacketHeldItemChange(swordsSlot)); - ((IAccessorPlayerControllerMP) mc.playerController).setCurrentPlayerItem(swordsSlot); - this.startBlock(mc.thePlayer.inventory.getStackInSlot(swordsSlot)); - attack = false; - this.blockTick = 0; - } - break; - default: - this.blockTick = 0; - } - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = true; - this.fakeBlockState = true; - break; - } - } - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - break; - case 7: // LEGIT - if (this.hasValidTarget()) { - if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { - switch (this.blockTick) { - case 0: - if (!this.isPlayerBlocking()) { - swap = true; - } - this.blockTick = 1; - break; - case 1: - if (this.isPlayerBlocking()) { - this.stopBlock(); - attack = false; - } - if (this.attackDelayMS <= 50L) { - this.blockTick = 0; - } - break; - default: - this.blockTick = 0; - } - } - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = true; - this.fakeBlockState = false; - } else { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = false; - } - break; - case 8: // FAKE - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.isBlocking = false; - this.fakeBlockState = this.hasValidTarget(); - if (PlayerUtil.isUsingItem() - && !this.isPlayerBlocking() - && !Myau.playerStateManager.digging - && !Myau.playerStateManager.placing) { - swap = true; - } - } - } - boolean attacked = false; - if (this.isBoxInSwingRange(this.target.getBox())) { - if (this.rotations.getValue() == 2 || this.rotations.getValue() == 3) { - float[] rotations = RotationUtil.getRotationsToBox( - this.target.getBox(), - event.getYaw(), - event.getPitch(), - (float) this.angleStep.getValue() + RandomUtil.nextFloat(-5.0F, 5.0F), - (float) this.smoothing.getValue() / 100.0F - ); - event.setRotation(rotations[0], rotations[1], 1); - if (this.rotations.getValue() == 3) { - Myau.rotationManager.setRotation(rotations[0], rotations[1], 1, true); - } - if (this.moveFix.getValue() != 0 || this.rotations.getValue() == 3) { - event.setPervRotation(rotations[0], 1); - } - } - if (attack) { - attacked = this.performAttack(event.getNewYaw(), event.getNewPitch()); - } - } - if (swap) { - if (attacked) { - this.interactAttack(event.getNewYaw(), event.getNewPitch()); - } else { - this.sendUseItem(); - } - } - if (blocked) { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - Myau.blinkManager.setBlinkState(true, BlinkModules.AUTO_BLOCK); - } - } - } - } - - @EventTarget - public void onTick(TickEvent event) { - if (this.isEnabled()) { - switch (event.getType()) { - case PRE: - if (this.target == null - || !this.isValidTarget(this.target.getEntity()) - || !this.isBoxInAttackRange(this.target.getBox()) - || !this.isBoxInSwingRange(this.target.getBox()) - || this.timer.hasTimeElapsed(this.switchDelay.getValue().longValue())) { - this.timer.reset(); - ArrayList targets = new ArrayList<>(); - for (Entity entity : mc.theWorld.loadedEntityList) { - if (entity instanceof EntityLivingBase - && this.isValidTarget((EntityLivingBase) entity) - && this.isInRange((EntityLivingBase) entity)) { - targets.add((EntityLivingBase) entity); - } - } - if (targets.isEmpty()) { - this.target = null; - } else { - if (targets.stream().anyMatch(this::isInSwingRange)) { - targets.removeIf(entityLivingBase -> !this.isInSwingRange(entityLivingBase)); - } - if (targets.stream().anyMatch(this::isInAttackRange)) { - targets.removeIf(entityLivingBase -> !this.isInAttackRange(entityLivingBase)); - } - if (targets.stream().anyMatch(this::isPlayerTarget)) { - targets.removeIf(entityLivingBase -> !this.isPlayerTarget(entityLivingBase)); - } - targets.sort( - (entityLivingBase1, entityLivingBase2) -> { - int sortBase = 0; - switch (this.sort.getValue()) { - case 1: - sortBase = Float.compare(TeamUtil.getHealthScore(entityLivingBase1), TeamUtil.getHealthScore(entityLivingBase2)); - break; - case 2: - sortBase = Integer.compare(entityLivingBase1.hurtResistantTime, entityLivingBase2.hurtResistantTime); - break; - case 3: - sortBase = Float.compare( - RotationUtil.angleToEntity(entityLivingBase1), - RotationUtil.angleToEntity(entityLivingBase2) - ); - } - return sortBase != 0 - ? sortBase - : Double.compare(RotationUtil.distanceToEntity(entityLivingBase1), RotationUtil.distanceToEntity(entityLivingBase2)); - } - ); - if (this.mode.getValue() == 1 && this.hitRegistered) { - this.hitRegistered = false; - this.switchTick++; - } - if (this.mode.getValue() == 0 || this.switchTick >= targets.size()) { - this.switchTick = 0; - } - this.target = new AttackData(targets.get(this.switchTick)); - } - } - if (this.target != null) { - this.target = new AttackData(this.target.getEntity()); - } - break; - case POST: - if (this.isPlayerBlocking() && !mc.thePlayer.isBlocking()) { - mc.thePlayer.setItemInUse(mc.thePlayer.getHeldItem(), mc.thePlayer.getHeldItem().getMaxItemUseDuration()); - } - } - } - } - - @EventTarget(Priority.LOWEST) - public void onPacket(PacketEvent event) { - if (this.isEnabled() && !event.isCancelled() && mc.thePlayer != null && mc.theWorld != null) { - if (event.getPacket() instanceof C07PacketPlayerDigging) { - C07PacketPlayerDigging packet = (C07PacketPlayerDigging) event.getPacket(); - if (packet.getStatus() == C07PacketPlayerDigging.Action.RELEASE_USE_ITEM) { - this.blockingState = false; - } - } - if (event.getPacket() instanceof C09PacketHeldItemChange) { - this.blockingState = false; - if (this.isBlocking) { - mc.thePlayer.stopUsingItem(); - } - } - if (this.debugLog.getValue() == 1 && this.isAttackAllowed()) { - if (event.getPacket() instanceof S06PacketUpdateHealth) { - float packet = ((S06PacketUpdateHealth) event.getPacket()).getHealth() - mc.thePlayer.getHealth(); - if (packet != 0.0F && this.lastTickProcessed != mc.thePlayer.ticksExisted) { - this.lastTickProcessed = mc.thePlayer.ticksExisted; - ChatUtil.sendFormatted( - String.format( - "%sHealth: %s&l%s&r (&otick: %d&r)&r", - Myau.clientName, - packet > 0.0F ? "&a" : "&c", - df.format(packet), - mc.thePlayer.ticksExisted - ) - ); - } - } - if (event.getPacket() instanceof S1CPacketEntityMetadata) { - S1CPacketEntityMetadata packet = (S1CPacketEntityMetadata) event.getPacket(); - if (packet.getEntityId() == mc.thePlayer.getEntityId()) { - for (WatchableObject watchableObject : packet.func_149376_c()) { - if (watchableObject.getDataValueId() == 6) { - float diff = (Float) watchableObject.getObject() - mc.thePlayer.getHealth(); - if (diff != 0.0F && this.lastTickProcessed != mc.thePlayer.ticksExisted) { - this.lastTickProcessed = mc.thePlayer.ticksExisted; - ChatUtil.sendFormatted( - String.format( - "%sHealth: %s&l%s&r (&otick: %d&r)&r", - Myau.clientName, - diff > 0.0F ? "&a" : "&c", - df.format(diff), - mc.thePlayer.ticksExisted - ) - ); - } - } - } - } - } - } - } - } - - @EventTarget - public void onMove(MoveInputEvent event) { - if (this.isEnabled()) { - if (this.moveFix.getValue() == 1 - && this.rotations.getValue() != 3 - && RotationState.isActived() - && RotationState.getPriority() == 1.0F - && MoveUtil.isForwardPressed()) { - MoveUtil.fixStrafe(RotationState.getSmoothedYaw()); - } - if (this.shouldAutoBlock()) { - mc.thePlayer.movementInput.jump = false; - } - } - } - - @EventTarget - public void onRender(Render3DEvent event) { - if (this.isEnabled() && target != null) { - if (this.showTarget.getValue() != 0 - && TeamUtil.isEntityLoaded(this.target.getEntity()) - && this.isAttackAllowed()) { - Color color = new Color(-1); - switch (this.showTarget.getValue()) { - case 1: - if (this.target.getEntity().hurtTime > 0) { - color = new Color(16733525); - } else { - color = new Color(5635925); - } - break; - case 2: - color = ((HUD) Myau.moduleManager.modules.get(HUD.class)).getColor(System.currentTimeMillis()); - } - RenderUtil.enableRenderState(); - RenderUtil.drawEntityBox(this.target.getEntity(), color.getRed(), color.getGreen(), color.getBlue()); - RenderUtil.disableRenderState(); - } - } - } - - @EventTarget - public void onLeftClick(LeftClickMouseEvent event) { - if (this.isBlocking) { - event.setCancelled(true); - } else { - if (this.isEnabled() && this.target != null && this.canAttack()) { - event.setCancelled(true); - } - } - } - - @EventTarget - public void onRightClick(RightClickMouseEvent event) { - if (this.isBlocking) { - event.setCancelled(true); - } else { - if (this.isEnabled() && this.target != null && this.canAttack()) { - event.setCancelled(true); - } - } - } - - @EventTarget - public void onHitBlock(HitBlockEvent event) { - if (this.isBlocking) { - event.setCancelled(true); - } else { - if (this.isEnabled() && this.target != null && this.canAttack()) { - event.setCancelled(true); - } - } - } - - @EventTarget - public void onCancelUse(CancelUseEvent event) { - if (this.isBlocking) { - event.setCancelled(true); - } - } - - @Override - public void onEnabled() { - this.target = null; - this.switchTick = 0; - this.hitRegistered = false; - this.attackDelayMS = 0L; - this.blockTick = 0; - } - - @Override - public void onDisabled() { - Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); - this.blockingState = false; - this.isBlocking = false; - this.fakeBlockState = false; - } - - @Override - public void verifyValue(String value) { - boolean badCps = this.autoBlock.getValue() == 2 - || this.autoBlock.getValue() == 3 - || this.autoBlock.getValue() == 4 - || this.autoBlock.getValue() == 5 - || this.autoBlock.getValue() == 6 - || this.autoBlock.getValue() == 7; - if (!this.autoBlock.getName().equals(value)) { - if (this.swingRange.getName().equals(value)) { - if (this.swingRange.getValue() < this.attackRange.getValue()) { - this.attackRange.setValue(this.swingRange.getValue()); - } - } else if (this.attackRange.getName().equals(value)) { - if (this.swingRange.getValue() < this.attackRange.getValue()) { - this.swingRange.setValue(this.attackRange.getValue()); - } - } else if (this.minCPS.getName().equals(value)) { - if (this.minCPS.getValue() > this.maxCPS.getValue()) { - this.maxCPS.setValue(this.minCPS.getValue()); - } - } else if (this.autoBlockMinCPS.getName().equals(value)) { - if (this.autoBlockMinCPS.getValue() > this.autoBlockMaxCPS.getValue()) { - this.autoBlockMaxCPS.setValue(this.autoBlockMinCPS.getValue()); - } - if(autoBlockMinCPS.getValue() > 10.0F && badCps){ - autoBlockMinCPS.setValue(10.0F); - } - } else if (this.autoBlockMaxCPS.getName().equals(value)) { - if (this.autoBlockMinCPS.getValue() > this.autoBlockMaxCPS.getValue()) { - this.autoBlockMinCPS.setValue(this.autoBlockMaxCPS.getValue()); - } - if(autoBlockMaxCPS.getValue() > 10.0F && badCps){ - autoBlockMaxCPS.setValue(10.0F); - } - } else { - if (this.maxCPS.getName().equals(value) && this.minCPS.getValue() > this.maxCPS.getValue()) { - this.minCPS.setValue(this.maxCPS.getValue()); - } - } - } else { - if (badCps && (this.autoBlockMinCPS.getValue() > 10.0F || this.autoBlockMaxCPS.getValue() > 10.0F)) { - this.autoBlockMinCPS.setValue(8.0F); - this.autoBlockMaxCPS.setValue(10.0F); - } - } - } - - @Override - public String[] getSuffix() { - return new String[]{CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, this.mode.getModeString())}; - } - - public static class AttackData { - private final EntityLivingBase entity; - private final AxisAlignedBB box; - private final double x; - private final double y; - private final double z; - - public AttackData(EntityLivingBase entityLivingBase) { - this.entity = entityLivingBase; - double collisionBorderSize = entityLivingBase.getCollisionBorderSize(); - this.box = entityLivingBase.getEntityBoundingBox().expand(collisionBorderSize, collisionBorderSize, collisionBorderSize); - this.x = entityLivingBase.posX; - this.y = entityLivingBase.posY; - this.z = entityLivingBase.posZ; - } - - public EntityLivingBase getEntity() { - return this.entity; - } - - public AxisAlignedBB getBox() { - return this.box; - } - - public double getX() { - return this.x; - } - - public double getY() { - return this.y; - } - - public double getZ() { - return this.z; - } - } -} +package myau.module.modules; + +import com.google.common.base.CaseFormat; +import myau.Myau; +import myau.enums.BlinkModules; +import myau.event.EventManager; +import myau.event.EventTarget; +import myau.event.types.EventType; +import myau.event.types.Priority; +import myau.events.*; +import myau.management.RotationState; +import myau.mixin.IAccessorPlayerControllerMP; +import myau.module.Module; +import myau.property.properties.*; +import myau.util.*; +import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityOtherPlayerMP; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.entity.DataWatcher.WatchableObject; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.boss.EntityDragon; +import net.minecraft.entity.boss.EntityWither; +import net.minecraft.entity.monster.EntityIronGolem; +import net.minecraft.entity.monster.EntityMob; +import net.minecraft.entity.monster.EntitySilverfish; +import net.minecraft.entity.monster.EntitySlime; +import net.minecraft.entity.passive.EntityAnimal; +import net.minecraft.entity.passive.EntityBat; +import net.minecraft.entity.passive.EntitySquid; +import net.minecraft.entity.passive.EntityVillager; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; +import net.minecraft.network.play.client.C02PacketUseEntity; +import net.minecraft.network.play.client.C02PacketUseEntity.Action; +import net.minecraft.network.play.client.C07PacketPlayerDigging; +import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; +import net.minecraft.network.play.client.C09PacketHeldItemChange; +import net.minecraft.network.play.server.S06PacketUpdateHealth; +import net.minecraft.network.play.server.S1CPacketEntityMetadata; +import net.minecraft.util.*; +import net.minecraft.util.MovingObjectPosition.MovingObjectType; +import net.minecraft.world.WorldSettings.GameType; + +import java.awt.*; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.ArrayList; +import java.util.Locale; +import java.util.Random; + +public class KillAura extends Module { + private static final Minecraft mc = Minecraft.getMinecraft(); + private static final DecimalFormat df = new DecimalFormat("+0.0;-0.0", new DecimalFormatSymbols(Locale.US)); + private final TimerUtil timer = new TimerUtil(); + private AttackData target = null; + private int switchTick = 0; + private boolean hitRegistered = false; + private boolean blockingState = false; + private boolean isBlocking = false; + private boolean fakeBlockState = false; + private boolean blinkReset = false; + private long attackDelayMS = 0L; + private int blockTick = 0; + private int lastTickProcessed; + public final ModeProperty mode; + public final ModeProperty sort; + public final ModeProperty autoBlock; + public final BooleanProperty autoBlockRequirePress; + public final FloatProperty autoBlockMinCPS; + public final FloatProperty autoBlockMaxCPS; + public final FloatProperty autoBlockRange; + public final IntProperty maxHurtTime; + public final FloatProperty swingRange; + public final FloatProperty attackRange; + public final IntProperty fov; + public final IntProperty minCPS; + public final IntProperty maxCPS; + public final IntProperty switchDelay; + public final ModeProperty rotations; + public final ModeProperty moveFix; + public final PercentProperty smoothing; + public final IntProperty angleStep; + public final BooleanProperty throughWalls; + public final BooleanProperty swingThrough; + public final BooleanProperty requirePress; + public final BooleanProperty allowMining; + public final BooleanProperty weaponsOnly; + public final BooleanProperty allowTools; + public final BooleanProperty inventoryCheck; + public final BooleanProperty botCheck; + public final BooleanProperty players; + public final BooleanProperty bosses; + public final BooleanProperty mobs; + public final BooleanProperty animals; + public final BooleanProperty golems; + public final BooleanProperty silverfish; + public final BooleanProperty teams; + public final ModeProperty showTarget; + public final ModeProperty debugLog; + + private long getAttackDelay() { + return this.isBlocking ? (long) (1000.0F / RandomUtil.nextLong(this.autoBlockMinCPS.getValue().longValue(), this.autoBlockMaxCPS.getValue().longValue())) : 1000L / RandomUtil.nextLong(this.minCPS.getValue(), this.maxCPS.getValue()); + } + + private boolean performAttack(float yaw, float pitch) { + if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + if (this.isPlayerBlocking() && this.autoBlock.getValue() != 1) { + return false; + } else if (this.attackDelayMS > 0L) { + return false; + } else { + this.attackDelayMS = this.attackDelayMS + this.getAttackDelay(); + mc.thePlayer.swingItem(); + if ((this.rotations.getValue() != 0 || !this.isBoxInAttackRange(this.target.getBox())) + && RotationUtil.rayTrace(this.target.getBox(), yaw, pitch, this.attackRange.getValue()) == null) { + return false; + } else { + AttackEvent event = new AttackEvent(this.target.getEntity()); + EventManager.call(event); + ((IAccessorPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); + PacketUtil.sendPacket(new C02PacketUseEntity(this.target.getEntity(), Action.ATTACK)); + if (mc.playerController.getCurrentGameType() != GameType.SPECTATOR) { + PlayerUtil.attackEntity(this.target.getEntity()); + } + return true; + } + } + } else { + return false; + } + } + + private boolean performSwing() { + if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + if (this.isPlayerBlocking() && this.autoBlock.getValue() != 1) { + return false; + } else if (this.attackDelayMS > 0L) { + return false; + } else { + this.attackDelayMS = this.attackDelayMS + this.getAttackDelay(); + mc.thePlayer.swingItem(); + return true; + } + } else { + return false; + } + } + + private void sendUseItem() { + ((IAccessorPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); + this.startBlock(mc.thePlayer.getHeldItem()); + } + + private void startBlock(ItemStack itemStack) { + PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(itemStack)); + mc.thePlayer.setItemInUse(itemStack, itemStack.getMaxItemUseDuration()); + this.blockingState = true; + } + + private void stopBlock() { + PacketUtil.sendPacket(new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN)); + mc.thePlayer.stopUsingItem(); + this.blockingState = false; + } + + private void interactAttack(float yaw, float pitch) { + if (this.target != null) { + MovingObjectPosition mop = RotationUtil.rayTrace(this.target.getBox(), yaw, pitch, 8.0); + if (mop != null) { + ((IAccessorPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); + PacketUtil.sendPacket( + new C02PacketUseEntity( + this.target.getEntity(), + new Vec3(mop.hitVec.xCoord - this.target.getX(), mop.hitVec.yCoord - this.target.getY(), mop.hitVec.zCoord - this.target.getZ()) + ) + ); + PacketUtil.sendPacket(new C02PacketUseEntity(this.target.getEntity(), Action.INTERACT)); + PacketUtil.sendPacket(new C08PacketPlayerBlockPlacement(mc.thePlayer.getHeldItem())); + mc.thePlayer.setItemInUse(mc.thePlayer.getHeldItem(), mc.thePlayer.getHeldItem().getMaxItemUseDuration()); + this.blockingState = true; + } + } + } + + private boolean canAttack() { + if (this.inventoryCheck.getValue() && mc.currentScreen instanceof GuiContainer) { + return false; + } else if (!(Boolean) this.weaponsOnly.getValue() + || ItemUtil.hasRawUnbreakingEnchant() + || this.allowTools.getValue() && ItemUtil.isHoldingTool()) { + if (((IAccessorPlayerControllerMP) mc.playerController).getIsHittingBlock()) { + return false; + } else if ((ItemUtil.isEating() || ItemUtil.isUsingBow()) && PlayerUtil.isUsingItem()) { + return false; + } else { + AutoHeal autoHeal = (AutoHeal) Myau.moduleManager.modules.get(AutoHeal.class); + if (autoHeal.isEnabled() && autoHeal.isSwitching()) { + return false; + } else { + BedNuker bedNuker = (BedNuker) Myau.moduleManager.modules.get(BedNuker.class); + AutoBlockIn autoBlockIn = (AutoBlockIn) Myau.moduleManager.modules.get(AutoBlockIn.class); + if (bedNuker.isEnabled() && bedNuker.isReady()) { + return false; + } else if (Myau.moduleManager.modules.get(Scaffold.class).isEnabled()) { + return false; + } else if (autoBlockIn.isEnabled()) { + return false; + } else if (this.requirePress.getValue()) { + return PlayerUtil.isAttacking(); + } else { + return !this.allowMining.getValue() || !mc.objectMouseOver.typeOfHit.equals(MovingObjectType.BLOCK) || !PlayerUtil.isAttacking(); + } + } + } + } else { + return false; + } + } + + private boolean canAutoBlock() { + if (!ItemUtil.isHoldingSword()) { + return false; + } else if (this.autoBlockRequirePress.getValue() && !PlayerUtil.isUsingItem()) { + return false; + } else { + if (this.maxHurtTime.getValue() > 0) { + if (mc.thePlayer.hurtResistantTime <= this.maxHurtTime.getValue() / 50) { + return false; + } + } + return true; + } + } + + private boolean hasValidTarget() { + return mc.theWorld + .loadedEntityList + .stream() + .anyMatch( + entity -> entity instanceof EntityLivingBase + && this.isValidTarget((EntityLivingBase) entity) + && this.isInBlockRange((EntityLivingBase) entity) + ); + } + + private boolean isValidTarget(EntityLivingBase entityLivingBase) { + if (!mc.theWorld.loadedEntityList.contains(entityLivingBase)) { + return false; + } else if (entityLivingBase != mc.thePlayer && entityLivingBase != mc.thePlayer.ridingEntity) { + if (entityLivingBase == mc.getRenderViewEntity() || entityLivingBase == mc.getRenderViewEntity().ridingEntity) { + return false; + } else if (entityLivingBase.deathTime > 0) { + return false; + } else if (RotationUtil.angleToEntity(entityLivingBase) > this.fov.getValue().floatValue()) { + return false; + } else if (!this.throughWalls.getValue() && !this.swingThrough.getValue() && RotationUtil.rayTrace(entityLivingBase) != null) { + return false; + } else if (entityLivingBase instanceof EntityOtherPlayerMP) { + if (!this.players.getValue()) { + return false; + } else if (TeamUtil.isFriend((EntityPlayer) entityLivingBase)) { + return false; + } else { + return (!this.teams.getValue() || !TeamUtil.isSameTeam((EntityPlayer) entityLivingBase)) && (!this.botCheck.getValue() || !TeamUtil.isBot((EntityPlayer) entityLivingBase)); + } + } else if (entityLivingBase instanceof EntityDragon || entityLivingBase instanceof EntityWither) { + return this.bosses.getValue(); + } else if (!(entityLivingBase instanceof EntityMob) && !(entityLivingBase instanceof EntitySlime)) { + if (entityLivingBase instanceof EntityAnimal + || entityLivingBase instanceof EntityBat + || entityLivingBase instanceof EntitySquid + || entityLivingBase instanceof EntityVillager) { + return this.animals.getValue(); + } else if (!(entityLivingBase instanceof EntityIronGolem)) { + return false; + } else { + return this.golems.getValue() && (!this.teams.getValue() || !TeamUtil.hasTeamColor(entityLivingBase)); + } + } else if (!(entityLivingBase instanceof EntitySilverfish)) { + return this.mobs.getValue(); + } else { + return this.silverfish.getValue() && (!this.teams.getValue() || !TeamUtil.hasTeamColor(entityLivingBase)); + } + } else { + return false; + } + } + + private boolean isInRange(EntityLivingBase entityLivingBase) { + return this.isInBlockRange(entityLivingBase) || this.isInSwingRange(entityLivingBase) || this.isInAttackRange(entityLivingBase); + } + + private boolean isInBlockRange(EntityLivingBase entityLivingBase) { + return RotationUtil.distanceToEntity(entityLivingBase) <= (double) this.autoBlockRange.getValue(); + } + + private boolean isInSwingRange(EntityLivingBase entityLivingBase) { + return RotationUtil.distanceToEntity(entityLivingBase) <= (double) this.swingRange.getValue(); + } + + private boolean isBoxInSwingRange(AxisAlignedBB axisAlignedBB) { + return RotationUtil.distanceToBox(axisAlignedBB) <= (double) this.swingRange.getValue(); + } + + private boolean isInAttackRange(EntityLivingBase entityLivingBase) { + return RotationUtil.distanceToEntity(entityLivingBase) <= (double) this.attackRange.getValue(); + } + + private boolean isBoxInAttackRange(AxisAlignedBB axisAlignedBB) { + return RotationUtil.distanceToBox(axisAlignedBB) <= (double) this.attackRange.getValue(); + } + + private boolean isPlayerTarget(EntityLivingBase entityLivingBase) { + return entityLivingBase instanceof EntityPlayer && TeamUtil.isTarget((EntityPlayer) entityLivingBase); + } + + private int findEmptySlot(int currentSlot) { + for (int i = 0; i < 9; i++) { + if (i != currentSlot && mc.thePlayer.inventory.getStackInSlot(i) == null) { + return i; + } + } + for (int i = 0; i < 9; i++) { + if (i != currentSlot) { + ItemStack stack = mc.thePlayer.inventory.getStackInSlot(i); + if (stack != null && !stack.hasDisplayName()) { + return i; + } + } + } + return Math.floorMod(currentSlot - 1, 9); + } + + private int findSwordSlot(int currentSlot) { + for (int i = 0; i < 9; i++) { + if (i != currentSlot) { + ItemStack item = mc.thePlayer.inventory.getStackInSlot(i); + if (item != null && item.getItem() instanceof ItemSword) { + return i; + } + } + } + return -1; + } + + public KillAura() { + super("KillAura", false); + this.lastTickProcessed = 0; + this.mode = new ModeProperty("mode", 0, new String[]{"SINGLE", "SWITCH"}); + this.sort = new ModeProperty("sort", 0, new String[]{"DISTANCE", "HEALTH", "HURT_TIME", "FOV"}); + this.autoBlock = new ModeProperty( + "auto-block", 2, new String[]{"NONE", "VANILLA", "SPOOF", "HYPIXEL", "BLINK", "INTERACT", "SWAP", "LEGIT", "FAKE"} + ); + this.autoBlockRequirePress = new BooleanProperty("auto-block-require-press", false); + this.autoBlockMinCPS = new FloatProperty("auto-block-min-aps", 8.0F, 1.0F, 20.0F); + this.autoBlockMaxCPS = new FloatProperty("auto-block-max-aps", 10.0F, 1.0F, 20.0F); + this.autoBlockRange = new FloatProperty("auto-block-range", 6.0F, 3.0F, 8.0F); + this.maxHurtTime = new IntProperty("max-hurt-time", 0, 0, 100); + this.swingRange = new FloatProperty("swing-range", 3.5F, 3.0F, 6.0F); + this.attackRange = new FloatProperty("attack-range", 3.0F, 3.0F, 6.0F); + this.fov = new IntProperty("fov", 360, 30, 360); + this.minCPS = new IntProperty("min-aps", 14, 1, 20); + this.maxCPS = new IntProperty("max-aps", 14, 1, 20); + this.switchDelay = new IntProperty("switch-delay", 150, 0, 1000); + this.rotations = new ModeProperty("rotations", 2, new String[]{"NONE", "LEGIT", "SILENT", "LOCK_VIEW"}); + this.moveFix = new ModeProperty("move-fix", 1, new String[]{"NONE", "SILENT", "STRICT"}); + this.smoothing = new PercentProperty("smoothing", 0); + this.angleStep = new IntProperty("angle-step", 90, 30, 180); + this.throughWalls = new BooleanProperty("through-walls", true); + this.swingThrough = new BooleanProperty("swing-through", false); + this.requirePress = new BooleanProperty("require-press", false); + this.allowMining = new BooleanProperty("allow-mining", true); + this.weaponsOnly = new BooleanProperty("weapons-only", true); + this.allowTools = new BooleanProperty("allow-tools", false, this.weaponsOnly::getValue); + this.inventoryCheck = new BooleanProperty("inventory-check", true); + this.botCheck = new BooleanProperty("bot-check", true); + this.players = new BooleanProperty("players", true); + this.bosses = new BooleanProperty("bosses", false); + this.mobs = new BooleanProperty("mobs", false); + this.animals = new BooleanProperty("animals", false); + this.golems = new BooleanProperty("golems", false); + this.silverfish = new BooleanProperty("silverfish", false); + this.teams = new BooleanProperty("teams", true); + this.showTarget = new ModeProperty("show-target", 0, new String[]{"NONE", "DEFAULT", "HUD"}); + this.debugLog = new ModeProperty("debug-log", 0, new String[]{"NONE", "HEALTH"}); + } + + public EntityLivingBase getTarget() { + return this.target != null ? this.target.getEntity() : null; + } + + public boolean isAttackAllowed() { + Scaffold scaffold = (Scaffold) Myau.moduleManager.modules.get(Scaffold.class); + if (scaffold.isEnabled()) { + return false; + } else if (!this.weaponsOnly.getValue() + || ItemUtil.hasRawUnbreakingEnchant() + || this.allowTools.getValue() && ItemUtil.isHoldingTool()) { + return !this.requirePress.getValue() || KeyBindUtil.isKeyDown(mc.gameSettings.keyBindAttack.getKeyCode()); + } else { + return false; + } + } + + public boolean shouldAutoBlock() { + if (this.isPlayerBlocking() && this.isBlocking) { + return !mc.thePlayer.isInWater() && !mc.thePlayer.isInLava() && (this.autoBlock.getValue() == 3 // HYPIXEL + || this.autoBlock.getValue() == 4 // BLINK + || this.autoBlock.getValue() == 5 // INTERACT + || this.autoBlock.getValue() == 6 // SWAP + || this.autoBlock.getValue() == 7); // LEGIT + } else { + return false; + } + } + + public boolean isBlocking() { + return this.fakeBlockState && ItemUtil.isHoldingSword(); + } + + public boolean isPlayerBlocking() { + return (mc.thePlayer.isUsingItem() || this.blockingState) && ItemUtil.isHoldingSword(); + } + + @EventTarget(Priority.LOW) + public void onUpdate(UpdateEvent event) { + if (event.getType() == EventType.POST && this.blinkReset) { + this.blinkReset = false; + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + Myau.blinkManager.setBlinkState(true, BlinkModules.AUTO_BLOCK); + } + if (this.isEnabled() && event.getType() == EventType.PRE) { + if (this.attackDelayMS > 0L) { + this.attackDelayMS -= 50L; + } + boolean attack = this.target != null && this.canAttack(); + boolean block = attack && this.canAutoBlock(); + if (!block) { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + this.blockTick = 0; + } + if (attack) { + boolean swap = false; + boolean blocked = false; + if (block) { + switch (this.autoBlock.getValue()) { + case 0: // NONE + if (PlayerUtil.isUsingItem()) { + this.isBlocking = true; + if (!this.isPlayerBlocking() && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + swap = true; + } + } else { + this.isBlocking = false; + if (this.isPlayerBlocking() && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + this.stopBlock(); + } + } + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.fakeBlockState = false; + break; + case 1: // VANILLA + if (this.hasValidTarget()) { + if (!this.isPlayerBlocking() && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + swap = true; + } + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = true; + this.fakeBlockState = false; + } else { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + } + break; + case 2: // SPOOF + if (this.hasValidTarget()) { + int item = ((IAccessorPlayerControllerMP) mc.playerController).getCurrentPlayerItem(); + if (Myau.playerStateManager.digging + || Myau.playerStateManager.placing + || mc.thePlayer.inventory.currentItem != item + || this.isPlayerBlocking() && this.blockTick != 0 + || this.attackDelayMS > 0L && this.attackDelayMS <= 50L) { + this.blockTick = 0; + } else { + int slot = this.findEmptySlot(item); + PacketUtil.sendPacket(new C09PacketHeldItemChange(slot)); + PacketUtil.sendPacket(new C09PacketHeldItemChange(item)); + swap = true; + this.blockTick = 1; + } + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = true; + this.fakeBlockState = false; + } else { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + } + break; + case 3: // HYPIXEL + if (this.hasValidTarget()) { + if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + switch (this.blockTick) { + case 0: + if (!this.isPlayerBlocking()) { + swap = true; + } + blocked = true; + this.blockTick = 1; + break; + case 1: + if (this.isPlayerBlocking()) { + if(Myau.moduleManager.modules.get(NoSlow.class).isEnabled()){ + int randomSlot = new Random().nextInt(9); + while (randomSlot == mc.thePlayer.inventory.currentItem) { + randomSlot = new Random().nextInt(9); + } + PacketUtil.sendPacket(new C09PacketHeldItemChange(randomSlot)); + PacketUtil.sendPacket(new C09PacketHeldItemChange(mc.thePlayer.inventory.currentItem)); + } + this.stopBlock(); + attack = false; + } + if (this.attackDelayMS <= 50L) { + this.blockTick = 0; + } + break; + default: + this.blockTick = 0; + } + } + this.isBlocking = true; + this.fakeBlockState = true; + } else { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + } + break; + case 4: // BLINK + if (this.hasValidTarget()) { + if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + switch (this.blockTick) { + case 0: + if (!this.isPlayerBlocking()) { + swap = true; + } + this.blinkReset = true; + this.blockTick = 1; + break; + case 1: + if (this.isPlayerBlocking()) { + this.stopBlock(); + attack = false; + } + if (this.attackDelayMS <= 50L) { + this.blockTick = 0; + } + break; + default: + this.blockTick = 0; + } + } + this.isBlocking = true; + this.fakeBlockState = true; + } else { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + } + break; + case 5: // INTERACT + if (this.hasValidTarget()) { + int item = ((IAccessorPlayerControllerMP) mc.playerController).getCurrentPlayerItem(); + if (mc.thePlayer.inventory.currentItem == item && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + switch (this.blockTick) { + case 0: + if (!this.isPlayerBlocking()) { + swap = true; + } + this.blinkReset = true; + this.blockTick = 1; + break; + case 1: + if (this.isPlayerBlocking()) { + int slot = this.findEmptySlot(item); + PacketUtil.sendPacket(new C09PacketHeldItemChange(slot)); + ((IAccessorPlayerControllerMP) mc.playerController).setCurrentPlayerItem(slot); + attack = false; + } + if (this.attackDelayMS <= 50L) { + this.blockTick = 0; + } + break; + default: + this.blockTick = 0; + } + } + this.isBlocking = true; + this.fakeBlockState = true; + } else { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + } + break; + case 6: // SWAP + if (this.hasValidTarget()) { + int item = ((IAccessorPlayerControllerMP) mc.playerController).getCurrentPlayerItem(); + if (mc.thePlayer.inventory.currentItem == item && !Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + switch (this.blockTick) { + case 0: + int slot = this.findSwordSlot(item); + if (slot != -1) { + if (!this.isPlayerBlocking()) { + swap = true; + } + this.blockTick = 1; + } + break; + case 1: + int swordsSlot = this.findSwordSlot(item); + if (swordsSlot == -1) { + this.blockTick = 0; + } else if (!this.isPlayerBlocking()) { + swap = true; + } else if (this.attackDelayMS <= 50L) { + PacketUtil.sendPacket(new C09PacketHeldItemChange(swordsSlot)); + ((IAccessorPlayerControllerMP) mc.playerController).setCurrentPlayerItem(swordsSlot); + this.startBlock(mc.thePlayer.inventory.getStackInSlot(swordsSlot)); + attack = false; + this.blockTick = 0; + } + break; + default: + this.blockTick = 0; + } + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = true; + this.fakeBlockState = true; + break; + } + } + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + break; + case 7: // LEGIT + if (this.hasValidTarget()) { + if (!Myau.playerStateManager.digging && !Myau.playerStateManager.placing) { + switch (this.blockTick) { + case 0: + if (!this.isPlayerBlocking()) { + swap = true; + } + this.blockTick = 1; + break; + case 1: + if (this.isPlayerBlocking() && this.attackDelayMS <= 100L) { + this.stopBlock(); + this.blockTick = 2; + } + break; + case 2: + if (!this.isPlayerBlocking() && this.attackDelayMS <= 50L) { + swap = true; + this.blockTick = 1; + } + break; + default: + this.blockTick = 0; + } + } + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = true; + this.fakeBlockState = false; + } else { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = false; + this.blockTick = 0; + } + break; + case 8: // FAKE + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.isBlocking = false; + this.fakeBlockState = this.hasValidTarget(); + if (PlayerUtil.isUsingItem() + && !this.isPlayerBlocking() + && !Myau.playerStateManager.digging + && !Myau.playerStateManager.placing) { + swap = true; + } + } + } + boolean attacked = false; + boolean behindWall = this.swingThrough.getValue() + && RotationUtil.rayTrace(this.target.getEntity()) != null; + boolean inSwingOrWall = this.isBoxInSwingRange(this.target.getBox()) || behindWall; + + if (inSwingOrWall) { + if (this.rotations.getValue() == 2 || this.rotations.getValue() == 3) { + float[] rotations = RotationUtil.getRotationsToBox( + this.target.getBox(), + event.getYaw(), + event.getPitch(), + (float) this.angleStep.getValue() + RandomUtil.nextFloat(-5.0F, 5.0F), + (float) this.smoothing.getValue() / 100.0F + ); + event.setRotation(rotations[0], rotations[1], 1); + if (this.rotations.getValue() == 3) { + Myau.rotationManager.setRotation(rotations[0], rotations[1], 1, true); + } + if (this.moveFix.getValue() != 0 || this.rotations.getValue() == 3) { + event.setPervRotation(rotations[0], 1); + } + } + + if (attack) { + if (behindWall) { + attacked = this.performSwing(); + } else { + attacked = this.performAttack(event.getNewYaw(), event.getNewPitch()); + } + } + } + if (swap) { + if (attacked) { + this.interactAttack(event.getNewYaw(), event.getNewPitch()); + } else { + this.sendUseItem(); + } + } + if (blocked) { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + Myau.blinkManager.setBlinkState(true, BlinkModules.AUTO_BLOCK); + } + } + } + } + + @EventTarget + public void onTick(TickEvent event) { + if (this.isEnabled()) { + switch (event.getType()) { + case PRE: + boolean currentTargetBehindWall = this.swingThrough.getValue() + && this.target != null + && RotationUtil.rayTrace(this.target.getEntity()) != null; + if (this.target == null + || !this.isValidTarget(this.target.getEntity()) + || (!currentTargetBehindWall && !this.isBoxInAttackRange(this.target.getBox())) + || !this.isBoxInSwingRange(this.target.getBox()) + || this.timer.hasTimeElapsed(this.switchDelay.getValue().longValue())) { + this.timer.reset(); + ArrayList targets = new ArrayList<>(); + for (Entity entity : mc.theWorld.loadedEntityList) { + if (entity instanceof EntityLivingBase + && this.isValidTarget((EntityLivingBase) entity) + && this.isInRange((EntityLivingBase) entity)) { + targets.add((EntityLivingBase) entity); + } + } + if (targets.isEmpty()) { + this.target = null; + } else { + if (targets.stream().anyMatch(this::isInSwingRange)) { + targets.removeIf(entityLivingBase -> !this.isInSwingRange(entityLivingBase)); + } + if (targets.stream().anyMatch(e -> this.isInAttackRange(e) || (this.swingThrough.getValue() && RotationUtil.rayTrace(e) != null))) { + targets.removeIf(entityLivingBase -> !this.isInAttackRange(entityLivingBase) + && !(this.swingThrough.getValue() && RotationUtil.rayTrace(entityLivingBase) != null)); + } + if (targets.stream().anyMatch(this::isPlayerTarget)) { + targets.removeIf(entityLivingBase -> !this.isPlayerTarget(entityLivingBase)); + } + targets.sort( + (entityLivingBase1, entityLivingBase2) -> { + int sortBase = 0; + switch (this.sort.getValue()) { + case 1: + sortBase = Float.compare(TeamUtil.getHealthScore(entityLivingBase1), TeamUtil.getHealthScore(entityLivingBase2)); + break; + case 2: + sortBase = Integer.compare(entityLivingBase1.hurtResistantTime, entityLivingBase2.hurtResistantTime); + break; + case 3: + sortBase = Float.compare( + RotationUtil.angleToEntity(entityLivingBase1), + RotationUtil.angleToEntity(entityLivingBase2) + ); + } + return sortBase != 0 + ? sortBase + : Double.compare(RotationUtil.distanceToEntity(entityLivingBase1), RotationUtil.distanceToEntity(entityLivingBase2)); + } + ); + if (this.mode.getValue() == 1 && this.hitRegistered) { + this.hitRegistered = false; + this.switchTick++; + } + if (this.mode.getValue() == 0 || this.switchTick >= targets.size()) { + this.switchTick = 0; + } + this.target = new AttackData(targets.get(this.switchTick)); + } + } + if (this.target != null) { + this.target = new AttackData(this.target.getEntity()); + } + break; + case POST: + if (this.isPlayerBlocking() && !mc.thePlayer.isBlocking()) { + mc.thePlayer.setItemInUse(mc.thePlayer.getHeldItem(), mc.thePlayer.getHeldItem().getMaxItemUseDuration()); + } + } + } + } + + @EventTarget(Priority.LOWEST) + public void onPacket(PacketEvent event) { + if (this.isEnabled() && !event.isCancelled() && mc.thePlayer != null && mc.theWorld != null) { + if (event.getPacket() instanceof C07PacketPlayerDigging) { + C07PacketPlayerDigging packet = (C07PacketPlayerDigging) event.getPacket(); + if (packet.getStatus() == C07PacketPlayerDigging.Action.RELEASE_USE_ITEM) { + this.blockingState = false; + } + } + if (event.getPacket() instanceof C09PacketHeldItemChange) { + this.blockingState = false; + if (this.isBlocking) { + mc.thePlayer.stopUsingItem(); + } + } + if (this.debugLog.getValue() == 1 && this.isAttackAllowed()) { + if (event.getPacket() instanceof S06PacketUpdateHealth) { + float packet = ((S06PacketUpdateHealth) event.getPacket()).getHealth() - mc.thePlayer.getHealth(); + if (packet != 0.0F && this.lastTickProcessed != mc.thePlayer.ticksExisted) { + this.lastTickProcessed = mc.thePlayer.ticksExisted; + ChatUtil.sendFormatted( + String.format( + "%sHealth: %s&l%s&r (&otick: %d&r)&r", + Myau.clientName, + packet > 0.0F ? "&a" : "&c", + df.format(packet), + mc.thePlayer.ticksExisted + ) + ); + } + } + if (event.getPacket() instanceof S1CPacketEntityMetadata) { + S1CPacketEntityMetadata packet = (S1CPacketEntityMetadata) event.getPacket(); + if (packet.getEntityId() == mc.thePlayer.getEntityId()) { + for (WatchableObject watchableObject : packet.func_149376_c()) { + if (watchableObject.getDataValueId() == 6) { + float diff = (Float) watchableObject.getObject() - mc.thePlayer.getHealth(); + if (diff != 0.0F && this.lastTickProcessed != mc.thePlayer.ticksExisted) { + this.lastTickProcessed = mc.thePlayer.ticksExisted; + ChatUtil.sendFormatted( + String.format( + "%sHealth: %s&l%s&r (&otick: %d&r)&r", + Myau.clientName, + diff > 0.0F ? "&a" : "&c", + df.format(diff), + mc.thePlayer.ticksExisted + ) + ); + } + } + } + } + } + } + } + } + + @EventTarget + public void onMove(MoveInputEvent event) { + if (this.isEnabled()) { + if (this.moveFix.getValue() == 1 + && this.rotations.getValue() != 3 + && RotationState.isActived() + && RotationState.getPriority() == 1.0F + && MoveUtil.isForwardPressed()) { + MoveUtil.fixStrafe(RotationState.getSmoothedYaw()); + } + if (this.shouldAutoBlock()) { + mc.thePlayer.movementInput.jump = false; + } + } + } + + @EventTarget + public void onRender(Render3DEvent event) { + if (this.isEnabled() && target != null) { + if (this.showTarget.getValue() != 0 + && TeamUtil.isEntityLoaded(this.target.getEntity()) + && this.isAttackAllowed()) { + Color color = new Color(-1); + switch (this.showTarget.getValue()) { + case 1: + if (this.target.getEntity().hurtTime > 0) { + color = new Color(16733525); + } else { + color = new Color(5635925); + } + break; + case 2: + color = ((HUD) Myau.moduleManager.modules.get(HUD.class)).getColor(System.currentTimeMillis()); + } + RenderUtil.enableRenderState(); + RenderUtil.drawEntityBox(this.target.getEntity(), color.getRed(), color.getGreen(), color.getBlue()); + RenderUtil.disableRenderState(); + } + } + } + + @EventTarget + public void onLeftClick(LeftClickMouseEvent event) { + if (this.isBlocking) { + event.setCancelled(true); + } else { + if (this.isEnabled() && this.target != null && this.canAttack()) { + event.setCancelled(true); + } + } + } + + @EventTarget + public void onRightClick(RightClickMouseEvent event) { + if (this.isBlocking) { + event.setCancelled(true); + } else { + if (this.isEnabled() && this.target != null && this.canAttack()) { + event.setCancelled(true); + } + } + } + + @EventTarget + public void onHitBlock(HitBlockEvent event) { + if (this.isBlocking) { + event.setCancelled(true); + } else { + if (this.isEnabled() && this.target != null && this.canAttack()) { + event.setCancelled(true); + } + } + } + + @EventTarget + public void onCancelUse(CancelUseEvent event) { + if (this.isBlocking) { + event.setCancelled(true); + } + } + + @Override + public void onEnabled() { + this.target = null; + this.switchTick = 0; + this.hitRegistered = false; + this.attackDelayMS = 0L; + this.blockTick = 0; + } + + @Override + public void onDisabled() { + Myau.blinkManager.setBlinkState(false, BlinkModules.AUTO_BLOCK); + this.blockingState = false; + this.isBlocking = false; + this.fakeBlockState = false; + } + + @Override + public void verifyValue(String value) { + boolean badCps = this.autoBlock.getValue() == 2 + || this.autoBlock.getValue() == 3 + || this.autoBlock.getValue() == 4 + || this.autoBlock.getValue() == 5 + || this.autoBlock.getValue() == 6 + || this.autoBlock.getValue() == 7; + if (!this.autoBlock.getName().equals(value)) { + if (this.swingRange.getName().equals(value)) { + if (this.swingRange.getValue() < this.attackRange.getValue()) { + this.attackRange.setValue(this.swingRange.getValue()); + } + } else if (this.attackRange.getName().equals(value)) { + if (this.swingRange.getValue() < this.attackRange.getValue()) { + this.swingRange.setValue(this.attackRange.getValue()); + } + } else if (this.minCPS.getName().equals(value)) { + if (this.minCPS.getValue() > this.maxCPS.getValue()) { + this.maxCPS.setValue(this.minCPS.getValue()); + } + } else if (this.autoBlockMinCPS.getName().equals(value)) { + if (this.autoBlockMinCPS.getValue() > this.autoBlockMaxCPS.getValue()) { + this.autoBlockMaxCPS.setValue(this.autoBlockMinCPS.getValue()); + } + if(autoBlockMinCPS.getValue() > 10.0F && badCps){ + autoBlockMinCPS.setValue(10.0F); + } + } else if (this.autoBlockMaxCPS.getName().equals(value)) { + if (this.autoBlockMinCPS.getValue() > this.autoBlockMaxCPS.getValue()) { + this.autoBlockMinCPS.setValue(this.autoBlockMaxCPS.getValue()); + } + if(autoBlockMaxCPS.getValue() > 10.0F && badCps){ + autoBlockMaxCPS.setValue(10.0F); + } + } else { + if (this.maxCPS.getName().equals(value) && this.minCPS.getValue() > this.maxCPS.getValue()) { + this.minCPS.setValue(this.maxCPS.getValue()); + } + } + } else { + if (badCps && (this.autoBlockMinCPS.getValue() > 10.0F || this.autoBlockMaxCPS.getValue() > 10.0F)) { + this.autoBlockMinCPS.setValue(8.0F); + this.autoBlockMaxCPS.setValue(10.0F); + } + } + } + + @Override + public String[] getSuffix() { + return new String[]{CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, this.mode.getModeString())}; + } + + public static class AttackData { + private final EntityLivingBase entity; + private final AxisAlignedBB box; + private final double x; + private final double y; + private final double z; + + public AttackData(EntityLivingBase entityLivingBase) { + this.entity = entityLivingBase; + double collisionBorderSize = entityLivingBase.getCollisionBorderSize(); + this.box = entityLivingBase.getEntityBoundingBox().expand(collisionBorderSize, collisionBorderSize, collisionBorderSize); + this.x = entityLivingBase.posX; + this.y = entityLivingBase.posY; + this.z = entityLivingBase.posZ; + } + + public EntityLivingBase getEntity() { + return this.entity; + } + + public AxisAlignedBB getBox() { + return this.box; + } + + public double getX() { + return this.x; + } + + public double getY() { + return this.y; + } + + public double getZ() { + return this.z; + } + } +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/LagRange.java b/src/main/java/myau/module/modules/LagRange.java index 7fc22ed0..1da3cc85 100644 --- a/src/main/java/myau/module/modules/LagRange.java +++ b/src/main/java/myau/module/modules/LagRange.java @@ -9,6 +9,7 @@ import myau.mixin.IAccessorPlayerControllerMP; import myau.mixin.IAccessorRenderManager; import myau.module.Module; +import myau.util.ChatUtil; import myau.util.ItemUtil; import myau.util.RenderUtil; import myau.util.RotationUtil; @@ -37,15 +38,29 @@ public class LagRange extends Module { private int tickIndex = -1; private long delayCounter = 0L; private boolean hasTarget = false; + private long lagStartTime = 0L; + private boolean timerExpired = false; private Vec3 lastPosition = null; private Vec3 currentPosition = null; - public final IntProperty delay = new IntProperty("delay", 150, 0, 1000); - public final FloatProperty range = new FloatProperty("range", 10.0F, 3.0F, 100.0F); + private boolean isLagging = false; + private boolean wasLagging = false; + + public final BooleanProperty advancedMode = new BooleanProperty("advanced-mode", false); + + public final IntProperty delay = new IntProperty("delay", 150, 0, 1000, () -> !this.advancedMode.getValue()); + public final FloatProperty range = new FloatProperty("range", 10.0F, 3.0F, 100.0F, () -> !this.advancedMode.getValue()); + + public final FloatProperty maxTime = new FloatProperty("max-time", 0.0F, 0.0F, 20.0F, this.advancedMode::getValue); + public final FloatProperty closeRange = new FloatProperty("close-range", 6.0F, 3.0F, 100.0F, this.advancedMode::getValue); + public final FloatProperty farRange = new FloatProperty("far-range", 10.0F, 3.0F, 100.0F, this.advancedMode::getValue); + public final IntProperty delayClose = new IntProperty("packet-delay-close", 150, 0, 1000, this.advancedMode::getValue); + public final IntProperty delayFar = new IntProperty("packet-delay-far", 300, 0, 1000, this.advancedMode::getValue); public final BooleanProperty weaponsOnly = new BooleanProperty("weapons-only", true); public final BooleanProperty allowTools = new BooleanProperty("allow-tools", false, this.weaponsOnly::getValue); public final BooleanProperty botCheck = new BooleanProperty("bot-check", true); public final BooleanProperty teams = new BooleanProperty("teams", true); public final ModeProperty showPosition = new ModeProperty("show-position", 0, new String[]{"NONE", "DEFAULT", "HUD"}); + public final BooleanProperty debugLog = new BooleanProperty("debug-log", false); private boolean isValidTarget(EntityPlayer entityPlayer) { if (entityPlayer != mc.thePlayer && entityPlayer != mc.thePlayer.ridingEntity) { @@ -87,6 +102,8 @@ public void onTick(TickEvent event) { case PRE: Myau.lagManager.setDelay(0); this.hasTarget = false; + this.isLagging = false; + BedNuker bedNuker = (BedNuker) Myau.moduleManager.modules.get(BedNuker.class); if ((!bedNuker.isEnabled() || !bedNuker.isReady()) && !((IAccessorPlayerControllerMP) mc.playerController).getIsHittingBlock() @@ -105,36 +122,105 @@ public void onTick(TickEvent event) { .collect(Collectors.toList()); if (players.isEmpty()) { this.tickIndex = -1; + this.lagStartTime = 0L; + this.timerExpired = false; } else { double height = mc.thePlayer.getEyeHeight(); Vec3 eyePosition = Myau.lagManager.getLastPosition().addVector(0.0, height, 0.0); Vec3 targetEyePosition = new Vec3(mc.thePlayer.lastTickPosX, mc.thePlayer.lastTickPosY + height, mc.thePlayer.lastTickPosZ); Vec3 playerEyePosition = new Vec3(mc.thePlayer.posX, mc.thePlayer.posY + height, mc.thePlayer.posZ); + + boolean timerEnabled = this.advancedMode.getValue() && this.maxTime.getValue() > 0.0F; + boolean anyPlayerInCloseRange = false; + + if (timerEnabled) { + for (EntityPlayer player : players) { + double distance = RotationUtil.distanceToBox(player, playerEyePosition); + if (distance <= (double) this.closeRange.getValue()) { + anyPlayerInCloseRange = true; + break; + } + } + } + + if (timerEnabled && this.timerExpired && anyPlayerInCloseRange) { + this.tickIndex = -1; + this.logDebugState(); + break; + } + + if (timerEnabled && this.timerExpired && !anyPlayerInCloseRange) { + this.timerExpired = false; + this.lagStartTime = 0L; + } + for (EntityPlayer player : players) { double distance = RotationUtil.distanceToBox(player, playerEyePosition); - if (!(distance > (double) this.range.getValue())) { + + float maxRange = this.advancedMode.getValue() + ? Math.max(this.closeRange.getValue(), this.farRange.getValue()) + : this.range.getValue(); + + if (!(distance > (double) maxRange)) { double targetDist = RotationUtil.distanceToBox(player, targetEyePosition); double eyeDist = RotationUtil.distanceToBox(player, eyePosition); + if (distance < targetDist || distance < eyeDist) { + if (timerEnabled) { + if (this.lagStartTime == 0L) { + this.lagStartTime = System.currentTimeMillis(); + } + + long elapsed = System.currentTimeMillis() - this.lagStartTime; + long maxTimeMs = (long) (this.maxTime.getValue() * 1000.0F); + if (elapsed >= maxTimeMs) { + this.timerExpired = true; + Myau.lagManager.setDelay(0); + this.tickIndex = -1; + this.isLagging = false; + this.logDebugState(); + return; + } + } + + int currentDelay; + boolean isInCloseRange = false; + + if (this.advancedMode.getValue()) { + isInCloseRange = distance <= (double) this.closeRange.getValue(); + currentDelay = isInCloseRange ? this.delayClose.getValue() : this.delayFar.getValue(); + } else { + currentDelay = this.delay.getValue(); + } + if (this.tickIndex < 0) { this.tickIndex = 0; - for (this.delayCounter = this.delayCounter + (long) this.delay.getValue(); + for (this.delayCounter = this.delayCounter + (long) currentDelay; this.delayCounter > 0L; this.delayCounter = this.delayCounter - 50 ) { this.tickIndex++; } } + Myau.lagManager.setDelay(this.tickIndex); this.hasTarget = true; + this.isLagging = true; + this.logDebugState(); return; } } } + + this.tickIndex = -1; } } else { this.tickIndex = -1; + this.lagStartTime = 0L; + this.timerExpired = false; } + + this.logDebugState(); break; case POST: Vec3 savedPosition = Myau.lagManager.getLastPosition(); @@ -148,12 +234,28 @@ public void onTick(TickEvent event) { } } + private void logDebugState() { + if (this.debugLog.getValue() && this.isLagging != this.wasLagging) { + ChatUtil.sendFormatted( + String.format( + "%sLagRange (&ostate: %d&r)&r", + Myau.clientName, + this.isLagging ? 1 : 0 + ) + ); + this.wasLagging = this.isLagging; + } + } + @EventTarget public void onPacket(PacketEvent event) { if (this.isEnabled()) { if (this.shouldResetOnPacket(event.getPacket())) { Myau.lagManager.setDelay(0); this.tickIndex = -1; + this.lagStartTime = 0L; + this.isLagging = false; + this.logDebugState(); } } } @@ -205,12 +307,35 @@ public void onDisabled() { this.tickIndex = -1; this.delayCounter = 0L; this.hasTarget = false; + this.lagStartTime = 0L; + this.timerExpired = false; this.lastPosition = null; this.currentPosition = null; + this.isLagging = false; + this.wasLagging = false; } @Override public String[] getSuffix() { - return new String[]{String.format("%dms", this.delay.getValue())}; + if (this.advancedMode.getValue()) { + return new String[]{String.format("%dms", this.delayFar.getValue())}; + } else { + return new String[]{String.format("%dms", this.delay.getValue())}; + } + } + + @Override + public void verifyValue(String value) { + if (this.advancedMode.getValue()) { + if (this.closeRange.getName().equals(value)) { + if (this.closeRange.getValue() > this.farRange.getValue()) { + this.farRange.setValue(this.closeRange.getValue()); + } + } else if (this.farRange.getName().equals(value)) { + if (this.closeRange.getValue() > this.farRange.getValue()) { + this.closeRange.setValue(this.farRange.getValue()); + } + } + } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/LongJump.java b/src/main/java/myau/module/modules/LongJump.java index 3ce6eb02..04544ab2 100644 --- a/src/main/java/myau/module/modules/LongJump.java +++ b/src/main/java/myau/module/modules/LongJump.java @@ -97,6 +97,11 @@ public void onTick(TickEvent event) { if (this.isAutoMode() && !this.fireballLaunched && this.readyToUseFireball) { int slot = this.findFireballInHotbar(); if (slot != -1) { + Module freezeModule = Myau.moduleManager.getModule("Freeze"); + if (freezeModule != null && freezeModule.isEnabled()) { + ((Freeze) freezeModule).ignoreNextVelocity(); + } + this.savedHotbarSlot = mc.thePlayer.inventory.currentItem; mc.thePlayer.inventory.currentItem = slot; ((IAccessorPlayerControllerMP) mc.playerController).callSyncCurrentPlayItem(); @@ -166,7 +171,7 @@ public void onUpdate(UpdateEvent event) { return; } } - if (this.isAutoMode() && !this.isJumping) { + if (this.isAutoMode() && !this.isJumping && !this.fireballLaunched) { if (this.jumpTimer.hasTimeElapsed(1500L)) { this.setEnabled(false); return; @@ -214,6 +219,11 @@ public void onKey(KeyEvent event) { if (event.getKey() == mc.gameSettings.keyBindUseItem.getKeyCode()) { ItemStack stack = mc.thePlayer.inventory.getCurrentItem(); if (stack != null && stack.getItem() instanceof ItemFireball) { + Module freezeModule = Myau.moduleManager.getModule("Freeze"); + if (freezeModule != null && freezeModule.isEnabled()) { + ((Freeze) freezeModule).ignoreNextVelocity(); + } + this.fireballTimer.reset(); } } @@ -256,4 +266,4 @@ public String[] getSuffix() { String mode = this.mode.getModeString(); return mode.contains("FIREBALL") ? new String[]{"Fireball"} : new String[]{CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, mode)}; } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/NameTags.java b/src/main/java/myau/module/modules/NameTags.java index c48d86d9..6ae7f4f0 100644 --- a/src/main/java/myau/module/modules/NameTags.java +++ b/src/main/java/myau/module/modules/NameTags.java @@ -51,6 +51,7 @@ public class NameTags extends Module { public final ModeProperty distanceMode = new ModeProperty("distance", 0, new String[]{"NONE", "DEFAULT", "VAPE"}); public final ModeProperty healthMode = new ModeProperty("health", 2, new String[]{"NONE", "HP", "HEARTS", "TAB"}); public final BooleanProperty armor = new BooleanProperty("armor", true); + public final BooleanProperty sneak = new BooleanProperty("sneak", true); public final BooleanProperty effects = new BooleanProperty("effects", true); public final BooleanProperty players = new BooleanProperty("players", true); public final BooleanProperty friends = new BooleanProperty("friends", true); @@ -133,6 +134,12 @@ public void onRender(Render3DEvent event) { case 2: distanceText = String.format("&a[&f%d&a]&r ", (int) distance); } + + String sneakText = ""; + if (this.sneak.getValue() && entity.isSneaking()) { + sneakText = "&eS&r "; + } + float health = ((EntityLivingBase) entity).getHealth(); float absorption = ((EntityLivingBase) entity).getAbsorptionAmount(); float max = ((EntityLivingBase) entity).getMaxHealth(); @@ -163,7 +170,7 @@ public void onRender(Render3DEvent event) { } } } - String color = ChatColors.formatColor(String.format("%s&f%s&r%s", distanceText, teamName, healText)); + String color = ChatColors.formatColor(String.format("%s%s&f%s&r%s", distanceText, sneakText, teamName, healText)); int width = mc.fontRendererObj.getStringWidth(color); if (this.backgroundOpacity.getValue() > 0) { Color textColor = !entity.isSneaking() && !entity.isInvisible() @@ -254,4 +261,4 @@ public void onRender(Render3DEvent event) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/NoSlow.java b/src/main/java/myau/module/modules/NoSlow.java index c3a588c8..ab28525f 100644 --- a/src/main/java/myau/module/modules/NoSlow.java +++ b/src/main/java/myau/module/modules/NoSlow.java @@ -38,8 +38,13 @@ public NoSlow() { super("NoSlow", false); } + private boolean isKillAuraEnabled() { + KillAura killAura = (KillAura) Myau.moduleManager.modules.get(KillAura.class); + return killAura != null && killAura.isEnabled(); + } + public boolean isSwordActive() { - return this.swordMode.getValue() != 0 && ItemUtil.isHoldingSword(); + return this.swordMode.getValue() != 0 && ItemUtil.isHoldingSword() && this.isKillAuraEnabled(); } public boolean isFoodActive() { @@ -66,7 +71,7 @@ public boolean canSprint() { } public int getMotionMultiplier() { - if (ItemUtil.isHoldingSword()) { + if (ItemUtil.isHoldingSword() && this.isKillAuraEnabled()) { return this.swordMotion.getValue(); } else if (ItemUtil.isEating()) { return this.foodMotion.getValue(); @@ -128,4 +133,4 @@ public void onRightClick(RightClickMouseEvent event) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Radar.java b/src/main/java/myau/module/modules/Radar.java index 5a380916..5c9ab6d8 100644 --- a/src/main/java/myau/module/modules/Radar.java +++ b/src/main/java/myau/module/modules/Radar.java @@ -31,9 +31,9 @@ public class Radar extends Module { public final BooleanProperty showEnemies = new BooleanProperty("enemies", true); public final BooleanProperty showBots = new BooleanProperty("bots", false); public final BooleanProperty showPVP = new BooleanProperty("show-pvp", false); - public final ColorProperty fillColor = new ColorProperty("fill-color", Color.GRAY.getRGB()); + public final ColorProperty fillColor = new ColorProperty("fill-color", Color.GRAY.getRGB(), 0x40); public final ColorProperty outlineColor = new ColorProperty("outline-color", Color.DARK_GRAY.getRGB()); - public final ColorProperty crossColor = new ColorProperty("cross-color", Color.LIGHT_GRAY.getRGB()); + public final ColorProperty crossColor = new ColorProperty("cross-color", Color.LIGHT_GRAY.getRGB(), 0x80); public Radar() { super("Radar", false); } @@ -108,8 +108,7 @@ public void onRender(Render2DEvent event) { double cos = Math.cos(yaw); double sin = Math.sin(yaw); - Color fill = new Color(fillColor.getValue()); - this.drawRadarCircle(0.0, 0, yaw, radarRadius.getValue(), 64, new Color(fill.getRed(),fill.getGreen(),fill.getBlue(),100).getRGB(), outlineColor.getValue(), crossColor.getValue()); + this.drawRadarCircle(0.0, 0, yaw, radarRadius.getValue(), 64, fillColor.getValue(), outlineColor.getValue(), crossColor.getValue()); for (EntityPlayer player : TeamUtil.getLoadedEntitiesSorted().stream().filter(entity -> entity instanceof EntityPlayer && this.shouldRender((EntityPlayer) entity)).map(EntityPlayer.class::cast).collect(Collectors.toList())) { double dx = (player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks()) - mc.thePlayer.posX; double dz = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks()) - mc.thePlayer.posZ; @@ -240,4 +239,4 @@ public void drawRadarCircle(double x, double y, double angle, double radius, GlStateManager.disableBlend(); GlStateManager.resetColor(); } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Scaffold.java b/src/main/java/myau/module/modules/Scaffold.java index 06b9489a..e8121757 100644 --- a/src/main/java/myau/module/modules/Scaffold.java +++ b/src/main/java/myau/module/modules/Scaffold.java @@ -72,6 +72,7 @@ public class Scaffold extends Module { public final ModeProperty keepY = new ModeProperty("keep-y", 0, new String[]{"NONE", "VANILLA", "EXTRA", "TELLY"}); public final BooleanProperty keepYonPress = new BooleanProperty("keep-y-on-press", false, () -> this.keepY.getValue() != 0); public final BooleanProperty disableWhileJumpActive = new BooleanProperty("no-keep-y-on-jump-potion", false, () -> this.keepY.getValue() != 0); + public final BooleanProperty tellyDiagonalSlowed = new BooleanProperty("telly-diagonal-slowed", true, () -> this.tower.getValue() == 3); public final BooleanProperty multiplace = new BooleanProperty("multi-place", true); public final BooleanProperty safeWalk = new BooleanProperty("safe-walk", true); public final BooleanProperty swing = new BooleanProperty("swing", true); @@ -232,7 +233,15 @@ private boolean isTowering() { if (mc.thePlayer.onGround && MoveUtil.isForwardPressed() && !PlayerUtil.isAirAbove()) { boolean keepY = this.keepY.getValue() == 3; boolean tower = this.tower.getValue() == 3; - return keepY && this.stage > 0 || tower && mc.gameSettings.keyBindJump.isKeyDown(); + + if (tower && mc.gameSettings.keyBindJump.isKeyDown()) { + if (this.tellyDiagonalSlowed.getValue() && this.isDiagonal(this.getCurrentYaw())) { + return false; + } + return true; + } + + return keepY && this.stage > 0; } else { return false; } @@ -481,6 +490,7 @@ public void onStrafe(StrafeEvent event) { && mc.gameSettings.keyBindJump.isKeyDown() && ItemUtil.isHoldingBlock()) { int yState = (int) (mc.thePlayer.posY % 1.0 * 100.0); + switch (this.tower.getValue()) { case 1: switch (this.towerTick) { @@ -602,6 +612,15 @@ public void onStrafe(StrafeEvent event) { this.towerDelay = 0; return; } + case 3: + if (this.tellyDiagonalSlowed.getValue() && this.isDiagonal(this.getCurrentYaw())) { + this.towerTick = 0; + this.towerDelay = 0; + return; + } + this.towerTick = 0; + this.towerDelay = 0; + return; default: this.towerTick = 0; this.towerDelay = 0; @@ -632,6 +651,7 @@ public void onMoveInput(MoveInputEvent event) { public void onLivingUpdate(LivingUpdateEvent event) { if (this.isEnabled()) { float speed = this.getSpeed(); + if (speed != 1.0F) { if (mc.thePlayer.movementInput.moveForward != 0.0F && mc.thePlayer.movementInput.moveStrafe != 0.0F) { mc.thePlayer.movementInput.moveForward = mc.thePlayer.movementInput.moveForward * (1.0F / (float) Math.sqrt(2.0)); @@ -764,4 +784,4 @@ public EnumFacing facing() { return this.facing; } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Timer.java b/src/main/java/myau/module/modules/Timer.java new file mode 100644 index 00000000..d0dbe871 --- /dev/null +++ b/src/main/java/myau/module/modules/Timer.java @@ -0,0 +1,89 @@ +package myau.module.modules; + +import myau.Myau; +import myau.event.EventTarget; +import myau.event.types.Priority; +import myau.events.LivingUpdateEvent; +import myau.module.Module; +import myau.property.properties.FloatProperty; +import myau.property.properties.ModeProperty; + +import java.util.Comparator; +import java.util.concurrent.CopyOnWriteArrayList; + +public class Timer extends Module { + + private static final CopyOnWriteArrayList requests = new CopyOnWriteArrayList<>(); + + public final ModeProperty mode = new ModeProperty("mode", 0, new String[]{"SPEED", "FREEZE"}); + public final FloatProperty speed = new FloatProperty("speed", 1.0F, 0.01F, 10.0F, () -> this.mode.getValue() == 0); + + public Timer() { + super("Timer", false); + } + + public boolean isFreezing() { + return this.isEnabled() && this.mode.getValue() == 1; + } + + public static float getRequestedSpeed() { + float requestSpeed = requests.stream() + .max(Comparator.comparingInt(r -> r.priority)) + .map(r -> r.speed) + .orElse(-1f); + + if (requestSpeed > 0) return requestSpeed; + + Timer instance = Myau.moduleManager != null + ? (Timer) Myau.moduleManager.modules.get(Timer.class) + : null; + + if (instance != null && instance.isEnabled() && instance.mode.getValue() == 0) { + return instance.speed.getValue(); + } + + return 1.0f; + } + + public static void requestTimerSpeed(float speed, int priority, Object provider, int resetAfterTicks) { + requests.removeIf(r -> r.provider == provider); + requests.add(new TimerRequest(speed, priority, provider, resetAfterTicks + 1)); + } + + public static void cancelRequest(Object provider) { + requests.removeIf(r -> r.provider == provider); + } + + @EventTarget(Priority.HIGHEST) + public void onLivingUpdate(LivingUpdateEvent event) { + requests.forEach(r -> r.ticksLeft--); + requests.removeIf(r -> r.ticksLeft <= 0); + } + + @Override + public void onDisabled() { + requests.clear(); + } + + @Override + public String[] getSuffix() { + if (this.mode.getValue() == 1) { + return new String[]{"Freeze"}; + } + return new String[]{String.format("%.1fx", this.speed.getValue())}; + } + + private static class TimerRequest { + float speed; + int priority; + Object provider; + int ticksLeft; + + TimerRequest(float speed, int priority, Object provider, int ticksLeft) { + this.speed = speed; + this.priority = priority; + this.provider = provider; + this.ticksLeft = ticksLeft; + } + } +} \ No newline at end of file diff --git a/src/main/java/myau/module/modules/Tracers.java b/src/main/java/myau/module/modules/Tracers.java index 34a58383..19a7c46a 100644 --- a/src/main/java/myau/module/modules/Tracers.java +++ b/src/main/java/myau/module/modules/Tracers.java @@ -13,6 +13,7 @@ import myau.property.properties.BooleanProperty; import myau.property.properties.PercentProperty; import myau.property.properties.ModeProperty; +import myau.property.properties.IntProperty; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.GlStateManager; @@ -29,6 +30,7 @@ public class Tracers extends Module { public final BooleanProperty drawLines = new BooleanProperty("lines", true); public final BooleanProperty drawArrows = new BooleanProperty("arrows", false); public final PercentProperty opacity = new PercentProperty("opacity", 100); + public final IntProperty distance = new IntProperty("distance", 512, 0, 512); public final BooleanProperty showPlayers = new BooleanProperty("players", true); public final BooleanProperty showFriends = new BooleanProperty("friends", true); public final BooleanProperty showEnemies = new BooleanProperty("enemies", true); @@ -37,7 +39,7 @@ public class Tracers extends Module { private boolean shouldRender(EntityPlayer entityPlayer) { if (entityPlayer.deathTime > 0) { return false; - } else if (mc.getRenderViewEntity().getDistanceToEntity(entityPlayer) > 512.0F) { + } else if (mc.getRenderViewEntity().getDistanceToEntity(entityPlayer) > (float) this.distance.getValue()) { return false; } else if (entityPlayer != mc.thePlayer && entityPlayer != mc.getRenderViewEntity()) { if (TeamUtil.isBot(entityPlayer)) { @@ -195,4 +197,4 @@ public void onRender(Render2DEvent event) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/myau/property/properties/ColorProperty.java b/src/main/java/myau/property/properties/ColorProperty.java index 0481d765..af8c76e4 100644 --- a/src/main/java/myau/property/properties/ColorProperty.java +++ b/src/main/java/myau/property/properties/ColorProperty.java @@ -3,40 +3,52 @@ import com.google.gson.JsonObject; import myau.property.Property; +import java.awt.*; import java.util.function.BooleanSupplier; public class ColorProperty extends Property { public ColorProperty(String name, Integer color) { - this(name, color, null); + this(name, color, (BooleanSupplier)null); + } + + public ColorProperty(String name, Integer color, Integer alpha) { + this(name, color, alpha, null); } public ColorProperty(String string, Integer color, BooleanSupplier check) { - super(string, color, rgb -> rgb <= 16777215, check); + super(string, color, check); + } + + public ColorProperty(String name, Integer color, Integer alpha, BooleanSupplier check) { + this(name, color & 0xFFFFFF | alpha << 24, check); } @Override public String getValuePrompt() { - return "RGB"; + return "ARGB"; } @Override public String formatValue() { - String hex = String.format("%06X", this.getValue()).substring(0,6); - return String.format("&c%s&a%s&9%s", hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6)); + String hex = String.format("%08X", this.getValue()).substring(0,8); + return String.format("&r%s&c%s&a%s&9%s", hex.substring(0, 2), hex.substring(2, 4), hex.substring(4, 6), hex.substring(6, 8)); } @Override public boolean parseString(String string) { - return this.setValue(Integer.parseInt(string.replace("#", ""), 16)); + String s = string.replace("#", ""); + int i = Integer.parseUnsignedInt(s, 16); + return this.setValue(s.length() <= 6 ? i | 0xFF000000 : i); } @Override public boolean read(JsonObject jsonObject) { - return this.parseString(jsonObject.get(this.getName()).getAsString().substring(0,6)); + String s = jsonObject.get(this.getName()).getAsString(); + return this.parseString(s.length() > 8 ? s.substring(0, 8) : s); } @Override public void write(JsonObject jsonObject) { - jsonObject.addProperty(this.getName(), String.format("%06X", this.getValue())); + jsonObject.addProperty(this.getName(), String.format("%08X", this.getValue())); } -} +} \ No newline at end of file diff --git a/src/main/java/myau/ui/ClickGui.java b/src/main/java/myau/ui/ClickGui.java index 071632fd..c39832db 100644 --- a/src/main/java/myau/ui/ClickGui.java +++ b/src/main/java/myau/ui/ClickGui.java @@ -35,6 +35,7 @@ public ClickGui() { combatModules.add(Myau.moduleManager.getModule(Velocity.class)); combatModules.add(Myau.moduleManager.getModule(Freeze.class)); combatModules.add(Myau.moduleManager.getModule(Reach.class)); + combatModules.add(Myau.moduleManager.getModule(Backtrack.class)); combatModules.add(Myau.moduleManager.getModule(TargetStrafe.class)); combatModules.add(Myau.moduleManager.getModule(NoHitDelay.class)); combatModules.add(Myau.moduleManager.getModule(AntiFireball.class)); @@ -48,11 +49,13 @@ public ClickGui() { movementModules.add(Myau.moduleManager.getModule(AntiAFK.class)); movementModules.add(Myau.moduleManager.getModule(Fly.class)); movementModules.add(Myau.moduleManager.getModule(Speed.class)); + movementModules.add(Myau.moduleManager.getModule(myau.module.modules.Timer.class)); movementModules.add(Myau.moduleManager.getModule(LongJump.class)); movementModules.add(Myau.moduleManager.getModule(Sprint.class)); movementModules.add(Myau.moduleManager.getModule(SafeWalk.class)); movementModules.add(Myau.moduleManager.getModule(Jesus.class)); movementModules.add(Myau.moduleManager.getModule(Blink.class)); + movementModules.add(Myau.moduleManager.getModule(FakeLag.class)); movementModules.add(Myau.moduleManager.getModule(NoFall.class)); movementModules.add(Myau.moduleManager.getModule(NoSlow.class)); movementModules.add(Myau.moduleManager.getModule(KeepSprint.class)); @@ -86,6 +89,7 @@ public ClickGui() { playerModules.add(Myau.moduleManager.getModule(InvManager.class)); playerModules.add(Myau.moduleManager.getModule(InvWalk.class)); playerModules.add(Myau.moduleManager.getModule(Scaffold.class)); + playerModules.add(Myau.moduleManager.getModule(Clutch.class)); playerModules.add(Myau.moduleManager.getModule(AutoBlockIn.class)); playerModules.add(Myau.moduleManager.getModule(SpeedMine.class)); playerModules.add(Myau.moduleManager.getModule(FastPlace.class));