修复创造弹药盒读取

This commit is contained in:
Atsuihsio 2025-03-11 22:39:59 +08:00
parent 4dab918583
commit 89fd45efda
5 changed files with 38 additions and 5 deletions

View file

@ -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;

View file

@ -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);

View file

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

View file

@ -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 -> {

View file

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