From 420a71a4eec1f92da5af4b0bc43c1e6c3cc0c657 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sat, 14 Sep 2024 22:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E8=A7=A3=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=BD=9C=E5=9C=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/ProjectileEntity.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java index c96f93af2..b6e898cbb 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java @@ -87,6 +87,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa || input.getBlock() instanceof TrapDoorBlock || input.getBlock() instanceof BarbedWireBlock); + @Nullable protected LivingEntity shooter; protected int shooterId; private float damage = 1f; @@ -321,8 +322,10 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa } if (state.getBlock() instanceof TargetBlock) { + if (this.shooter == null) return; + int rings = getRings(blockHitResult, hitVec); - double dis = shooter.position().distanceTo(hitVec); + double dis = this.shooter.position().distanceTo(hitVec); recordHitScore(rings, dis); } @@ -422,6 +425,8 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa // TODO 实现穿甲比例大于1时的穿透生物效果 protected void onHitEntity(Entity entity, boolean headshot, boolean legShot) { + if (this.shooter == null) return; + float mMultiple = 1 + this.monsterMultiple; if (entity == null) return; @@ -449,7 +454,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa p -> p.sendSystemMessage( Component.translatable("death.attack.beast_gun", victim.getDisplayName(), - shooter.getDisplayName() + shooter == null ? "" : shooter.getDisplayName() ) ) );