修复碰撞bug
This commit is contained in:
parent
aad489880f
commit
080f7ed625
2 changed files with 14 additions and 5 deletions
|
@ -82,6 +82,12 @@ public class ContainerMobileEntity extends MobileVehicleEntity implements HasCus
|
|||
})
|
||||
);
|
||||
|
||||
// Player player = (Player) this.getFirstPassenger();
|
||||
|
||||
// if (player != null) {
|
||||
// player.displayClientMessage(Component.literal( new DecimalFormat("##.#").format(this.getEnergy())), true);
|
||||
// }
|
||||
|
||||
this.refreshDimensions();
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,11 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
|||
if (this instanceof IHelicopterEntity) {
|
||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (100 * ((lastTickSpeed - 0.3) * (lastTickSpeed - 0.3))));
|
||||
this.bounceVertical(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
|
||||
crash = true;
|
||||
} else if (Mth.abs((float) lastTickVerticalSpeed) > 0.6) {
|
||||
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, this.getFirstPassenger() == null ? this : this.getFirstPassenger()), (float) (240 * ((Mth.abs((float) lastTickVerticalSpeed) - 0.6) * (lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
|
||||
if (!this.level().isClientSide) {
|
||||
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
||||
}
|
||||
this.bounceVertical(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
|
||||
}
|
||||
}
|
||||
|
@ -109,11 +111,12 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
|
|||
}
|
||||
|
||||
public void bounceVertical(Direction direction) {
|
||||
if (!this.level().isClientSide) {
|
||||
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
||||
}
|
||||
collisionCoolDown = 4;
|
||||
crash = true;
|
||||
if (direction.getAxis() == Direction.Axis.Y) {
|
||||
if (!this.level().isClientSide) {
|
||||
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
|
||||
}
|
||||
collisionCoolDown = 4;
|
||||
this.setDeltaMovement(this.getDeltaMovement().multiply(0.9, -0.8, 0.9));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue