From e34e037576982273b07fb2f7da80192a70c7ef3b Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Wed, 3 May 2023 12:34:59 +0200 Subject: [PATCH] Improve the precision of Trajectories --- .../net/wurstclient/hacks/TrajectoriesHack.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java b/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java index d67df0fc..b8efc9e5 100644 --- a/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java +++ b/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java @@ -28,6 +28,7 @@ import net.minecraft.entity.projectile.ProjectileUtil; import net.minecraft.item.*; import net.minecraft.util.Arm; import net.minecraft.util.Hand; +import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.Box; @@ -217,12 +218,15 @@ public final class TrajectoriesHack extends Hack implements RenderListener : RotationUtils.getEyesPos(); // check for block collision - RaycastContext bContext = new RaycastContext(lastPos, arrowPos, - RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.NONE, MC.player); - if(MC.world.raycast(bContext).getType() != HitResult.Type.MISS) + BlockHitResult bResult = + MC.world.raycast(new RaycastContext(lastPos, arrowPos, + RaycastContext.ShapeType.COLLIDER, + RaycastContext.FluidHandling.NONE, MC.player)); + if(bResult.getType() != HitResult.Type.MISS) { + // replace last pos with the collision point type = HitResult.Type.BLOCK; + path.set(path.size() - 1, bResult.getPos()); break; } @@ -234,7 +238,9 @@ public final class TrajectoriesHack extends Hack implements RenderListener arrowPos, box, predicate, maxDistSq); if(eResult != null && eResult.getType() != HitResult.Type.MISS) { + // replace last pos with the collision point type = HitResult.Type.ENTITY; + path.set(path.size() - 1, eResult.getPos()); break; } }