修复载具导致的崩溃问题
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);
|
||||
|
@ -317,7 +308,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
|
|||
public void move(@NotNull MoverType movementType, @NotNull Vec3 movement) {
|
||||
super.move(movementType, movement);
|
||||
if (this.isInWater() && horizontalCollision) {
|
||||
setDeltaMovement(this.getDeltaMovement().add(0,0.07,0));
|
||||
setDeltaMovement(this.getDeltaMovement().add(0, 0.07, 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -473,7 +464,7 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IC
|
|||
}
|
||||
|
||||
this.entityData.set(POWER, this.entityData.get(POWER) * (upInputDown ? 0.5f : (rightInputDown || leftInputDown) ? 0.977f : 0.99f));
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * (float)Math.max(0.76f - 0.1f * this.getDeltaMovement().horizontalDistance(), 0.3));
|
||||
this.entityData.set(DELTA_ROT, this.entityData.get(DELTA_ROT) * (float) Math.max(0.76f - 0.1f * this.getDeltaMovement().horizontalDistance(), 0.3));
|
||||
|
||||
float angle = (float) calculateAngle(this.getDeltaMovement(), this.getViewVector(1));
|
||||
double s0;
|
||||
|
|
|
@ -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);
|
||||
|
@ -169,7 +170,7 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
|||
diffY = Math.clamp(-90f, 90f, Mth.wrapDegrees(passenger.getYHeadRot() - this.getYRot()));
|
||||
diffX = Math.clamp(-60f, 60f, Mth.wrapDegrees(passenger.getXRot() - this.getXRot()));
|
||||
|
||||
float roll = Mth.abs(Mth.clamp(getRoll() / 60 , -1.5f , 1.5f));
|
||||
float roll = Mth.abs(Mth.clamp(getRoll() / 60, -1.5f, 1.5f));
|
||||
|
||||
float addY = Mth.clamp(Math.min((this.onGround() ? 1.5f : 0.9f) * (float) Math.max(getDeltaMovement().length() - 0.06, 0.1), 0.9f) * diffY - 0.5f * this.entityData.get(DELTA_ROT), (entityData.get(MELON) ? -2f : -3f) * (roll + 1), (entityData.get(MELON) ? 2f : 3f) * (roll + 1));
|
||||
float addX = Mth.clamp(Math.min((float) Math.max(getDeltaMovement().length() - 0.1, 0.01), 0.9f) * diffX, (entityData.get(MELON) ? -3f : -4f), (entityData.get(MELON) ? 3f : 4f));
|
||||
|
@ -188,7 +189,7 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity {
|
|||
|
||||
MelonBombEntity melonBomb = new MelonBombEntity(player, player.level());
|
||||
melonBomb.setPos(worldPosition.x, worldPosition.y, worldPosition.z);
|
||||
melonBomb.shoot(getDeltaMovement().x, getDeltaMovement().y, getDeltaMovement().z, (float)getDeltaMovement().length(), 0);
|
||||
melonBomb.shoot(getDeltaMovement().x, getDeltaMovement().y, getDeltaMovement().z, (float) getDeltaMovement().length(), 0);
|
||||
passenger.level().addFreshEntity(melonBomb);
|
||||
|
||||
this.level().playSound(null, getOnPos(), SoundEvents.IRON_DOOR_OPEN, SoundSource.PLAYERS, 1, 1);
|
||||
|
|
Loading…
Add table
Reference in a new issue