添加坠机伤害类型

This commit is contained in:
Atsuihsio 2025-01-05 03:54:13 +08:00
parent cde0d249dc
commit b15d4a9a36
15 changed files with 58 additions and 27 deletions

View file

@ -125,10 +125,8 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
}
this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1);
this.hurt(0.75f * Math.max(amount - 5, 0));
return true;
}
@Override
public void baseTick() {
propellerRotO = this.getPropellerRot();
@ -329,14 +327,14 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
public void destroy() {
if (level() instanceof ServerLevel) {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), attacker == null ? this : attacker,
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 300.0f,
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
CustomExplosion explosion = new CustomExplosion(this.level(), this,
crash ? ModDamageTypes.causeAirCrashDamage(this.level().registryAccess(), this, attacker) : ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), this, attacker), 300.0f,
this.getX(), this.getY(), this.getZ(), 8f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode();
ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
this.discard();
this.remove(RemovalReason.KILLED);
}
}
@ -390,7 +388,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
projectileRight.shoot(player, this.getLookAngle().x, this.getLookAngle().y+ 0.03, this.getLookAngle().z, 20,
(float) 0.2);
this.level().addFreshEntity(projectileRight);
ParticleTool.sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionRight.x, worldPositionRight.y, worldPositionRight.z, 1, 0, 0, 0, 0, false);
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionRight.x, worldPositionRight.y, worldPositionRight.z, 1, 0, 0, 0, 0, false);
ProjectileEntity projectileLeft = new ProjectileEntity(player.level())
.shooter(player)
@ -404,7 +402,7 @@ public class Ah6Entity extends MobileVehicleEntity implements GeoEntity, IHelico
projectileLeft.shoot(player, this.getLookAngle().x, this.getLookAngle().y + 0.03, this.getLookAngle().z, 20,
(float) 0.2);
this.level().addFreshEntity(projectileLeft);
ParticleTool.sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z, 1, 0, 0, 0, 0, false);
sendParticle((ServerLevel) this.level(), ParticleTypes.LARGE_SMOKE, worldPositionLeft.x, worldPositionLeft.y, worldPositionLeft.z, 1, 0, 0, 0, 0, false);
if (!player.level().isClientSide) {
if (player instanceof ServerPlayer serverPlayer) {

View file

@ -331,13 +331,13 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity,
public void destroy() {
if (level() instanceof ServerLevel) {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), attacker == null ? this : attacker,
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 200.0f,
this.getX(), this.getY(), this.getZ(), 15f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 200f,
this.getX(), this.getY(), this.getZ(), 10f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);
ParticleTool.spawnHugeExplosionParticles(this.level(), this.position());
ParticleTool.spawnMediumExplosionParticles(this.level(), this.position());
this.discard();
}
}

View file

@ -176,9 +176,9 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit
public void destroy() {
if (level() instanceof ServerLevel) {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), attacker == null ? this : attacker,
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 150.0f,
this.getX(), this.getY(), this.getZ(), 6f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 150f,
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false);

View file

@ -191,8 +191,8 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn
public void destroy() {
if (level() instanceof ServerLevel) {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), attacker == null ? this : attacker,
ModDamageTypes.causeCustomExplosionDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 150.0f,
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 150f,
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);

View file

@ -82,6 +82,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
}
collisionCoolDown = 4;
crash = true;
}
if (this.horizontalCollision) {
@ -91,10 +92,11 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
this.level().playSound(null, this, ModSounds.VEHICLE_STRIKE.get(), this.getSoundSource(), 1, 1);
}
collisionCoolDown = 4;
crash = true;
}
}
private void bounceHorizontal(Direction direction) {
public void bounceHorizontal(Direction direction) {
switch (direction.getAxis()) {
case X:
this.setDeltaMovement(this.getDeltaMovement().multiply(-0.8, 0.99, 0.99));
@ -105,7 +107,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
}
}
private void bounceVertical(Direction direction) {
public void bounceVertical(Direction direction) {
if (direction.getAxis() == Direction.Axis.Y) {
this.setDeltaMovement(this.getDeltaMovement().multiply(0.9, -0.8, 0.9));
}
@ -117,6 +119,7 @@ public class MobileVehicleEntity extends EnergyVehicleEntity {
*/
public void crushEntities(Vec3 velocity) {
if (velocity.horizontalDistance() < 0.1) return;
if (isRemoved()) return;
var frontBox = getBoundingBox().move(velocity.scale(0.5));
var velAdd = velocity.add(0, 0, 0).scale(0.9);

View file

@ -493,8 +493,8 @@ public class SpeedboatEntity extends MobileVehicleEntity implements GeoEntity, I
@Override
public void destroy() {
Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID));
CustomExplosion explosion = new CustomExplosion(this.level(), attacker == null ? this : attacker,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker == null ? this : attacker, attacker == null ? this : attacker), 75f,
CustomExplosion explosion = new CustomExplosion(this.level(), this,
ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), attacker, attacker), 75f,
this.getX(), this.getY(), this.getZ(), 5f, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP).setDamageMultiplier(1);
explosion.explode();
net.minecraftforge.event.ForgeEventFactory.onExplosionStart(this.level(), explosion);

View file

@ -46,7 +46,8 @@ public class VehicleEntity extends Entity {
public float roll;
public float prevRoll;
public int lastHurtTick;
public boolean crash;
public float getRoll() {
return roll;
}
@ -167,11 +168,18 @@ public class VehicleEntity extends Entity {
return false;
if (source.is(DamageTypes.IN_FIRE))
return false;
if (source.is(ModDamageTypes.VEHICLE_STRIKE))
if (source.is(ModDamageTypes.VEHICLE_STRIKE)) {
amount -= 20;
crash = true;
} else {
crash = false;
}
if (source.getEntity() != null) {
this.entityData.set(LAST_ATTACKER_UUID, source.getEntity().getStringUUID());
}
lastHurtTick = 0;
return super.hurt(source, amount);
}
@ -233,6 +241,8 @@ public class VehicleEntity extends Entity {
public void baseTick() {
super.baseTick();
lastHurtTick ++;
prevRoll = this.getRoll();
setZRot(roll * 0.9f);

View file

@ -31,6 +31,7 @@ public class ModDamageTypes {
public static final ResourceKey<DamageType> LASER = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser"));
public static final ResourceKey<DamageType> LASER_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser_headshot"));
public static final ResourceKey<DamageType> VEHICLE_STRIKE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "vehicle_strike"));
public static final ResourceKey<DamageType> AIR_CRASH = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "air_crash"));
public static DamageSource causeGunFireDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(GUN_FIRE), directEntity, attacker);
@ -88,6 +89,10 @@ public class ModDamageTypes {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(VEHICLE_STRIKE), directEntity, attacker);
}
public static DamageSource causeAirCrashDamage(RegistryAccess registryAccess, @Nullable Entity directEntity, @Nullable Entity attacker) {
return new DamageMessages(registryAccess.registry(Registries.DAMAGE_TYPE).get().getHolderOrThrow(AIR_CRASH), directEntity, attacker);
}
private static class DamageMessages extends DamageSource {
public DamageMessages(Holder.Reference<DamageType> typeReference) {
super(typeReference);

View file

@ -350,6 +350,9 @@
"death.attack.vehicle_strike": "%1$s被创死了",
"death.attack.vehicle_strike.entity": "%1$s被%2$s创死了",
"death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了",
"death.attack.air_crash": "%1$s坠机了",
"death.attack.air_crash.entity": "%1$s坠机了",
"death.attack.air_crash.item": "%1$s坠机了",
"entity.superbwarfare.projectile": "Bullet",
"entity.superbwarfare.projectile_mortar_shell": "Mortar Shell",

View file

@ -350,6 +350,9 @@
"death.attack.vehicle_strike": "%1$s被创死了",
"death.attack.vehicle_strike.entity": "%1$s被%2$s创死了",
"death.attack.vehicle_strike.item": "%1$s的被%2$s用%3$s创死了",
"death.attack.air_crash": "%1$s坠机了",
"death.attack.air_crash.entity": "%1$s坠机了",
"death.attack.air_crash.item": "%1$s坠机了",
"entity.superbwarfare.projectile": "子弹",
"entity.superbwarfare.projectile_mortar_shell": "迫击炮弹",

View file

@ -7,6 +7,7 @@
"superbwarfare:cannon_fire",
"superbwarfare:laser",
"superbwarfare:laser_headshot",
"superbwarfare:vehicle_strike"
"superbwarfare:vehicle_strike",
"superbwarfare:air_crash"
]
}

View file

@ -7,6 +7,7 @@
"superbwarfare:cannon_fire",
"superbwarfare:laser",
"superbwarfare:laser_headshot",
"superbwarfare:vehicle_strike"
"superbwarfare:vehicle_strike",
"superbwarfare:air_crash"
]
}

View file

@ -7,6 +7,7 @@
"superbwarfare:cannon_fire",
"superbwarfare:laser",
"superbwarfare:laser_headshot",
"superbwarfare:vehicle_strike"
"superbwarfare:vehicle_strike",
"superbwarfare:air_crash"
]
}

View file

@ -7,6 +7,7 @@
"superbwarfare:cannon_fire",
"superbwarfare:laser",
"superbwarfare:laser_headshot",
"superbwarfare:vehicle_strike"
"superbwarfare:vehicle_strike",
"superbwarfare:air_crash"
]
}

View file

@ -0,0 +1,5 @@
{
"exhaustion": 0,
"message_id": "air_crash",
"scaling": "never"
}