From 92ee2d4fd8f7984bf1eb29f7d1b222ef9e6ae2ff Mon Sep 17 00:00:00 2001 From: Alexander01998 Date: Sat, 6 Jan 2024 23:29:28 +0100 Subject: [PATCH] Fix incorrect trajectories when holding a fishing rod --- .../net/wurstclient/hacks/TrajectoriesHack.java | 13 ++++++++++++- src/main/java/net/wurstclient/util/BlockUtils.java | 13 +++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java b/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java index d7e406ba..f99dbca6 100644 --- a/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java +++ b/src/main/java/net/wurstclient/hacks/TrajectoriesHack.java @@ -33,6 +33,7 @@ import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.hit.HitResult; import net.minecraft.util.math.Box; import net.minecraft.util.math.Vec3d; +import net.minecraft.world.RaycastContext.FluidHandling; import net.wurstclient.Category; import net.wurstclient.SearchTags; import net.wurstclient.events.RenderListener; @@ -185,6 +186,7 @@ public final class TrajectoriesHack extends Hack implements RenderListener Item item = stack.getItem(); double throwPower = getThrowPower(item); double gravity = getProjectileGravity(item); + FluidHandling fluidHandling = getFluidHandling(item); // prepare yaw and pitch double yaw = Math.toRadians(player.getYaw()); @@ -216,7 +218,8 @@ public final class TrajectoriesHack extends Hack implements RenderListener : RotationUtils.getEyesPos(); // check for block collision - BlockHitResult bResult = BlockUtils.raycast(lastPos, arrowPos); + BlockHitResult bResult = + BlockUtils.raycast(lastPos, arrowPos, fluidHandling); if(bResult.getType() != HitResult.Type.MISS) { // replace last pos with the collision point @@ -304,6 +307,14 @@ public final class TrajectoriesHack extends Hack implements RenderListener return 0.03; } + private FluidHandling getFluidHandling(Item item) + { + if(item instanceof FishingRodItem) + return FluidHandling.ANY; + + return FluidHandling.NONE; + } + public static boolean isThrowable(ItemStack stack) { if(stack.isEmpty()) diff --git a/src/main/java/net/wurstclient/util/BlockUtils.java b/src/main/java/net/wurstclient/util/BlockUtils.java index 2311f39a..7c96963d 100644 --- a/src/main/java/net/wurstclient/util/BlockUtils.java +++ b/src/main/java/net/wurstclient/util/BlockUtils.java @@ -132,15 +132,20 @@ public enum BlockUtils return getState(pos).isOpaqueFullCube(MC.world, pos); } - public static BlockHitResult raycast(Vec3d from, Vec3d to) + public static BlockHitResult raycast(Vec3d from, Vec3d to, + RaycastContext.FluidHandling fluidHandling) { - RaycastContext context = - new RaycastContext(from, to, RaycastContext.ShapeType.COLLIDER, - RaycastContext.FluidHandling.NONE, MC.player); + RaycastContext context = new RaycastContext(from, to, + RaycastContext.ShapeType.COLLIDER, fluidHandling, MC.player); return MC.world.raycast(context); } + public static BlockHitResult raycast(Vec3d from, Vec3d to) + { + return raycast(from, to, RaycastContext.FluidHandling.NONE); + } + public static boolean hasLineOfSight(Vec3d from, Vec3d to) { return raycast(from, to).getType() == HitResult.Type.MISS;