Skip to content
This repository has been archived by the owner on Aug 10, 2018. It is now read-only.

Commit

Permalink
Improve speed of Nuker & Tunneller
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Feb 2, 2017
1 parent 6fdbc12 commit 267a341
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 18 deletions.
20 changes: 17 additions & 3 deletions src/tk/wurst_client/features/mods/NukerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand All @@ -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
Expand Down Expand Up @@ -191,7 +194,7 @@ public void onUpdate()

// break block
if(legit)
successful = BlockUtils.breakBlockLegit(pos);
successful = BlockUtils.prepareToBreakBlockLegit(pos);
else
successful = BlockUtils.breakBlockSimple(pos);

Expand All @@ -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)
{
Expand Down
28 changes: 20 additions & 8 deletions src/tk/wurst_client/features/mods/TunnellerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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);
}

Expand All @@ -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
Expand Down Expand Up @@ -108,7 +109,7 @@ public void onUpdate()

// break block
if(legit)
successful = BlockUtils.breakBlockLegit(pos);
successful = BlockUtils.prepareToBreakBlockLegit(pos);
else
successful = BlockUtils.breakBlockSimple(pos);

Expand All @@ -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)
{
Expand Down
33 changes: 32 additions & 1 deletion src/tk/wurst_client/utils/BlockUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 2 additions & 6 deletions src/tk/wurst_client/utils/RotationUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 267a341

Please sign in to comment.