From 55d29691c3692a5a2e853c8db27c4c91d51041b1 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 23 Feb 2025 00:11:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=88=86=E7=82=B8=E5=90=8E?= =?UTF-8?q?=E7=9A=84=E7=B2=92=E5=AD=90=E4=BA=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/MortarShellEntity.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MortarShellEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MortarShellEntity.java index efd789899..ace66959c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MortarShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/MortarShellEntity.java @@ -16,6 +16,7 @@ import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.effect.MobEffectInstance; +import net.minecraft.world.entity.AreaEffectCloud; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -173,6 +174,7 @@ public class MortarShellEntity extends ThrowableItemProjectile implements GeoEnt entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), this.damage); if (this.level() instanceof ServerLevel) { ProjectileTool.causeCustomExplode(this, this.damage, this.radius); + this.createAreaCloud(this.level()); } this.discard(); } @@ -189,6 +191,7 @@ public class MortarShellEntity extends ThrowableItemProjectile implements GeoEnt if (!this.level().isClientSide() && this.level() instanceof ServerLevel) { if (this.tickCount > 1) { ProjectileTool.causeCustomExplode(this, this.damage, this.radius); + this.createAreaCloud(this.level()); } } this.discard(); @@ -207,6 +210,7 @@ public class MortarShellEntity extends ThrowableItemProjectile implements GeoEnt if (this.tickCount > this.life || this.isInWater()) { if (this.level() instanceof ServerLevel) { ProjectileTool.causeCustomExplode(this, this.damage, this.radius); + this.createAreaCloud(this.level()); } this.discard(); } @@ -233,4 +237,17 @@ public class MortarShellEntity extends ThrowableItemProjectile implements GeoEnt } super.onRemovedFromWorld(); } + + private void createAreaCloud(Level level) { + if (this.potion == Potions.EMPTY) return; + + AreaEffectCloud cloud = new AreaEffectCloud(level, this.getX(), this.getY(), this.getZ()); + cloud.setPotion(this.potion); + cloud.setDuration((int) this.damage); + cloud.setRadius(this.radius); + if (this.getOwner() instanceof LivingEntity living) { + cloud.setOwner(living); + } + level.addFreshEntity(cloud); + } }