From 678438307e03f31f77df52a4d3c0196ac645631d Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Wed, 4 Dec 2024 22:05:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=BF=80=E5=85=89=E5=87=BB?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=BB=88=E7=82=B9=E4=BD=8D=E7=BD=AE=E5=88=A4?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/LaserEntity.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java index a74526c24..cf0a2c386 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/LaserEntity.java @@ -75,32 +75,32 @@ public class LaserEntity extends AbstractLaserEntity { collidePosY = hitVec.y; collidePosZ = hitVec.z; blockSide = result.getBlockHit().getDirection(); - } - - List entities = world.getEntitiesOfClass(LivingEntity.class, new AABB(Math.min(getX(), collidePosX), Math.min(getY(), collidePosY), Math.min(getZ(), collidePosZ), Math.max(getX(), collidePosX), Math.max(getY(), collidePosY), Math.max(getZ(), collidePosZ)).inflate(1, 1, 1)); - for (LivingEntity entity : entities) { - if (entity == this.caster) { - continue; - } - float pad = entity.getPickRadius() + getBaseScale(); - AABB aabb = entity.getBoundingBox().inflate(pad, pad, pad); - Optional hit = aabb.clip(from, to); - if (aabb.contains(from)) { - result.addEntityHit(entity); - } else if (hit.isPresent()) { - result.addEntityHit(entity); - } - } - - var target = result.getEntities().stream().min(Comparator.comparingDouble(e -> e.distanceToSqr(this.caster))); - if (target.isPresent()) { - collidePosX = target.get().getX(); - collidePosY = target.get().getY(); - collidePosZ = target.get().getZ(); } else { - collidePosX = endPosX; - collidePosY = endPosY; - collidePosZ = endPosZ; + List entities = world.getEntitiesOfClass(LivingEntity.class, new AABB(Math.min(getX(), collidePosX), Math.min(getY(), collidePosY), Math.min(getZ(), collidePosZ), Math.max(getX(), collidePosX), Math.max(getY(), collidePosY), Math.max(getZ(), collidePosZ)).inflate(1, 1, 1)); + for (LivingEntity entity : entities) { + if (entity == this.caster) { + continue; + } + float pad = entity.getPickRadius() + getBaseScale(); + AABB aabb = entity.getBoundingBox().inflate(pad, pad, pad); + Optional hit = aabb.clip(from, to); + if (aabb.contains(from)) { + result.addEntityHit(entity); + } else if (hit.isPresent()) { + result.addEntityHit(entity); + } + } + + var target = result.getEntities().stream().min(Comparator.comparingDouble(e -> e.distanceToSqr(this.caster))); + if (target.isPresent()) { + collidePosX = target.get().getX(); + collidePosY = target.get().getY(); + collidePosZ = target.get().getZ(); + } else { + collidePosX = endPosX; + collidePosY = endPosY; + collidePosZ = endPosZ; + } blockSide = null; }