Class RayTracer
java.lang.Object
com.binaris.wizardry.api.content.util.RayTracer
Utility class for performing ray trace operations in the world, including both block and entity detection.
Provides methods for tracing rays with aim assist and custom entity filtering.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Predicate<net.minecraft.world.entity.Entity>ignoreEntityFilter(@Nullable net.minecraft.world.entity.Entity entity) Creates a predicate that filters out the specified entity and dead living entities.static @NotNull net.minecraft.world.phys.HitResultrayTrace(net.minecraft.world.level.Level world, net.minecraft.world.entity.Entity caster, net.minecraft.world.phys.Vec3 origin, net.minecraft.world.phys.Vec3 endpoint, float aimAssist, boolean hitLiquids, Class<? extends net.minecraft.world.entity.Entity> entityType, Predicate<? super net.minecraft.world.entity.Entity> filter) Performs a ray trace from origin to endpoint, detecting both blocks and entities.static @NotNull net.minecraft.world.phys.HitResultstandardBlockRayTrace(net.minecraft.world.level.Level world, net.minecraft.world.entity.LivingEntity entity, double range, boolean hitLiquids, boolean ignoreUncollidables, boolean returnLastUncollidable) Performs a standard block ray trace from the entity's eye position in the direction they are looking.
-
Constructor Details
-
RayTracer
public RayTracer()
-
-
Method Details
-
rayTrace
@NotNull public static @NotNull net.minecraft.world.phys.HitResult rayTrace(net.minecraft.world.level.Level world, net.minecraft.world.entity.Entity caster, net.minecraft.world.phys.Vec3 origin, net.minecraft.world.phys.Vec3 endpoint, float aimAssist, boolean hitLiquids, Class<? extends net.minecraft.world.entity.Entity> entityType, Predicate<? super net.minecraft.world.entity.Entity> filter) Performs a ray trace from origin to endpoint, detecting both blocks and entities.- Parameters:
world- The world to perform the ray trace in.caster- The entity performing the ray trace.origin- The starting position of the ray.endpoint- The ending position of the ray.aimAssist- Additional size to inflate entity hitboxes for easier targeting.hitLiquids- Whether the ray should collide with liquid blocks.entityType- The class of entities to detect.filter- A predicate to filter out entities from the results.- Returns:
- The hit result of the ray trace, either a block hit or an entity hit.
-
standardBlockRayTrace
@NotNull public static @NotNull net.minecraft.world.phys.HitResult standardBlockRayTrace(net.minecraft.world.level.Level world, net.minecraft.world.entity.LivingEntity entity, double range, boolean hitLiquids, boolean ignoreUncollidables, boolean returnLastUncollidable) Performs a standard block ray trace from the entity's eye position in the direction they are looking.- Parameters:
world- The world to perform the ray trace in.entity- The entity performing the ray trace.range- The maximum distance to trace.hitLiquids- Whether the ray should collide with liquid blocks.ignoreUncollidables- Unused parameter (kept for API compatibility).returnLastUncollidable- Unused parameter (kept for API compatibility).- Returns:
- The hit result of the ray trace.
-
ignoreEntityFilter
public static Predicate<net.minecraft.world.entity.Entity> ignoreEntityFilter(@Nullable @Nullable net.minecraft.world.entity.Entity entity) Creates a predicate that filters out the specified entity and dead living entities.- Parameters:
entity- The entity to ignore, or null to only filter dead entities.- Returns:
- A predicate for filtering entities.
-