From b0e61f9ef7c019143d41d904dc7f4d9f74fc5d27 Mon Sep 17 00:00:00 2001 From: Atsuishio <842960157@qq.com> Date: Wed, 18 Jun 2025 17:51:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E6=98=AF=E4=BC=98=E5=8C=96=E5=BC=B9?= =?UTF-8?q?=E5=B0=84=E7=89=A9=E7=A9=BF=E9=80=8F=EF=BC=88=E6=81=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/projectile/Agm65Entity.java | 17 +++++++++-------- .../entity/projectile/CannonShellEntity.java | 11 ++++++----- .../projectile/FastThrowableProjectile.java | 7 +++---- .../entity/projectile/HeliRocketEntity.java | 12 ++++++------ .../entity/projectile/JavelinMissileEntity.java | 16 ++++++++-------- .../entity/projectile/RpgRocketEntity.java | 12 ++++++------ .../entity/projectile/WgMissileEntity.java | 16 ++++++++-------- .../entity/vehicle/DroneEntity.java | 4 ++-- .../entity/vehicle/Yx100Entity.java | 2 ++ 9 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java index 6460d90eb..fa211ff6a 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.init.*; @@ -165,6 +166,8 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E } causeExplode(result.getLocation()); + + discard(); } } @@ -175,6 +178,11 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + if (firstHit) { + causeExplode(blockHitResult.getLocation()); + firstHit = false; + Mod.queueServerWork(3, this::discard); + } this.level().destroyBlock(resultPos, true); } } @@ -205,7 +213,6 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E } else { ParticleTool.spawnMediumExplosionParticles(this.level(), vec3); } - discard(); } @Override @@ -271,13 +278,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f)); destroyBlock(); } - - @Override - public void destroy(Vec3 pos) { - causeExplode(pos); - - } - + @Override public boolean isNoGravity() { return true; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java index 804762a23..6c20f92e2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.init.ModDamageTypes; @@ -153,6 +154,11 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + if (firstHit) { + causeExplode(blockHitResult.getLocation()); + firstHit = false; + Mod.queueServerWork(3, this::discard); + } this.level().destroyBlock(resultPos, true); } } @@ -220,11 +226,6 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt } } - @Override - public void destroy(Vec3 pos) { - causeExplode(pos); - } - private void causeExplode(Vec3 vec3) { CustomExplosion explosion = new CustomExplosion(this.level(), this, ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FastThrowableProjectile.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FastThrowableProjectile.java index 57d7bcab7..cebfcbdf0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FastThrowableProjectile.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FastThrowableProjectile.java @@ -33,6 +33,8 @@ public abstract class FastThrowableProjectile extends ThrowableItemProjectile im public int durability = 50; + public boolean firstHit = true; + private boolean isFastMoving = false; public FastThrowableProjectile(EntityType pEntityType, Level pLevel) { @@ -97,16 +99,13 @@ public abstract class FastThrowableProjectile extends ThrowableItemProjectile im this.level().destroyBlock(pos, true); } if (hardness == -1 || hardness > durability || durability <= 0) { - destroy(pos.getCenter()); - break; + discard(); } } } } } - public void destroy(Vec3 pos) { - } @Override public void syncMotion() { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HeliRocketEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HeliRocketEntity.java index 06cc08673..2d8f898a2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HeliRocketEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HeliRocketEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModEntities; @@ -128,6 +129,11 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + if (firstHit) { + causeExplode(blockHitResult.getLocation()); + firstHit = false; + Mod.queueServerWork(3, this::discard); + } this.level().destroyBlock(resultPos, true); } } @@ -154,7 +160,6 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); - discard(); } @@ -184,11 +189,6 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti destroyBlock(); } - @Override - public void destroy(Vec3 pos) { - causeExplode(pos); - } - public static void causeRocketExplode(ThrowableItemProjectile projectile, @Nullable DamageSource source, Entity target, float damage, float radius, float damageMultiplier) { CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile, source, damage, projectile.getX(), projectile.getY(), projectile.getZ(), radius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true).setDamageMultiplier(damageMultiplier); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java index 74aa65411..280eb6c9c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.init.*; @@ -73,7 +74,7 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo this.entityData.set(TARGET_X, (float) targetPos.x); this.entityData.set(TARGET_Y, (float) targetPos.y); this.entityData.set(TARGET_Z, (float) targetPos.z); - this.durability = 35; + this.durability = 50; } public void setMonsterMultiplier(float monsterMultiplier) { @@ -208,6 +209,11 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + if (firstHit) { + causeExplode(blockHitResult.getLocation()); + firstHit = false; + Mod.queueServerWork(3, this::discard); + } this.level().destroyBlock(resultPos, true); } } @@ -234,7 +240,6 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); - discard(); } @Override @@ -357,12 +362,7 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo this.setDeltaMovement(this.getDeltaMovement().multiply(0.96, 0.96, 0.96)); destroyBlock(); } - - @Override - public void destroy(Vec3 pos) { - causeExplode(pos); - } - + private PlayState movementPredicate(AnimationState event) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.jvm.idle")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java index 68a71bac4..38d179d85 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModEntities; @@ -123,6 +124,11 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + if (firstHit) { + causeExplode(blockHitResult.getLocation()); + firstHit = false; + Mod.queueServerWork(3, this::discard); + } this.level().destroyBlock(resultPos, true); } } @@ -181,7 +187,6 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); - discard(); } @Override @@ -211,11 +216,6 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit destroyBlock(); } - @Override - public void destroy(Vec3 pos) { - causeExplode(pos); - } - private PlayState movementPredicate(AnimationState event) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.rpg.idle")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java index 388d247d3..b65a78c6e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java @@ -1,5 +1,6 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.Mod; import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.entity.vehicle.base.VehicleEntity; import com.atsuishio.superbwarfare.init.ModDamageTypes; @@ -61,7 +62,7 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit this.damage = damage; this.explosionDamage = explosionDamage; this.explosionRadius = explosionRadius; - this.durability = 25; + this.durability = 50; } @Override @@ -139,6 +140,11 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + if (firstHit) { + causeExplode(blockHitResult.getLocation()); + firstHit = false; + Mod.queueServerWork(3, this::discard); + } this.level().destroyBlock(resultPos, true); } } @@ -242,13 +248,7 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit } destroyBlock(); } - - @Override - public void destroy(Vec3 pos) { - causeExplode(pos); - discard(); - } - + private PlayState movementPredicate(AnimationState event) { return event.setAndContinue(RawAnimation.begin().thenLoop("animation.jvm.idle")); } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java index c4e06c24a..653b76bfa 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/DroneEntity.java @@ -576,10 +576,10 @@ public class DroneEntity extends MobileVehicleEntity implements GeoEntity { Entity attacker = EntityFindUtil.findEntity(this.level(), this.entityData.get(LAST_ATTACKER_UUID)); Player controller = EntityFindUtil.findPlayer(this.level(), this.entityData.get(CONTROLLER)); - Entity mortarShell = new MortarShellEntity(controller, level()); assert controller != null; + Entity mortarShell = new MortarShellEntity(controller, level()); Entity c4 = new C4Entity(controller, level()); - Entity rpg = new RpgRocketEntity(controller, level(), ExplosionConfig.RPG_EXPLOSION_DAMAGE.get()); + Entity rpg = new RpgRocketEntity(controller, level()); CustomExplosion explosion = switch (mode) { case 1 -> new CustomExplosion(this.level(), this, diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java index b114033ad..5895753d3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -236,6 +236,8 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti this.playSound(ModSounds.WHEEL_STEP.get(), (float) (getDeltaMovement().length() * 0.15), random.nextFloat() * 0.15f + 1.05f); } + + @Override public void baseTick() { super.baseTick();