From 8ff78be2cc81511de71932a2aef5b3babd063eae Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 15 Dec 2024 16:47:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=BF=AB=E8=89=87=E7=9A=84?= =?UTF-8?q?=E4=B9=98=E5=AE=A2=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/entity/SpeedboatEntity.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java index 2d6dea850..4c45d8e05 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java @@ -332,7 +332,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, gunnerAngle(); gunnerFire(); - testRiding(); + attractEntity(); this.refreshDimensions(); } @@ -575,15 +575,18 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, } } - // TODO 移除此方法 - public void testRiding() { - List list = this.level().getEntities(this, this.getBoundingBox().inflate((double) 0.2F, (double) -0.01F, (double) 0.2F), EntitySelector.pushableBy(this)); + public boolean hasEnoughSpaceFor(Entity pEntity) { + return pEntity.getBbWidth() < this.getBbWidth(); + } + + public void attractEntity() { + List list = this.level().getEntities(this, this.getBoundingBox().inflate(0.2F, -0.01F, 0.2F), EntitySelector.pushableBy(this)); if (!list.isEmpty()) { boolean flag = !this.level().isClientSide && !(this.getControllingPassenger() instanceof Player); for (Entity entity : list) { if (!entity.hasPassenger(this)) { - if (flag && this.getPassengers().size() < this.getMaxPassengers() && !entity.isPassenger() && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { + if (flag && this.getPassengers().size() < this.getMaxPassengers() && !entity.isPassenger() && this.hasEnoughSpaceFor(entity) && entity instanceof LivingEntity && !(entity instanceof WaterAnimal) && !(entity instanceof Player)) { entity.startRiding(this); } else { this.push(entity);