修复创造弹药盒读取
This commit is contained in:
parent
4dab918583
commit
89fd45efda
5 changed files with 38 additions and 5 deletions
|
@ -560,7 +560,12 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void vehicleShoot(Player player, int type) {
|
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();
|
Matrix4f transform = getVehicleTransform();
|
||||||
float x;
|
float x;
|
||||||
|
|
|
@ -335,6 +335,13 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void vehicleShoot(Player player, int type) {
|
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();
|
Matrix4f transform = getBarrelTransform();
|
||||||
if (getWeaponIndex(0) == 0) {
|
if (getWeaponIndex(0) == 0) {
|
||||||
if (this.cannotFire) return;
|
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(HEAT, this.entityData.get(HEAT) + 7);
|
||||||
this.entityData.set(FIRE_ANIM, 3);
|
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));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
} else if (getWeaponIndex(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
if (this.cannotFireCoax) return;
|
if (this.cannotFireCoax) return;
|
||||||
|
@ -381,7 +391,6 @@ public class Bmp2Entity extends ContainerMobileVehicleEntity implements GeoEntit
|
||||||
float z = 2f;
|
float z = 2f;
|
||||||
|
|
||||||
Vector4f worldPosition = transformPosition(transform, x, y, z);
|
Vector4f worldPosition = transformPosition(transform, x, y, z);
|
||||||
boolean hasCreativeAmmo = InventoryTool.hasCreativeAmmoBox(player);
|
|
||||||
|
|
||||||
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
|
if (this.entityData.get(AMMO) > 0 || hasCreativeAmmo) {
|
||||||
var projectileRight = ((ProjectileWeapon) getWeapon(0)).create(player);
|
var projectileRight = ((ProjectileWeapon) getWeapon(0)).create(player);
|
||||||
|
|
|
@ -294,7 +294,12 @@ public class Lav150Entity extends ContainerMobileVehicleEntity implements GeoEnt
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void vehicleShoot(Player player, int type) {
|
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();
|
Matrix4f transform = getBarrelTransform();
|
||||||
if (getWeaponIndex(0) == 0) {
|
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(HEAT, this.entityData.get(HEAT) + 7);
|
||||||
this.entityData.set(FIRE_ANIM, 3);
|
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));
|
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.SMALL_SHELL.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||||
|
|
||||||
} else if (getWeaponIndex(0) == 1) {
|
} else if (getWeaponIndex(0) == 1) {
|
||||||
|
|
|
@ -282,7 +282,12 @@ public class SpeedboatEntity extends ContainerMobileVehicleEntity implements Geo
|
||||||
this.entityData.set(HEAT, this.entityData.get(HEAT) + 4);
|
this.entityData.set(HEAT, this.entityData.get(HEAT) + 4);
|
||||||
this.entityData.set(FIRE_ANIM, 3);
|
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) {
|
if (!hasCreativeAmmo) {
|
||||||
ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> {
|
ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> {
|
||||||
|
|
|
@ -357,6 +357,12 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void vehicleShoot(Player player, int type) {
|
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 (reloadCoolDown == 0 && type == 0) {
|
||||||
|
|
||||||
if (!this.canConsume(SHOOT_COST)) {
|
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 -> {
|
ItemStack ammoBox = this.getItemStacks().stream().filter(stack -> {
|
||||||
if (stack.is(ModItems.AMMO_BOX.get())) {
|
if (stack.is(ModItems.AMMO_BOX.get())) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue