From 267a34155e205838b63a4d4e7f9ffc68ce701cd5 Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Thu, 2 Feb 2017 15:03:57 +0100 Subject: [PATCH] Improve speed of Nuker & Tunneller --- .../wurst_client/features/mods/NukerMod.java | 20 +++++++++-- .../features/mods/TunnellerMod.java | 28 +++++++++++----- src/tk/wurst_client/utils/BlockUtils.java | 33 ++++++++++++++++++- src/tk/wurst_client/utils/RotationUtils.java | 8 ++--- 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/src/tk/wurst_client/features/mods/NukerMod.java b/src/tk/wurst_client/features/mods/NukerMod.java index db908cf..e6a1131 100644 --- a/src/tk/wurst_client/features/mods/NukerMod.java +++ b/src/tk/wurst_client/features/mods/NukerMod.java @@ -13,6 +13,7 @@ import net.minecraft.util.math.BlockPos; import tk.wurst_client.events.LeftClickEvent; import tk.wurst_client.events.listeners.LeftClickListener; +import tk.wurst_client.events.listeners.PostUpdateListener; import tk.wurst_client.events.listeners.RenderListener; import tk.wurst_client.events.listeners.UpdateListener; import tk.wurst_client.features.Feature; @@ -30,8 +31,8 @@ name = "Nuker", help = "Mods/Nuker") @Mod.Bypasses -public class NukerMod extends Mod - implements LeftClickListener, UpdateListener, RenderListener +public class NukerMod extends Mod implements LeftClickListener, UpdateListener, + PostUpdateListener, RenderListener { public int id = 0; private BlockPos currentBlock; @@ -112,6 +113,7 @@ public void onEnable() // add listeners wurst.events.add(LeftClickListener.class, this); wurst.events.add(UpdateListener.class, this); + wurst.events.add(PostUpdateListener.class, this); wurst.events.add(RenderListener.class, this); } @@ -121,6 +123,7 @@ public void onDisable() // remove listeners wurst.events.remove(LeftClickListener.class, this); wurst.events.remove(UpdateListener.class, this); + wurst.events.remove(PostUpdateListener.class, this); wurst.events.remove(RenderListener.class, this); // resets @@ -191,7 +194,7 @@ public void onUpdate() // break block if(legit) - successful = BlockUtils.breakBlockLegit(pos); + successful = BlockUtils.prepareToBreakBlockLegit(pos); else successful = BlockUtils.breakBlockSimple(pos); @@ -208,6 +211,17 @@ public void onUpdate() mc.playerController.resetBlockRemoving(); } + @Override + public void afterUpdate() + { + boolean legit = wurst.special.yesCheatSpf.getBypassLevel() + .ordinal() > BypassLevel.MINEPLEX.ordinal(); + + // break block + if(currentBlock != null && legit) + BlockUtils.breakBlockLegit(currentBlock); + } + @Override public void onRender(float partialTicks) { diff --git a/src/tk/wurst_client/features/mods/TunnellerMod.java b/src/tk/wurst_client/features/mods/TunnellerMod.java index f0bd33c..f3780b2 100644 --- a/src/tk/wurst_client/features/mods/TunnellerMod.java +++ b/src/tk/wurst_client/features/mods/TunnellerMod.java @@ -9,6 +9,7 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; +import tk.wurst_client.events.listeners.PostUpdateListener; import tk.wurst_client.events.listeners.RenderListener; import tk.wurst_client.events.listeners.UpdateListener; import tk.wurst_client.features.Feature; @@ -21,7 +22,8 @@ name = "Tunneller", help = "Mods/Tunneller") @Mod.Bypasses -public class TunnellerMod extends Mod implements RenderListener, UpdateListener +public class TunnellerMod extends Mod + implements UpdateListener, PostUpdateListener, RenderListener { private BlockPos currentBlock; @@ -38,15 +40,13 @@ public Feature[] getSeeAlso() public void onEnable() { // disable other nukers - if(wurst.mods.nukerMod.isEnabled()) - wurst.mods.nukerMod.setEnabled(false); - if(wurst.mods.nukerLegitMod.isEnabled()) - wurst.mods.nukerLegitMod.setEnabled(false); - if(wurst.mods.speedNukerMod.isEnabled()) - wurst.mods.speedNukerMod.setEnabled(false); + wurst.mods.nukerMod.setEnabled(false); + wurst.mods.nukerLegitMod.setEnabled(false); + wurst.mods.speedNukerMod.setEnabled(false); // add listeners wurst.events.add(UpdateListener.class, this); + wurst.events.add(PostUpdateListener.class, this); wurst.events.add(RenderListener.class, this); } @@ -55,6 +55,7 @@ public void onDisable() { // remove listeners wurst.events.remove(UpdateListener.class, this); + wurst.events.remove(PostUpdateListener.class, this); wurst.events.remove(RenderListener.class, this); // resets @@ -108,7 +109,7 @@ public void onUpdate() // break block if(legit) - successful = BlockUtils.breakBlockLegit(pos); + successful = BlockUtils.prepareToBreakBlockLegit(pos); else successful = BlockUtils.breakBlockSimple(pos); @@ -125,6 +126,17 @@ public void onUpdate() mc.playerController.resetBlockRemoving(); } + @Override + public void afterUpdate() + { + boolean legit = wurst.special.yesCheatSpf.getBypassLevel() + .ordinal() > BypassLevel.MINEPLEX.ordinal(); + + // break block + if(currentBlock != null && legit) + BlockUtils.breakBlockLegit(currentBlock); + } + @Override public void onRender(float partialTicks) { diff --git a/src/tk/wurst_client/utils/BlockUtils.java b/src/tk/wurst_client/utils/BlockUtils.java index 2aeaaad..d054a4e 100644 --- a/src/tk/wurst_client/utils/BlockUtils.java +++ b/src/tk/wurst_client/utils/BlockUtils.java @@ -158,7 +158,7 @@ public static boolean placeBlockSimple(BlockPos pos) return false; } - public static boolean breakBlockLegit(BlockPos pos) + public static boolean prepareToBreakBlockLegit(BlockPos pos) { Vec3d eyesPos = RotationUtils.getEyesPos(); Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5); @@ -190,6 +190,37 @@ public static boolean breakBlockLegit(BlockPos pos) if(!RotationUtils.faceVectorPacket(hitVec)) return true; + return true; + } + + return false; + } + + public static boolean breakBlockLegit(BlockPos pos) + { + Vec3d eyesPos = RotationUtils.getEyesPos(); + Vec3d posVec = new Vec3d(pos).addVector(0.5, 0.5, 0.5); + double distanceSqPosVec = eyesPos.squareDistanceTo(posVec); + + for(EnumFacing side : EnumFacing.values()) + { + Vec3d hitVec = + posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5)); + double distanceSqHitVec = eyesPos.squareDistanceTo(hitVec); + + // check if hitVec is within range (4.25 blocks) + if(distanceSqHitVec > 18.0625) + continue; + + // check if side is facing towards player + if(distanceSqHitVec >= distanceSqPosVec) + continue; + + // check line of sight + if(mc.world.rayTraceBlocks(eyesPos, hitVec, false, true, + false) != null) + continue; + // damage block if(!mc.playerController.onPlayerDamageBlock(pos, side)) return false; diff --git a/src/tk/wurst_client/utils/RotationUtils.java b/src/tk/wurst_client/utils/RotationUtils.java index c1d642a..5e0f2bd 100644 --- a/src/tk/wurst_client/utils/RotationUtils.java +++ b/src/tk/wurst_client/utils/RotationUtils.java @@ -82,14 +82,10 @@ public static boolean faceVectorPacket(Vec3d vec) float[] rotations = getNeededRotations(vec); - float oldYaw = serverYaw; - float oldPitch = serverPitch; - - serverYaw = limitAngleChange(oldYaw, rotations[0], 30); + serverYaw = limitAngleChange(serverYaw, rotations[0], 30); serverPitch = rotations[1]; - return Math.abs(oldYaw - rotations[0]) - + Math.abs(oldPitch - rotations[1]) < 1F; + return Math.abs(serverYaw - rotations[0]) < 1F; } public static void faceVectorPacketInstant(Vec3d vec)