diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java index a9300fcd5..54050a3ad 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/MortarEntity.java @@ -37,6 +37,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; +import org.jetbrains.annotations.NotNull; import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -99,12 +100,8 @@ public class MortarEntity extends VehicleEntity implements GeoEntity, AnimatedEn @Override public boolean hurt(DamageSource source, float amount) { - this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = this.damageModifier.compute(source, amount); super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); return true; } 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 b3c4d2ccd..c47c7fdab 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -132,16 +132,12 @@ public class Ah6Entity extends ContainerMobileEntity implements GeoEntity, IHeli } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } 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 107411ddf..00208a2e2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/AnnihilatorEntity.java @@ -42,6 +42,7 @@ import net.minecraftforge.event.ForgeEventFactory; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; +import org.jetbrains.annotations.NotNull; import org.joml.Math; import org.joml.Vector3d; import software.bernie.geckolib.animatable.GeoEntity; @@ -181,16 +182,12 @@ public class AnnihilatorEntity extends EnergyVehicleEntity implements GeoEntity, } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java index ebbabe801..d5aee4727 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Bmp2Entity.java @@ -138,16 +138,12 @@ public class Bmp2Entity extends ContainerMobileEntity implements GeoEntity, ILan } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java index 1855bf15b..a2d8b40f7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java @@ -106,11 +106,8 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity { } @Override - public boolean hurt(DamageSource source, float amount) { - amount = damageModifier.compute(source, amount); + public boolean hurt(@NotNull DamageSource source, float amount) { super.hurt(source, amount); - this.hurt(amount, source.getEntity(), false); - return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/LaserTowerEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/LaserTowerEntity.java index 6824b7e79..aa72063a2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/LaserTowerEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/LaserTowerEntity.java @@ -35,6 +35,7 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; +import org.jetbrains.annotations.NotNull; import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -142,16 +143,12 @@ public class LaserTowerEntity extends EnergyVehicleEntity implements GeoEntity, } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.8, this.getZ(), 4, 0.1, 0.1, 0.1, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java index 054a1e1c8..2217b3304 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Lav150Entity.java @@ -135,16 +135,12 @@ public class Lav150Entity extends ContainerMobileEntity implements GeoEntity, IL } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } 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 7305f55b0..9247bf555 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -38,6 +38,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; +import org.jetbrains.annotations.NotNull; import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -149,16 +150,12 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, ICannonEntit } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } 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 810df25bf..0ddefcd8f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -38,6 +38,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; +import org.jetbrains.annotations.NotNull; import org.joml.Math; import org.joml.Vector3d; import software.bernie.geckolib.animatable.GeoEntity; @@ -163,16 +164,12 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, ICannonEn } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } 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 c6ad86108..1475c2a2c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/SpeedboatEntity.java @@ -39,6 +39,7 @@ import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; +import org.jetbrains.annotations.NotNull; import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -114,16 +115,12 @@ public class SpeedboatEntity extends ContainerMobileEntity implements GeoEntity, } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + super.hurt(source, amount); if (this.level() instanceof ServerLevel serverLevel) { sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 2.5, this.getZ(), 4, 0.2, 0.2, 0.2, 0.2, false); } this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - return true; } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java index 39ba55878..5e443ed56 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java @@ -97,13 +97,9 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity { } @Override - public boolean hurt(DamageSource source, float amount) { - this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); - this.hurt(amount, source.getEntity(), true); + public boolean hurt(@NotNull DamageSource source, float amount) { super.hurt(source, amount); - + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); return true; } 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 28bb8cf9e..3abd0270b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/VehicleEntity.java @@ -154,18 +154,20 @@ public class VehicleEntity extends Entity { } @Override - public boolean hurt(DamageSource source, float amount) { + public boolean hurt(@NotNull DamageSource source, float amount) { + float computedAmount = damageModifier.compute(source, amount); this.crash = source.is(ModDamageTypes.VEHICLE_STRIKE); if (source.getEntity() != null) { this.entityData.set(LAST_ATTACKER_UUID, source.getEntity().getStringUUID()); } - if (amount > 0) { + if (computedAmount > 0) { lastHurtTick = 0; repairCoolDown = maxRepairCoolDown(); } - return super.hurt(source, amount); + this.onHurt(computedAmount, source.getEntity(), true); + return super.hurt(source, computedAmount); } protected final DamageModifier damageModifier = this.getDamageModifier(); @@ -194,7 +196,7 @@ public class VehicleEntity extends Entity { } - public void hurt(float pHealAmount, Entity attacker, boolean send) { + public void onHurt(float pHealAmount, Entity attacker, boolean send) { if (this.level() instanceof ServerLevel) { var holder = Holder.direct(ModSounds.INDICATION_VEHICLE.get()); if (attacker instanceof ServerPlayer player && pHealAmount > 0 && this.getHealth() > 0 && send && !(this instanceof DroneEntity)) { @@ -323,7 +325,7 @@ public class VehicleEntity extends Entity { if (this.getHealth() <= 0.1 * this.getMaxHealth()) { // 血量过低时自动扣血 - this.hurt(0.1f, attacker, false); + this.onHurt(0.1f, attacker, false); } else { // 呼吸回血 if (repairCoolDown == 0) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java index 06b07eadd..0c489ea67 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java @@ -31,6 +31,7 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; +import org.jetbrains.annotations.NotNull; import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -103,13 +104,9 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity { } @Override - public boolean hurt(DamageSource source, float amount) { - this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - - amount = damageModifier.compute(source, amount); + public boolean hurt(@NotNull DamageSource source, float amount) { super.hurt(source, amount); - this.hurt(amount, source.getEntity(), true); - + this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); return true; }