diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index e7dd3a509..7189996d7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -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) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java index 5778ea37c..6aa2cd552 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java @@ -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(); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java index 8efb7f776..f224a16fa 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java index f4873d02f..a991d1857 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java index 54d14060c..d5e9a5f73 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MobileVehicleEntity.java @@ -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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java index 334c43ef6..ff0535581 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -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); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java index e5873096b..223d4b156 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java @@ -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); diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java b/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java index 345f316fe..53a53eb44 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModDamageTypes.java @@ -31,6 +31,7 @@ public class ModDamageTypes { public static final ResourceKey LASER = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser")); public static final ResourceKey LASER_HEADSHOT = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "laser_headshot")); public static final ResourceKey VEHICLE_STRIKE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(ModUtils.MODID, "vehicle_strike")); + public static final ResourceKey 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 typeReference) { super(typeReference); diff --git a/src/main/resources/assets/superbwarfare/lang/en_us.json b/src/main/resources/assets/superbwarfare/lang/en_us.json index 8a04ea9a0..29544352d 100644 --- a/src/main/resources/assets/superbwarfare/lang/en_us.json +++ b/src/main/resources/assets/superbwarfare/lang/en_us.json @@ -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", diff --git a/src/main/resources/assets/superbwarfare/lang/zh_cn.json b/src/main/resources/assets/superbwarfare/lang/zh_cn.json index c6f08fcc5..8703095fc 100644 --- a/src/main/resources/assets/superbwarfare/lang/zh_cn.json +++ b/src/main/resources/assets/superbwarfare/lang/zh_cn.json @@ -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": "迫击炮弹", diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json index 564095052..1714584b5 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_armor.json @@ -7,6 +7,7 @@ "superbwarfare:cannon_fire", "superbwarfare:laser", "superbwarfare:laser_headshot", - "superbwarfare:vehicle_strike" + "superbwarfare:vehicle_strike", + "superbwarfare:air_crash" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json index 564095052..1714584b5 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_effects.json @@ -7,6 +7,7 @@ "superbwarfare:cannon_fire", "superbwarfare:laser", "superbwarfare:laser_headshot", - "superbwarfare:vehicle_strike" + "superbwarfare:vehicle_strike", + "superbwarfare:air_crash" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json index 564095052..1714584b5 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_enchantments.json @@ -7,6 +7,7 @@ "superbwarfare:cannon_fire", "superbwarfare:laser", "superbwarfare:laser_headshot", - "superbwarfare:vehicle_strike" + "superbwarfare:vehicle_strike", + "superbwarfare:air_crash" ] } \ No newline at end of file diff --git a/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json b/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json index 564095052..1714584b5 100644 --- a/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json +++ b/src/main/resources/data/minecraft/tags/damage_type/bypasses_resistance.json @@ -7,6 +7,7 @@ "superbwarfare:cannon_fire", "superbwarfare:laser", "superbwarfare:laser_headshot", - "superbwarfare:vehicle_strike" + "superbwarfare:vehicle_strike", + "superbwarfare:air_crash" ] } \ No newline at end of file diff --git a/src/main/resources/data/superbwarfare/damage_type/air_crash.json b/src/main/resources/data/superbwarfare/damage_type/air_crash.json new file mode 100644 index 000000000..02284592e --- /dev/null +++ b/src/main/resources/data/superbwarfare/damage_type/air_crash.json @@ -0,0 +1,5 @@ +{ + "exhaustion": 0, + "message_id": "air_crash", + "scaling": "never" +} \ No newline at end of file