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.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())

View File

@ -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;