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())) {