package ar.com.companeros.horror; import net.minecraft.world.entity.Mob; import net.minecraft.world.level.CollisionGetter; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; /** Espacio físico del cuerpo: todas las consultas usan las formas de colisión reales. */ final class ParasiteClearance { static final float WIDTH = .6F; static final float COMPACT_HEIGHT = .85F; static final int TRANSITION_TICKS = 12; private static final double EPSILON = 1.0E-5; private ParasiteClearance() { } static AABB bodyAt(Vec3 feet, float height) { double radius = WIDTH / 2D; return new AABB(feet.x - radius, feet.y, feet.z - radius, feet.x + radius, feet.y + height, feet.z + radius).deflate(EPSILON); } static boolean fits(CollisionGetter world, Mob body, Vec3 feet, float height) { return world.noCollision(body, bodyAt(feet, height)); } // Barrido corto y acotado; una escotilla abierta conserva su placa vertical como obstáculo. static boolean clearSegment(CollisionGetter world, Mob body, Vec3 from, Vec3 to, float height) { Vec3 offset = to.subtract(from); int samples = Math.max(1, Math.min(12, (int) Math.ceil(offset.length() / .2))); for (int step = 0; step <= samples; step++) { if (!fits(world, body, from.add(offset.scale(step / (double) samples)), height)) return false; } return true; } }