Java Code Examples for net.minecraft.entity.Entity#getCameraPosVec()

The following examples show how to use net.minecraft.entity.Entity#getCameraPosVec() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Tracer.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static BlockHitResult rayTraceBlocks(Entity source, float partialTicks, double reach, boolean fluids)
{
    Vec3d pos = source.getCameraPosVec(partialTicks);
    Vec3d rotation = source.getRotationVec(partialTicks);
    Vec3d reachEnd = pos.add(rotation.x * reach, rotation.y * reach, rotation.z * reach);
    return source.world.rayTrace(new RayTraceContext(pos, reachEnd, RayTraceContext.ShapeType.OUTLINE, fluids ? RayTraceContext.FluidHandling.ANY : RayTraceContext.FluidHandling.NONE, source));
}
 
Example 2
Source File: Tracer.java    From fabric-carpet with MIT License 5 votes vote down vote up
public static EntityHitResult rayTraceEntities(Entity source, float partialTicks, double reach, double maxSqDist)
{
    Vec3d pos = source.getCameraPosVec(partialTicks);
    Vec3d reachVec = source.getRotationVec(partialTicks).multiply(reach);
    Box box = source.getBoundingBox().stretch(reachVec).expand(1);
    return rayTraceEntities(source, pos, pos.add(reachVec), box, e -> !e.isSpectator() && e.collides(), maxSqDist);
}