From 7e22bab186853f656bfc1011f0405c7b5a78fd2a Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 19 May 2024 23:19:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=B2=92=E5=AD=90=E6=95=88?= =?UTF-8?q?=E6=9E=9C=E6=98=BE=E7=A4=BA=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../target/entity/ClaymoreEntity.java | 12 +++---- .../target/entity/GunGrenadeEntity.java | 1 + .../target/entity/MortarShellEntity.java | 1 + .../target/entity/RpgRocketEntity.java | 33 ++++++++----------- .../entity/TaserBulletProjectileEntity.java | 1 + 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java b/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java index a0773223a..e1033f430 100644 --- a/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java +++ b/src/main/java/net/mcreator/target/entity/ClaymoreEntity.java @@ -3,8 +3,7 @@ package net.mcreator.target.entity; import net.mcreator.target.TargetMod; import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModItems; -import net.minecraft.commands.CommandSource; -import net.minecraft.commands.CommandSourceStack; +import net.mcreator.target.tools.ParticleTool; import net.minecraft.core.BlockPos; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; @@ -129,11 +128,9 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated super.die(source); if (level() instanceof ServerLevel server) { - server.explode(null, this.getX(), this.getY(), this.getZ(), 6.5f, Level.ExplosionInteraction.NONE); server.explode(this, this.getX(), this.getY(), this.getZ(), 6.5f, Level.ExplosionInteraction.NONE); - this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4, - this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp"); + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); this.discard(); } } @@ -247,9 +244,8 @@ public class ClaymoreEntity extends TamableAnimal implements GeoEntity, Animated if (!condition) continue; if (!level.isClientSide()) { - if (!this.level().isClientSide() && this.getServer() != null) { - this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4, - this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp"); + if (!this.level().isClientSide()) { + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); } this.discard(); } diff --git a/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java b/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java index f1f049fba..048b98eb2 100644 --- a/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java +++ b/src/main/java/net/mcreator/target/entity/GunGrenadeEntity.java @@ -30,6 +30,7 @@ import net.minecraftforge.network.PlayMessages; import java.util.Optional; +// TODO 父类改为Projectile @OnlyIn(value = Dist.CLIENT, _interface = ItemSupplier.class) public class GunGrenadeEntity extends AbstractArrow implements ItemSupplier { public static final ItemStack PROJECTILE_ITEM = new ItemStack(Blocks.AIR); diff --git a/src/main/java/net/mcreator/target/entity/MortarShellEntity.java b/src/main/java/net/mcreator/target/entity/MortarShellEntity.java index 5b50dec6f..e13b82c8f 100644 --- a/src/main/java/net/mcreator/target/entity/MortarShellEntity.java +++ b/src/main/java/net/mcreator/target/entity/MortarShellEntity.java @@ -21,6 +21,7 @@ import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; +// TODO 父类改为Projectile @OnlyIn(value = Dist.CLIENT, _interface = ItemSupplier.class) public class MortarShellEntity extends AbstractArrow implements ItemSupplier { public static final ItemStack PROJECTILE_ITEM = new ItemStack(Blocks.AIR); diff --git a/src/main/java/net/mcreator/target/entity/RpgRocketEntity.java b/src/main/java/net/mcreator/target/entity/RpgRocketEntity.java index 0acd540a1..9a5885c63 100644 --- a/src/main/java/net/mcreator/target/entity/RpgRocketEntity.java +++ b/src/main/java/net/mcreator/target/entity/RpgRocketEntity.java @@ -5,8 +5,8 @@ import net.mcreator.target.headshot.IHeadshotBox; import net.mcreator.target.init.TargetModEntities; import net.mcreator.target.init.TargetModSounds; import net.mcreator.target.network.TargetModVariables; -import net.minecraft.commands.CommandSource; -import net.minecraft.commands.CommandSourceStack; +import net.mcreator.target.tools.ParticleTool; +import net.minecraft.core.particles.ParticleTypes; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.server.level.ServerLevel; @@ -31,6 +31,7 @@ import net.minecraftforge.network.PlayMessages; import java.util.Optional; +// TODO 父类改为Projectile @OnlyIn(value = Dist.CLIENT, _interface = ItemSupplier.class) public class RpgRocketEntity extends AbstractArrow implements ItemSupplier { public static final ItemStack PROJECTILE_ITEM = new ItemStack(Blocks.AIR); @@ -100,9 +101,8 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier { if (this.level() instanceof ServerLevel level) { level.explode(this, this.getX(), this.getY(), this.getZ(), 4, Level.ExplosionInteraction.NONE); - if (!entity.level().isClientSide() && entity.getServer() != null) { - entity.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, entity.position(), entity.getRotationVector(), (ServerLevel) entity.level(), 4, - entity.getName().getString(), entity.getDisplayName(), entity.getServer(), entity), "target:mediumexp"); + if (!entity.level().isClientSide()) { + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); } this.discard(); @@ -174,33 +174,28 @@ public class RpgRocketEntity extends AbstractArrow implements ItemSupplier { this.getPersistentData().putInt("time", (1 + this.getPersistentData().getInt("time"))); double life = this.getPersistentData().getInt("time"); if (life == 4) { - if (!this.level().isClientSide() && this.getServer() != null) { - this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4, - this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0.8 0.8 0.8 0.01 50 force"); + if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) { + ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 50, 0.8, 0.8, 0.8, 0.01, true); } } if (life >= 4) { this.setDeltaMovement(new Vec3((1.04 * this.getDeltaMovement().x()), (1.04 * this.getDeltaMovement().y() - 0.02), (1.04 * this.getDeltaMovement().z()))); - if (!this.level().isClientSide() && this.getServer() != null) { - this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4, - this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:smoke ~ ~ ~ 0 0 0 0 2 force"); - this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4, - this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "particle minecraft:campfire_cosy_smoke ~ ~ ~ 0 0 0 0 2 force"); + if (!this.level().isClientSide() && this.level() instanceof ServerLevel serverLevel) { + ParticleTool.sendParticle(serverLevel, ParticleTypes.SMOKE, this.getX(), this.getY(), this.getZ(), 2, 0, 0, 0, 0, true); + ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY(), this.getZ(), 2, 0, 0, 0, 0, true); } } if (life >= 90) { - if (!this.level().isClientSide() && this.getServer() != null) { - this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4, - this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp"); + if (!this.level().isClientSide()) { + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); } if (!this.level().isClientSide()) this.discard(); } if (this.inGround) { - if (!this.level().isClientSide() && this.getServer() != null) { - this.getServer().getCommands().performPrefixedCommand(new CommandSourceStack(CommandSource.NULL, this.position(), this.getRotationVector(), this.level() instanceof ServerLevel ? (ServerLevel) this.level() : null, 4, - this.getName().getString(), this.getDisplayName(), this.level().getServer(), this), "target:mediumexp"); + if (!this.level().isClientSide()) { + ParticleTool.spawnMediumExplosionParticles(this.level(), this.position()); } this.discard(); } diff --git a/src/main/java/net/mcreator/target/entity/TaserBulletProjectileEntity.java b/src/main/java/net/mcreator/target/entity/TaserBulletProjectileEntity.java index 84095bb3d..3fbf26c38 100644 --- a/src/main/java/net/mcreator/target/entity/TaserBulletProjectileEntity.java +++ b/src/main/java/net/mcreator/target/entity/TaserBulletProjectileEntity.java @@ -31,6 +31,7 @@ import net.minecraftforge.network.PlayMessages; import java.util.Optional; +// TODO 父类改为Projectile @OnlyIn(value = Dist.CLIENT, _interface = ItemSupplier.class) public class TaserBulletProjectileEntity extends AbstractArrow implements ItemSupplier { public static final ItemStack PROJECTILE_ITEM = new ItemStack(Blocks.AIR);