Line Of Sight Changes
This commit is contained in:
@@ -643,6 +643,23 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
return this.getHandle().hasLineOfSight(((CraftEntity) other).getHandle());
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public boolean hasLineOfSight(Location loc) {
|
||||
if (this.getHandle().level() != ((CraftWorld) loc.getWorld()).getHandle()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
net.minecraft.world.phys.Vec3 start = new net.minecraft.world.phys.Vec3(this.getHandle().getX(), this.getHandle().getEyeY(), this.getHandle().getZ());
|
||||
net.minecraft.world.phys.Vec3 end = new net.minecraft.world.phys.Vec3(loc.getX(), loc.getY(), loc.getZ());
|
||||
if (end.distanceToSqr(start) > 128D * 128D) {
|
||||
return false; // Return early if the distance is greater than 128 blocks
|
||||
}
|
||||
|
||||
return this.getHandle().level().clipDirect(start, end, net.minecraft.world.phys.shapes.CollisionContext.of(this.getHandle())) == net.minecraft.world.phys.HitResult.Type.MISS;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public boolean getRemoveWhenFarAway() {
|
||||
return this.getHandle() instanceof Mob && !((Mob) this.getHandle()).isPersistenceRequired();
|
||||
|
||||
Reference in New Issue
Block a user