0
0
mirror of https://github.com/Wurst-Imperium/Wurst7.git synced 2024-09-19 17:02:13 +02:00

Fix incorrect trajectories when holding a fishing rod

This commit is contained in:
Alexander01998 2024-01-06 23:29:28 +01:00
parent ffe2d3c929
commit 92ee2d4fd8
2 changed files with 21 additions and 5 deletions

View File

@ -33,6 +33,7 @@ import net.minecraft.util.hit.EntityHitResult;
import net.minecraft.util.hit.HitResult; import net.minecraft.util.hit.HitResult;
import net.minecraft.util.math.Box; import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import net.minecraft.world.RaycastContext.FluidHandling;
import net.wurstclient.Category; import net.wurstclient.Category;
import net.wurstclient.SearchTags; import net.wurstclient.SearchTags;
import net.wurstclient.events.RenderListener; import net.wurstclient.events.RenderListener;
@ -185,6 +186,7 @@ public final class TrajectoriesHack extends Hack implements RenderListener
Item item = stack.getItem(); Item item = stack.getItem();
double throwPower = getThrowPower(item); double throwPower = getThrowPower(item);
double gravity = getProjectileGravity(item); double gravity = getProjectileGravity(item);
FluidHandling fluidHandling = getFluidHandling(item);
// prepare yaw and pitch // prepare yaw and pitch
double yaw = Math.toRadians(player.getYaw()); double yaw = Math.toRadians(player.getYaw());
@ -216,7 +218,8 @@ public final class TrajectoriesHack extends Hack implements RenderListener
: RotationUtils.getEyesPos(); : RotationUtils.getEyesPos();
// check for block collision // check for block collision
BlockHitResult bResult = BlockUtils.raycast(lastPos, arrowPos); BlockHitResult bResult =
BlockUtils.raycast(lastPos, arrowPos, fluidHandling);
if(bResult.getType() != HitResult.Type.MISS) if(bResult.getType() != HitResult.Type.MISS)
{ {
// replace last pos with the collision point // replace last pos with the collision point
@ -304,6 +307,14 @@ public final class TrajectoriesHack extends Hack implements RenderListener
return 0.03; return 0.03;
} }
private FluidHandling getFluidHandling(Item item)
{
if(item instanceof FishingRodItem)
return FluidHandling.ANY;
return FluidHandling.NONE;
}
public static boolean isThrowable(ItemStack stack) public static boolean isThrowable(ItemStack stack)
{ {
if(stack.isEmpty()) if(stack.isEmpty())

View File

@ -132,15 +132,20 @@ public enum BlockUtils
return getState(pos).isOpaqueFullCube(MC.world, pos); 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 = RaycastContext context = new RaycastContext(from, to,
new RaycastContext(from, to, RaycastContext.ShapeType.COLLIDER, RaycastContext.ShapeType.COLLIDER, fluidHandling, MC.player);
RaycastContext.FluidHandling.NONE, MC.player);
return MC.world.raycast(context); 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) public static boolean hasLineOfSight(Vec3d from, Vec3d to)
{ {
return raycast(from, to).getType() == HitResult.Type.MISS; return raycast(from, to).getType() == HitResult.Type.MISS;