调整撞击伤害和载具交互

This commit is contained in:
Atsuihsio 2025-03-08 01:35:40 +08:00
parent bf31a3946a
commit c3fdfa6eb7
2 changed files with 18 additions and 8 deletions

View file

@ -141,8 +141,8 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity {
if (this instanceof HelicopterEntity) {
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (20 * ((lastTickSpeed - 0.3) * (lastTickSpeed - 0.3))));
this.bounceVertical(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
} else if (Mth.abs((float) lastTickVerticalSpeed) > 0.6) {
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (48 * ((Mth.abs((float) lastTickVerticalSpeed) - 0.6) * (lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
} else if (Mth.abs((float) lastTickVerticalSpeed) > 0.4) {
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (96 * ((Mth.abs((float) lastTickVerticalSpeed) - 0.4) * (lastTickSpeed - 0.3) * (lastTickSpeed - 0.3))));
if (!this.level().isClientSide) {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
}
@ -151,7 +151,7 @@ public abstract class MobileVehicleEntity extends EnergyVehicleEntity {
}
if (this.horizontalCollision) {
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (36 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
this.hurt(ModDamageTypes.causeVehicleStrikeDamage(this.level().registryAccess(), this, driver == null ? this : driver), (float) (126 * ((lastTickSpeed - 0.4) * (lastTickSpeed - 0.4))));
this.bounceHorizontal(Direction.getNearest(this.getDeltaMovement().x(), this.getDeltaMovement().y(), this.getDeltaMovement().z()).getOpposite());
if (!this.level().isClientSide) {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);

View file

@ -263,14 +263,24 @@ public abstract class VehicleEntity extends Entity {
} else if (!player.isShiftKeyDown()) {
if (this.getFirstPassenger() == null) {
if (player instanceof FakePlayer) return InteractionResult.PASS;
if (this instanceof LandArmorEntity landArmorEntity) {
player.setXRot((float) getXRotFromVector(landArmorEntity.getBarrelVec(1)));
player.setYRot((float) getYRotFromVector(landArmorEntity.getBarrelVec(1)));
} else {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
}
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
} else if (!(this.getFirstPassenger() instanceof Player)) {
if (player instanceof FakePlayer) return InteractionResult.PASS;
this.getFirstPassenger().stopRiding();
if (this instanceof LandArmorEntity landArmorEntity) {
player.setXRot((float) getXRotFromVector(landArmorEntity.getBarrelVec(1)));
player.setYRot((float) getYRotFromVector(landArmorEntity.getBarrelVec(1)));
} else {
player.setXRot(this.getXRot());
player.setYRot(this.getYRot());
}
return player.startRiding(this) ? InteractionResult.CONSUME : InteractionResult.PASS;
}
if (this.canAddPassenger(player)) {
@ -352,7 +362,7 @@ public abstract class VehicleEntity extends Entity {
.immuneTo(DamageTypes.DRAGON_BREATH)
.immuneTo(DamageTypes.WITHER)
.immuneTo(DamageTypes.WITHER_SKULL)
.reduce(8, ModDamageTypes.VEHICLE_STRIKE);
.reduce(5, ModDamageTypes.VEHICLE_STRIKE);
}
public void heal(float pHealAmount) {