From 6633cc772378f7dfb5331ade0359c29c760d9147 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Sun, 8 Jun 2025 15:26:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96javelin=E7=9A=84=E7=9B=AE?= =?UTF-8?q?=E6=A0=87=E9=94=81=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../item/gun/launcher/JavelinItem.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java index 4e1a05b88..532bd12dd 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java @@ -116,14 +116,12 @@ public class JavelinItem extends GunItem { } Entity targetEntity = EntityFindUtil.findEntity(player.level(), tag.getString("TargetEntity")); - Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8); - if (tag.getInt("GuideType") == 0) { - if (seekingEntity != null && seekingEntity == targetEntity) { + if (targetEntity != null && VectorTool.calculateAngle(player.getViewVector(1), player.getEyePosition().vectorTo(targetEntity.getBoundingBox().getCenter())) < 8) { tag.putInt("SeekTime", tag.getInt("SeekTime") + 1); - if (tag.getInt("SeekTime") > 0 && (!seekingEntity.getPassengers().isEmpty() || seekingEntity instanceof VehicleEntity) && seekingEntity.tickCount % 3 == 0) { - seekingEntity.level().playSound(null, seekingEntity.getOnPos(), seekingEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKING_WARNING.get(), SoundSource.PLAYERS, 1, 1f); + if (tag.getInt("SeekTime") > 0 && (!targetEntity.getPassengers().isEmpty() || targetEntity instanceof VehicleEntity) && targetEntity.tickCount % 3 == 0) { + targetEntity.level().playSound(null, targetEntity.getOnPos(), targetEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKING_WARNING.get(), SoundSource.PLAYERS, 1, 1f); } } else { tag.putInt("SeekTime", 0); @@ -133,12 +131,12 @@ public class JavelinItem extends GunItem { SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCK.get(), 1, 1); } - if (seekingEntity != null && tag.getInt("SeekTime") > 20) { + if (targetEntity != null && tag.getInt("SeekTime") > 20) { if (player instanceof ServerPlayer serverPlayer) { SoundTool.playLocalSound(serverPlayer, ModSounds.JAVELIN_LOCKON.get(), 1, 1); } - if ((!seekingEntity.getPassengers().isEmpty() || seekingEntity instanceof VehicleEntity) && seekingEntity.tickCount % 2 == 0) { - seekingEntity.level().playSound(null, seekingEntity.getOnPos(), seekingEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKED_WARNING.get(), SoundSource.PLAYERS, 1, 0.95f); + if ((!targetEntity.getPassengers().isEmpty() || targetEntity instanceof VehicleEntity) && targetEntity.tickCount % 2 == 0) { + targetEntity.level().playSound(null, targetEntity.getOnPos(), targetEntity instanceof Pig ? SoundEvents.PIG_HURT : ModSounds.LOCKED_WARNING.get(), SoundSource.PLAYERS, 1, 0.95f); } } @@ -161,6 +159,12 @@ public class JavelinItem extends GunItem { } } } + + Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8); + + if (seekingEntity instanceof DecoyEntity) { + tag.putInt("SeekTime", 0); + } } } else { tag.putInt("SeekTime", 0);