diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java index f94b30688..404946cce 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/ProjectileEntity.java @@ -190,8 +190,9 @@ public class ProjectileEntity extends Projectile implements IEntityWithComplexSp if (obbVec != null) { hitPos = new Vec3(obbVec); if (this.level() instanceof ServerLevel serverLevel) { + this.level().playSound(null, BlockPos.containing(hitPos), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.2, false); - sendParticle(serverLevel, ParticleTypes.SMOKE, hitPos.x, hitPos.y, hitPos.z, 3, 0, 0, 0, 0.01, false); + sendParticle(serverLevel, ParticleTypes.SMOKE, hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.01, false); } } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java index 8c5a7f62b..aeec98f5f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/A10Entity.java @@ -174,11 +174,6 @@ public class A10Entity extends ContainerMobileVehicleEntity implements GeoEntity this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.2), random.nextFloat() * 0.1f + 1f); } - @Override - public boolean sendFireStarParticleOnHurt() { - return false; - } - @Override public DamageModifier getDamageModifier() { return super.getDamageModifier() 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 8220f3e6e..4330d1072 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java @@ -98,14 +98,8 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity { return Mth.lerp(0.6f * tickDelta, pitchO, getBodyPitch()); } - @Override - public boolean sendFireStarParticleOnHurt() { - return false; - } - - @Override - public boolean playHitSoundOnHurt() { - return false; + public DroneEntity(EntityType type, Level world, float moveX, float moveY, float moveZ) { + super(type, world); } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MortarEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MortarEntity.java index 7cecf4b00..e74dde7e2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MortarEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/MortarEntity.java @@ -78,10 +78,6 @@ public class MortarEntity extends VehicleEntity implements GeoEntity { return 0.2F; } - @Override - public boolean sendFireStarParticleOnHurt() { - return false; - } @Override public void addAdditionalSaveData(CompoundTag compound) { 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 08a90e094..367206ac9 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Tom6Entity.java @@ -100,11 +100,6 @@ public class Tom6Entity extends MobileVehicleEntity implements GeoEntity { this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.3), random.nextFloat() * 0.1f + 1f); } - @Override - public boolean sendFireStarParticleOnHurt() { - return false; - } - @Override public @NotNull InteractionResult interact(Player player, @NotNull InteractionHand hand) { if (player.getMainHandItem().is(Items.MELON) && !entityData.get(MELON)) { 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 524e7eb1b..7aab70a6c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/WheelChairEntity.java @@ -90,11 +90,6 @@ public class WheelChairEntity extends MobileVehicleEntity implements GeoEntity { this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.3), random.nextFloat() * 0.15f + 1); } - @Override - public boolean sendFireStarParticleOnHurt() { - return false; - } - @Override public void baseTick() { if (jumpCoolDown > 0 && onGround()) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java index 69b487fe6..e6876373d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/base/VehicleEntity.java @@ -72,7 +72,6 @@ import java.util.Objects; import java.util.function.Function; import static com.atsuishio.superbwarfare.client.RenderHelper.preciseBlit; -import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; public abstract class VehicleEntity extends Entity { @@ -430,33 +429,9 @@ public abstract class VehicleEntity extends Entity { } this.onHurt(computedAmount, source.getEntity(), true); - - // 显示火花粒子效果 - if (this.sendFireStarParticleOnHurt() && this.level() instanceof ServerLevel serverLevel) { - sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), this.getX(), this.getY() + 0.5 * getBbHeight(), this.getZ(), 2, 0.4, 0.4, 0.4, 0.2, false); - } - // 播放受击音效 - if (this.playHitSoundOnHurt()) { - this.level().playSound(null, this.getOnPos(), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); - } - return super.hurt(source, computedAmount); } - /** - * 受击时是否显示火花粒子效果 - */ - public boolean sendFireStarParticleOnHurt() { - return true; - } - - /** - * 受击时是否播放受击音效 - */ - public boolean playHitSoundOnHurt() { - return true; - } - /** * 控制载具伤害免疫 * diff --git a/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java b/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java index b101f7b14..a2cf73d41 100644 --- a/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java +++ b/src/main/java/com/atsuishio/superbwarfare/mixins/ProjectileUtilMixin.java @@ -1,6 +1,12 @@ package com.atsuishio.superbwarfare.mixins; import com.atsuishio.superbwarfare.entity.OBBEntity; +import com.atsuishio.superbwarfare.init.ModParticleTypes; +import com.atsuishio.superbwarfare.init.ModSounds; +import net.minecraft.core.BlockPos; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.sounds.SoundSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.ProjectileUtil; @@ -17,6 +23,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import java.util.Optional; import java.util.function.Predicate; +import static com.atsuishio.superbwarfare.tools.ParticleTool.sendParticle; + @Mixin(ProjectileUtil.class) public class ProjectileUtilMixin { @@ -35,7 +43,14 @@ public class ProjectileUtilMixin { if (optional.isPresent()) { double d1 = pStartVec.distanceToSqr(new Vec3(optional.get())); if (d1 < Double.MAX_VALUE) { - cir.setReturnValue(new EntityHitResult(entity, new Vec3(optional.get()))); + EntityHitResult hitResult = new EntityHitResult(entity, new Vec3(optional.get())); + cir.setReturnValue(hitResult); + if (pLevel instanceof ServerLevel serverLevel && pProjectile.getDeltaMovement().lengthSqr() > 0.01) { + Vec3 hitPos = hitResult.getLocation(); + pLevel.playSound(null, BlockPos.containing(hitPos), ModSounds.HIT.get(), SoundSource.PLAYERS, 1, 1); + sendParticle(serverLevel, ModParticleTypes.FIRE_STAR.get(), hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.2, false); + sendParticle(serverLevel, ParticleTypes.SMOKE, hitPos.x, hitPos.y, hitPos.z, 2, 0, 0, 0, 0.01, false); + } } } }