From a75260754aaa1d6bb4f95c3ee93edafc3e5717c4 Mon Sep 17 00:00:00 2001 From: Light_Quanta Date: Tue, 20 May 2025 01:48:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BASmokeDecoyEntity=E6=B7=BB=E5=8A=A0NBT?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/SmokeDecoyEntity.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java index b4dc534ae..afb87d2a8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmokeDecoyEntity.java @@ -25,12 +25,23 @@ public class SmokeDecoyEntity extends Entity implements DecoyEntity { super(ModEntities.SMOKE_DECOY.get(), level); } + public int life = 400; + public int igniteTime = 4; + @Override protected void readAdditionalSaveData(@NotNull CompoundTag compoundTag) { + if (compoundTag.contains("IgniteTime")) { + this.igniteTime = compoundTag.getInt("IgniteTime"); + } + if (compoundTag.contains("Life")) { + this.life = compoundTag.getInt("Life"); + } } @Override protected void addAdditionalSaveData(@NotNull CompoundTag compoundTag) { + compoundTag.putInt("IgniteTime", igniteTime); + compoundTag.putInt("Life", life); } @Override @@ -41,7 +52,7 @@ public class SmokeDecoyEntity extends Entity implements DecoyEntity { public void tick() { super.tick(); this.move(MoverType.SELF, this.getDeltaMovement()); - if (tickCount == 4) { + if (tickCount == this.igniteTime) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ModParticleTypes.CUSTOM_SMOKE.get(), this.xo, this.yo, this.zo, 100, 0, 0, 0, 0.07, true); @@ -50,13 +61,13 @@ public class SmokeDecoyEntity extends Entity implements DecoyEntity { this.setDeltaMovement(Vec3.ZERO); } - if (this.tickCount > 400) { + if (this.tickCount > this.life) { this.discard(); } } public void decoyShoot(Entity entity, Vec3 shootVec, float pVelocity, float pInaccuracy) { - Vec3 vec3 = shootVec.normalize().add(this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy)).scale((double) pVelocity); + Vec3 vec3 = shootVec.normalize().add(this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy), this.random.triangle(0.0, 0.0172275 * (double) pInaccuracy)).scale(pVelocity); this.setDeltaMovement(entity.getDeltaMovement().scale(0.75).add(vec3)); double d0 = vec3.horizontalDistance(); this.setYRot((float) (Mth.atan2(vec3.x, vec3.z) * 57.2957763671875));