From 3b5427560f80f9d304a7376a0bfb98b477002eca Mon Sep 17 00:00:00 2001 From: Atsuihsio <842960157@qq.com> Date: Tue, 24 Dec 2024 23:54:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=A9=E9=A6=96=E6=AD=A6?= =?UTF-8?q?=E5=99=A8=E6=95=88=E6=9E=9C=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=88=86?= =?UTF-8?q?=E7=82=B8level=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../atsuishio/superbwarfare/event/LivingEventHandler.java | 4 ++-- .../com/atsuishio/superbwarfare/tools/CustomExplosion.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java index 71f5c98a0..45809347b 100644 --- a/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/event/LivingEventHandler.java @@ -782,9 +782,9 @@ public class LivingEventHandler { var entity = event.getEntity(); int level = PerkHelper.getItemPerkLevel(ModPerks.VORPAL_WEAPON.get(), stack); if (level <= 0) return; - if (entity.getMaxHealth() < 100.0f) return; + if (entity.getHealth() < 100.0f) return; - event.setAmount(event.getAmount() * (1.15f + 0.05f * level)); + event.setAmount((float) (event.getAmount() + entity.getHealth() * 0.00002f * Math.pow(level,2))); } @SubscribeEvent diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java index 95ba4d05c..a773d2d06 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java @@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.google.common.collect.Sets; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; import net.minecraft.world.damagesource.DamageSource; @@ -72,7 +73,9 @@ public class CustomExplosion extends Explosion { ModUtils.PACKET_HANDLER.send(PacketDistributor.PLAYER.with(() -> serverPlayer), new ShakeClientMessage(20 + 0.02 * damage,3 * pRadius,50 + 0.05 * damage, pToBlowX, pToBlowY, pToBlowZ)); } } - pLevel.explode(source == null ? null : source.getEntity(), pToBlowX, pToBlowY, pToBlowZ, pRadius / 2, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE); + if (pLevel instanceof ServerLevel) { + pLevel.explode(source == null ? null : source.getEntity(), pToBlowX, pToBlowY, pToBlowZ, pRadius / 2, ExplosionDestroyConfig.EXPLOSION_DESTROY.get() ? Level.ExplosionInteraction.BLOCK : Level.ExplosionInteraction.NONE); + } } public CustomExplosion(Level pLevel, @Nullable Entity pSource, @Nullable DamageSource source, float damage, double pToBlowX, double pToBlowY, double pToBlowZ, float pRadius) {