From 89fd45efda0749ba3791e85a1b1c7e28280dae67 Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Tue, 11 Mar 2025 22:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=9B=E9=80=A0=E5=BC=B9?= =?UTF-8?q?=E8=8D=AF=E7=9B=92=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../superbwarfare/entity/vehicle/Ah6Entity.java | 7 ++++++- .../superbwarfare/entity/vehicle/Bmp2Entity.java | 11 ++++++++++- .../superbwarfare/entity/vehicle/Lav150Entity.java | 10 +++++++++- .../superbwarfare/entity/vehicle/SpeedboatEntity.java | 7 ++++++- .../superbwarfare/entity/vehicle/Yx100Entity.java | 8 +++++++- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index 4684fb231..6df08e798 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -560,7 +560,12 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity @Override public void vehicleShoot(Player player, int type) { - boolean hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player); + boolean hasCreativeAmmo = false; + for (int i = 0; i < getMaxPassengers() - 1; i++) { + if (getNthEntity(i) instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) { + hasCreativeAmmo = true; + } + } Matrix4f transform = getVehicleTransform(); float x; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index 599387d8c..cbb5844c6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -335,6 +335,13 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit @Override public void vehicleShoot(Player player, int type) { + boolean hasCreativeAmmo = false; + for (int i = 0; i < getMaxPassengers() - 1; i++) { + if (getNthEntity(i) instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) { + hasCreativeAmmo = true; + } + } + Matrix4f transform = getBarrelTransform(); if (getWeaponIndex(0) == 0) { if (this.cannotFire) return; @@ -373,6 +380,9 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit this.entityData.set(HEAT, this.entityData.get(HEAT) + 7); this.entityData.set(FIRE_ANIM, 3); + + if (hasCreativeAmmo) return; + this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } else if (getWeaponIndex(0) == 1) { if (this.cannotFireCoax) return; @@ -381,7 +391,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit float z = 2f; Vector4f worldPosition = transformPosition(transform, x, y, z); - boolean hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player); if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) { var projectileRight = ((ProjectileWeapon) getWeapon(0)).create(player); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 23a934c52..c544bb1e5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -294,7 +294,12 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt @Override public void vehicleShoot(Player player, int type) { - boolean hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player); + boolean hasCreativeAmmo = false; + for (int i = 0; i < getMaxPassengers() - 1; i++) { + if (getNthEntity(i) instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) { + hasCreativeAmmo = true; + } + } Matrix4f transform = getBarrelTransform(); if (getWeaponIndex(0) == 0) { @@ -334,6 +339,9 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt this.entityData.set(HEAT, this.entityData.get(HEAT) + 7); this.entityData.set(FIRE_ANIM, 3); + + if (hasCreativeAmmo) return; + this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1)); } else if (getWeaponIndex(0) == 1) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index 052098446..ab232c82d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -282,7 +282,12 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo this.entityData.set(HEAT, this.entityData.get(HEAT) + 4); this.entityData.set(FIRE_ANIM, 3); - boolean hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player); + boolean hasCreativeAmmo = false; + for (int i = 0; i < getMaxPassengers() - 1; i++) { + if (getNthEntity(i) instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) { + hasCreativeAmmo = true; + } + } if (!hasCreativeAmmo) { ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index 9f32d8561..66b055e4d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -357,6 +357,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti @Override public void vehicleShoot(Player player, int type) { + boolean hasCreativeAmmo = false; + for (int i = 0; i < getMaxPassengers() - 1; i++) { + if (getNthEntity(i) instanceof Player pPlayer && InventoryTool.hasCreativeAmmoBox(pPlayer)) { + hasCreativeAmmo = true; + } + } if (reloadCoolDown == 0 && type == 0) { if (!this.canConsume(SHOOT_COST)) { @@ -478,7 +484,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti } } - if (hasItem(ModItems.CREATIVE_AMMO_BOX.get())) return; + if (hasCreativeAmmo) return; ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> { if (stack.is(ModItems.AMMO_BOX.get())) {