修复载具导致的崩溃问题
This commit is contained in:
parent
5abdadf0c9
commit
863f6a3cde
5 changed files with 17 additions and 26 deletions
|
@ -182,8 +182,7 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli
|
|||
if (decoyReloadCoolDown > 0) {
|
||||
decoyReloadCoolDown--;
|
||||
}
|
||||
Player player = (Player) this.getFirstPassenger();
|
||||
if (player != null) {
|
||||
if (this.getFirstPassenger() instanceof Player player) {
|
||||
if ((this.getItemStacks().stream().filter(stack -> stack.is(ModItems.ROCKET_70.get())).mapToInt(ItemStack::getCount).sum() > 0 || player.getInventory().hasAnyMatching(s -> s.is(ModItems.CREATIVE_AMMO_BOX.get()))) && reloadCoolDown == 0 && this.getEntityData().get(LOADED_ROCKET) < 14) {
|
||||
this.entityData.set(LOADED_ROCKET, this.getEntityData().get(LOADED_ROCKET) + 1);
|
||||
reloadCoolDown = 25;
|
||||
|
|
|
@ -211,8 +211,7 @@ public class Bmp2Entity extends ContainerMobileEntity implements GeoEntity, ICha
|
|||
}
|
||||
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
Player player = (Player) this.getFirstPassenger();
|
||||
if (player != null) {
|
||||
if (this.getFirstPassenger() instanceof Player player) {
|
||||
if ((this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO_BOX.get())).mapToInt(ItemStack::getCount).sum() > 0 && this.getEntityData().get(LOADED_COAX_AMMO) < 500)) {
|
||||
this.entityData.set(LOADED_COAX_AMMO, this.getEntityData().get(LOADED_COAX_AMMO) + 30);
|
||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO_BOX.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||
|
|
|
@ -194,8 +194,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
|
|||
}
|
||||
|
||||
if (this.level() instanceof ServerLevel) {
|
||||
Player player = (Player) this.getFirstPassenger();
|
||||
if (player != null) {
|
||||
if (this.getFirstPassenger() instanceof Player player) {
|
||||
if ((this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO_BOX.get())).mapToInt(ItemStack::getCount).sum() > 0 && this.getEntityData().get(LOADED_COAX_AMMO) < 500)) {
|
||||
this.entityData.set(LOADED_COAX_AMMO, this.getEntityData().get(LOADED_COAX_AMMO) + 30);
|
||||
this.getItemStacks().stream().filter(stack -> stack.is(ModItems.RIFLE_AMMO_BOX.get())).findFirst().ifPresent(stack -> stack.shrink(1));
|
||||
|
@ -265,12 +264,6 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
|
|||
turretYRotO = deltaT + getTurretYRot();
|
||||
}
|
||||
|
||||
// Player player = (Player) this.getFirstPassenger();
|
||||
//
|
||||
// if (player != null) {
|
||||
// player.displayClientMessage(Component.literal( new DecimalFormat("##").format(getTurretYRot())), true);
|
||||
// }
|
||||
|
||||
collideBlock();
|
||||
gunnerAngle();
|
||||
lowHealthWarning();
|
||||
|
@ -295,8 +288,6 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
|
|||
// Vec3 p7 = new Vec3(worldPosition7.x,worldPosition7.y,worldPosition7.z);
|
||||
// Vec3 p8 = new Vec3(worldPosition8.x,worldPosition8.y,worldPosition8.z);
|
||||
//
|
||||
// Player player = (Player) this.getFirstPassenger();
|
||||
//
|
||||
// if (player != null) {
|
||||
// if (player.level() instanceof ServerLevel serverLevel ) {
|
||||
// sendParticle(serverLevel, ParticleTypes.END_ROD, p1.x, p1.y, p1.z, (int) (2 + 4 * this.getDeltaMovement().length()), 0, 0, 0, 0, true);
|
||||
|
|
|
@ -50,6 +50,7 @@ import java.util.Comparator;
|
|||
import java.util.List;
|
||||
|
||||
public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntity {
|
||||
|
||||
public static final EntityDataAccessor<Integer> COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
public static final float MAX_HEALTH = VehicleConfig.MK42_HP.get();
|
||||
|
|
|
@ -45,6 +45,7 @@ import software.bernie.geckolib.util.GeckoLibUtil;
|
|||
import java.util.List;
|
||||
|
||||
public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
||||
|
||||
public static final EntityDataAccessor<Float> DELTA_ROT = SynchedEntityData.defineId(Tom6Entity.class, EntityDataSerializers.FLOAT);
|
||||
public static final EntityDataAccessor<Boolean> MELON = SynchedEntityData.defineId(Tom6Entity.class, EntityDataSerializers.BOOLEAN);
|
||||
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
|
||||
|
|
Loading…
Add table
Reference in a new issue