From 2b3c01b65880fb16429ab3207723dba8df17ca01 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Fri, 2 May 2025 02:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=90=E4=BA=9B=E7=88=86?= =?UTF-8?q?=E7=82=B8=E4=B8=8D=E8=83=BD=E7=A0=B4=E5=9D=8F=E7=93=A6=E5=9F=BA?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../atsuishio/superbwarfare/tools/CustomExplosion.java | 6 ++++++ .../atsuishio/superbwarfare/tools/ProjectileTool.java | 9 --------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java index a8ea84b33..64d39668c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java @@ -7,6 +7,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.core.particles.ParticleOptions; import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; @@ -78,6 +79,11 @@ public class CustomExplosion extends Explosion { public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius, BlockInteraction pBlockInteraction) { this(pLevel, pSource, source, null, damage, pToBlowX, pToBlowY, pToBlowZ, pRadius, pBlockInteraction); final Vec3 center = new Vec3(pToBlowX, pToBlowY, pToBlowZ); + + if (pLevel instanceof ServerLevel) { + pLevel.explode(source == null ? null : source.getEntity(), pToBlowX, pToBlowY, pToBlowZ, 0.5f * pRadius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE); + } + for (Entity target : level.getEntitiesOfClass(Entity.class, new AABB(center, center).inflate(4 * radius), e -> true).stream().sorted(Comparator.comparingDouble(e -> e.distanceToSqr(center))).toList()) { if (target instanceof ServerPlayer serverPlayer) { PacketDistributor.sendToPlayer(serverPlayer, new ShakeClientMessage(5 + 0.02 * damage, 0.75 * pRadius, 4 + 0.02 * damage, pToBlowX, pToBlowY, pToBlowZ)); diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java index 6e663c7ef..4f48659d4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/ProjectileTool.java @@ -2,13 +2,10 @@ package com.atsuishio.superbwarfare.tools; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.init.ModDamageTypes; -import net.minecraft.server.level.ServerLevel; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.level.Explosion; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; import net.neoforged.neoforge.event.EventHooks; import javax.annotation.Nullable; @@ -33,12 +30,6 @@ public class ProjectileTool { ParticleTool.spawnHugeExplosionParticles(projectile.level(), projectile.position().add(projectile.getDeltaMovement().scale(0.5))); } - Vec3 pos = projectile.position().add(projectile.getDeltaMovement().scale(0.5)); - - if (projectile.level() instanceof ServerLevel) { - projectile.level().explode(source == null ? null : source.getEntity(), pos.x, pos.y, pos.z, 0.5f * radius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE); - } - projectile.discard(); }