diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Tm62Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Tm62Entity.java index 7be9e7a25..2e8a4dff3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Tm62Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Tm62Entity.java @@ -26,6 +26,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.level.entity.EntityTypeTest; +import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.neoforged.neoforge.event.EventHooks; import net.neoforged.neoforge.items.ItemHandlerHelper; @@ -225,6 +226,15 @@ public class Tm62Entity extends Entity implements GeoEntity, OwnableEntity { if (trigger) { triggerExplode(); + if (this.level() instanceof ServerLevel) { + AABB aabb = new AABB(position(), position()).inflate(2); + BlockPos.betweenClosedStream(aabb).forEach((blockPos) -> { + float hard = this.level().getBlockState(blockPos).getBlock().defaultDestroyTime(); + if (ExplosionConfig.EXPLOSION_DESTROY.get() && hard != -1) { + this.level().destroyBlock(blockPos, true); + } + }); + } } } } 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 67189f7ad..6460d90eb 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Agm65Entity.java @@ -29,7 +29,6 @@ import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.Item; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; @@ -54,15 +53,17 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E private float explosionDamage = ExplosionConfig.AGM_65_EXPLOSION_DAMAGE.get(); private float explosionRadius = ExplosionConfig.AGM_65_EXPLOSION_RADIUS.get().floatValue(); private boolean distracted = false; - private int durability = 100; + private int durability = 50; public Agm65Entity(EntityType type, Level world) { super(type, world); this.noCulling = true; + this.durability = 25; } public Agm65Entity(LivingEntity entity, Level level) { super(ModEntities.AGM_65.get(), entity, level); + this.durability = 25; } public void setTargetUuid(String uuid) { @@ -163,12 +164,7 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E entity.invulnerableTime = 0; } - for (int i = 0; i < 5; i++) { - causeExplode(result.getLocation().add(getDeltaMovement().normalize().scale(i)), this.explosionRadius * 0.5f, false); - } - - causeExplode(result.getLocation(), this.explosionRadius, true); - this.discard(); + causeExplode(result.getLocation()); } } @@ -176,42 +172,20 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E public void onHitBlock(@NotNull BlockHitResult blockHitResult) { if (this.level() instanceof ServerLevel) { BlockPos resultPos = blockHitResult.getBlockPos(); - float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); - - if (hardness == -1) { - this.discard(); - causeExplode(blockHitResult.getLocation(), this.explosionRadius, true); - return; - } else { + if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { this.level().destroyBlock(resultPos, true); } } - - causeExplode(blockHitResult.getLocation(), this.explosionRadius, true); - - for (int i = 0; i < 8; i++) { - Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i)); - AABB aabb = new AABB(hitPos, hitPos).inflate(0.25); - if (durability > 0) { - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - float hard = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); - durability -= (int) hard; - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(pos, true); - } - causeExplode(hitPos, this.explosionRadius * 0.5f, false); - }); - } - } - if (durability <= 0) { - discard(); + if (!ExplosionConfig.EXPLOSION_DESTROY.get()) { + causeExplode(blockHitResult.getLocation()); + this.discard(); } } } - private void causeExplode(Vec3 vec3, float radius, boolean isHuge) { + private void causeExplode(Vec3 vec3) { CustomExplosion explosion = new CustomExplosion(this.level(), this, ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), this, @@ -220,17 +194,18 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E vec3.x, vec3.y, vec3.z, - radius, + explosionRadius, ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true). setDamageMultiplier(1); explosion.explode(); EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); - if (isHuge) { + if (explosionRadius > 9) { ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); } else { ParticleTool.spawnMediumExplosionParticles(this.level(), vec3); } + discard(); } @Override @@ -294,6 +269,13 @@ public class Agm65Entity extends FastThrowableProjectile implements GeoEntity, E float f = (float) Mth.clamp(1 - 0.005 * getDeltaMovement().length(), 0.001, 1); this.setDeltaMovement(this.getDeltaMovement().multiply(f, f, f)); + destroyBlock(); + } + + @Override + public void destroy(Vec3 pos) { + causeExplode(pos); + } @Override diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/C4Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/C4Entity.java index 88554b096..a1a12b4a4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/C4Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/C4Entity.java @@ -414,13 +414,12 @@ public class C4Entity extends Entity implements GeoEntity, OwnableEntity { } if (this.level() instanceof ServerLevel) { - AABB aabb = new AABB(pos, pos).inflate(3); + AABB aabb = new AABB(pos, pos).inflate(2); BlockPos.betweenClosedStream(aabb).forEach((blockPos) -> { float hard = this.level().getBlockState(blockPos).getBlock().defaultDestroyTime(); - if (ExplosionConfig.EXPLOSION_DESTROY.get() && hard != -1 && new Vec3(blockPos.getX(), blockPos.getY(), blockPos.getZ()).distanceTo(position()) < 2) { + if (ExplosionConfig.EXPLOSION_DESTROY.get() && hard != -1) { this.level().destroyBlock(blockPos, 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 f9f599ce9..804762a23 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/CannonShellEntity.java @@ -25,7 +25,7 @@ import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.Item; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; @@ -37,6 +37,7 @@ import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache; import software.bernie.geckolib.animation.*; import software.bernie.geckolib.util.GeckoLibUtil; +import javax.annotation.ParametersAreNonnullByDefault; import java.util.HashSet; import java.util.Set; @@ -49,7 +50,6 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt private float explosionDamage = 0; private float fireProbability = 0; private int fireTime = 0; - private int durability = 40; public Set loadedChunks = new HashSet<>(); private float gravity = 0.1f; @@ -73,6 +73,12 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt return this; } + @Override + @ParametersAreNonnullByDefault + public boolean isColliding(BlockPos pPos, BlockState pState) { + return true; + } + @Override public void addAdditionalSaveData(@NotNull CompoundTag pCompound) { super.addAdditionalSaveData(pCompound); @@ -140,6 +146,23 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt return true; } + @Override + public void onHitBlock(@NotNull BlockHitResult blockHitResult) { + if (this.level() instanceof ServerLevel) { + BlockPos resultPos = blockHitResult.getBlockPos(); + float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); + if (hardness != -1) { + if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + this.level().destroyBlock(resultPos, true); + } + } + if (!ExplosionConfig.EXPLOSION_DESTROY.get()) { + causeExplode(blockHitResult.getLocation()); + this.discard(); + } + } + } + @Override public void onHitEntity(@NotNull EntityHitResult entityHitResult) { if (this.level() instanceof ServerLevel) { @@ -161,7 +184,7 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt } ParticleTool.cannonHitParticles(this.level(), this.position(), this); - causeExplode(entityHitResult.getLocation(), this.radius, true); + causeExplode(entityHitResult.getLocation()); if (entity instanceof VehicleEntity) { this.discard(); } @@ -169,45 +192,6 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt } } - @Override - public void onHitBlock(@NotNull BlockHitResult blockHitResult) { - if (this.level() instanceof ServerLevel) { - BlockPos resultPos = blockHitResult.getBlockPos(); - - float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); - - if (hardness == -1) { - this.discard(); - causeExplode(blockHitResult.getLocation(), this.radius, true); - return; - } else { - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(resultPos, true); - } - } - - causeExplode(blockHitResult.getLocation(), this.radius, true); - - for (int i = 0; i < 5; i++) { - Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i)); - AABB aabb = new AABB(hitPos, hitPos).inflate(0.25); - if (durability > 0) { - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - float hard = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); - durability -= (int) hard; - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(pos, true); - } - causeExplode(hitPos, this.radius * 0.5f, false); - }); - } - } - if (durability <= 0) { - discard(); - } - } - } - @Override public void tick() { super.tick(); @@ -218,9 +202,12 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt // 更新需要加载的区块 ChunkLoadTool.updateLoadedChunks(serverLevel, this, this.loadedChunks); } + + destroyBlock(); + if (this.tickCount > 600 || this.isInWater()) { if (this.level() instanceof ServerLevel) { - causeExplode(position(), this.radius, true); + causeExplode(position()); } this.discard(); } @@ -233,7 +220,12 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt } } - private void causeExplode(Vec3 vec3, float radius, boolean isHuge) { + @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(), this, @@ -248,11 +240,12 @@ public class CannonShellEntity extends FastThrowableProjectile implements GeoEnt explosion.explode(); EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); - if (isHuge) { + if (radius > 9) { ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); } else { ParticleTool.spawnMediumExplosionParticles(this.level(), vec3); } + discard(); } private PlayState movementPredicate(AnimationState event) { 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 76ba4624b..57d7bcab7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FastThrowableProjectile.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/FastThrowableProjectile.java @@ -1,21 +1,29 @@ package com.atsuishio.superbwarfare.entity.projectile; +import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.network.message.receive.ClientMotionSyncMessage; +import net.minecraft.core.BlockPos; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; +import net.minecraft.util.Mth; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.neoforged.neoforge.entity.IEntityWithComplexSpawn; import net.neoforged.neoforge.network.PacketDistributor; import org.jetbrains.annotations.NotNull; import javax.annotation.Nullable; +import java.util.List; import java.util.function.Consumer; +import static com.atsuishio.superbwarfare.tools.TraceTool.getBlocksAlongRay; + public abstract class FastThrowableProjectile extends ThrowableItemProjectile implements CustomSyncMotionEntity, IEntityWithComplexSpawn { public static Consumer flySound = projectile -> { @@ -23,6 +31,8 @@ public abstract class FastThrowableProjectile extends ThrowableItemProjectile im public static Consumer nearFlySound = projectile -> { }; + public int durability = 50; + private boolean isFastMoving = false; public FastThrowableProjectile(EntityType pEntityType, Level pLevel) { @@ -69,6 +79,35 @@ public abstract class FastThrowableProjectile extends ThrowableItemProjectile im this.syncMotion(); } + public void destroyBlock() { + if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + Vec3 posO = new Vec3(xo, yo, zo); + List blockList = getBlocksAlongRay(posO, getDeltaMovement(), getDeltaMovement().length()); + for (BlockPos pos : blockList) { + BlockState blockState = level().getBlockState(pos); + if (!blockState.is(Blocks.AIR)) { + float hardness = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); + + double resistance = 1 - Mth.clamp(hardness / 100, 0, 0.8); + setDeltaMovement(getDeltaMovement().multiply(resistance, resistance, resistance)); + + durability -= 10 + (int) (0.5 * hardness); + + if (hardness <= durability && hardness != -1) { + this.level().destroyBlock(pos, true); + } + if (hardness == -1 || hardness > durability || durability <= 0) { + destroy(pos.getCenter()); + break; + } + } + } + } + } + + public void destroy(Vec3 pos) { + } + @Override public void syncMotion() { if (this.level().isClientSide) return; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java index 13a9c78c0..40044b054 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/GunGrenadeEntity.java @@ -1,6 +1,5 @@ package com.atsuishio.superbwarfare.entity.projectile; -import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.init.ModDamageTypes; import com.atsuishio.superbwarfare.init.ModEntities; import com.atsuishio.superbwarfare.init.ModItems; @@ -156,15 +155,6 @@ public class GunGrenadeEntity extends FastThrowableProjectile implements GeoEnti BlockPos resultPos = blockHitResult.getBlockPos(); BlockState state = this.level().getBlockState(resultPos); - if (this.level() instanceof ServerLevel) { - float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); - if (hardness != -1) { - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(resultPos, true); - } - } - } - if (state.getBlock() instanceof BellBlock bell) { bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection()); } 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 d684dd47f..06cc08673 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HeliRocketEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/HeliRocketEntity.java @@ -23,7 +23,6 @@ import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.item.Item; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; @@ -44,8 +43,6 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti private float explosionDamage = 60f; private float explosionRadius = 5f; - private int durability = 50; - public HeliRocketEntity(EntityType type, Level world) { super(type, world); this.noCulling = true; @@ -54,6 +51,7 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti public HeliRocketEntity(EntityType pEntityType, double pX, double pY, double pZ, Level pLevel) { super(pEntityType, pX, pY, pZ, pLevel); this.noCulling = true; + this.durability = 20; } public HeliRocketEntity(LivingEntity entity, Level level, float damage, float explosionDamage, float explosionRadius) { @@ -61,6 +59,7 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti this.damage = damage; this.explosionDamage = explosionDamage; this.explosionRadius = explosionRadius; + this.durability = 20; } @Override @@ -117,10 +116,6 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti entity.invulnerableTime = 0; } - for (int i = 0; i < 3; i++) { - apExplode(result.getLocation().add(getDeltaMovement().normalize().scale(i))); - } - causeExplode(result.getLocation()); this.discard(); } @@ -130,37 +125,15 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti public void onHitBlock(@NotNull BlockHitResult blockHitResult) { if (this.level() instanceof ServerLevel) { BlockPos resultPos = blockHitResult.getBlockPos(); - float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); - - if (hardness == -1) { - this.discard(); - causeExplode(blockHitResult.getLocation()); - return; - } else { + if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { this.level().destroyBlock(resultPos, true); } } - - causeExplode(blockHitResult.getLocation()); - - for (int i = 0; i < 3; i++) { - Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i)); - AABB aabb = new AABB(hitPos, hitPos).inflate(0.25); - if (durability > 0) { - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - float hard = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); - durability -= (int) hard; - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(pos, true); - } - apExplode(hitPos); - }); - } - } - if (durability <= 0) { - discard(); + if (!ExplosionConfig.EXPLOSION_DESTROY.get()) { + causeExplode(blockHitResult.getLocation()); + this.discard(); } } } @@ -181,25 +154,9 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); + discard(); } - private void apExplode(Vec3 vec3) { - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), - this, - this.getOwner()), - explosionDamage, - vec3.x, - vec3.y, - vec3.z, - explosionRadius * 0.5f, - ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true). - setDamageMultiplier(1); - explosion.explode(); - EventHooks.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), vec3); - } @Override public void tick() { @@ -224,6 +181,12 @@ public class HeliRocketEntity extends FastThrowableProjectile implements GeoEnti } this.discard(); } + 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) { 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 16beb6f3e..74aa65411 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/JavelinMissileEntity.java @@ -30,7 +30,6 @@ import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.Item; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; @@ -60,8 +59,6 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo private boolean distracted = false; private int guideType = 0; - private int durability = 70; - public JavelinMissileEntity(EntityType type, Level world) { super(type, world); this.noCulling = true; @@ -76,6 +73,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; } public void setMonsterMultiplier(float monsterMultiplier) { @@ -198,50 +196,24 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo entity.invulnerableTime = 0; } - for (int i = 0; i < 3; i++) { - apExplode(result.getLocation().add(getDeltaMovement().normalize().scale(i))); - } - causeExplode(result.getLocation()); this.discard(); } } @Override - public void onHitBlock(BlockHitResult blockHitResult) { + public void onHitBlock(@NotNull BlockHitResult blockHitResult) { if (this.level() instanceof ServerLevel) { BlockPos resultPos = blockHitResult.getBlockPos(); - float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); - - if (hardness == -1) { - this.discard(); - causeExplode(blockHitResult.getLocation()); - return; - } else { + if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get()) { this.level().destroyBlock(resultPos, true); } } - - causeExplode(blockHitResult.getLocation()); - - for (int i = 0; i < 3; i++) { - Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i)); - AABB aabb = new AABB(hitPos, hitPos).inflate(0.25); - if (durability > 0) { - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - float hard = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); - durability -= (int) hard; - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(pos, true); - } - apExplode(hitPos); - }); - } - } - if (durability <= 0) { - discard(); + if (!ExplosionConfig.EXPLOSION_DESTROY.get()) { + causeExplode(blockHitResult.getLocation()); + this.discard(); } } } @@ -262,24 +234,7 @@ public class JavelinMissileEntity extends FastThrowableProjectile implements Geo EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); - } - - private void apExplode(Vec3 vec3) { - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), - this, - this.getOwner()), - explosionDamage, - vec3.x, - vec3.y, - vec3.z, - explosionRadius * 0.5f, - ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true). - setDamageMultiplier(this.monsterMultiplier); - explosion.explode(); - EventHooks.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), vec3); + discard(); } @Override @@ -400,6 +355,12 @@ 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) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Mk82Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Mk82Entity.java index ded6d91bd..1316599b1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Mk82Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/Mk82Entity.java @@ -5,7 +5,6 @@ import com.atsuishio.superbwarfare.init.ModEntities; import com.atsuishio.superbwarfare.init.ModItems; import com.atsuishio.superbwarfare.init.ModSounds; import com.atsuishio.superbwarfare.tools.ProjectileTool; -import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; @@ -21,9 +20,7 @@ import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.entity.projectile.ThrownPotion; import net.minecraft.world.item.Item; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.animatable.instance.AnimatableInstanceCache; @@ -38,6 +35,8 @@ public class Mk82Entity extends FastThrowableProjectile implements GeoEntity, Ex private float explosionDamage = ExplosionConfig.MK_82_EXPLOSION_DAMAGE.get(); private float explosionRadius = ExplosionConfig.MK_82_EXPLOSION_RADIUS.get().floatValue(); + public int durability = 1; + public Mk82Entity(EntityType type, Level world) { super(type, world); this.noCulling = true; @@ -114,24 +113,16 @@ public class Mk82Entity extends FastThrowableProjectile implements GeoEntity, Ex } @Override - public boolean shouldRenderAtSqrDistance(double pDistance) { - return true; + public void onHitBlock(@NotNull BlockHitResult blockHitResult) { + if (this.level() instanceof ServerLevel) { + ProjectileTool.causeCustomExplode(this, this.explosionDamage, this.explosionRadius, 1.2f); + } + this.discard(); } @Override - public void onHitBlock(@NotNull BlockHitResult blockHitResult) { - if (this.level() instanceof ServerLevel) { - AABB aabb = new AABB(blockHitResult.getLocation(), blockHitResult.getLocation()).inflate(5); - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - float hard = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); - if (ExplosionConfig.EXPLOSION_DESTROY.get() && hard != -1 && new Vec3(pos.getX(), pos.getY(), pos.getZ()).distanceTo(blockHitResult.getLocation()) < 3) { - this.level().destroyBlock(pos, true); - } - - }); - ProjectileTool.causeCustomExplode(this, this.explosionDamage, this.explosionRadius, 1.2f); - this.discard(); - } + public boolean shouldRenderAtSqrDistance(double pDistance) { + return true; } @Override 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 715b74531..68a71bac4 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/RpgRocketEntity.java @@ -24,7 +24,6 @@ import net.minecraft.world.entity.projectile.ThrowableItemProjectile; import net.minecraft.world.item.Item; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; @@ -46,31 +45,22 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit private float explosionDamage = 200f; private float explosionRadius = 10; - private int durability = 50; public RpgRocketEntity(EntityType type, Level world) { super(type, world); this.noCulling = true; + this.durability = 20; } public RpgRocketEntity(EntityType pEntityType, double pX, double pY, double pZ, Level pLevel) { super(pEntityType, pX, pY, pZ, pLevel); this.noCulling = true; + this.durability = 20; } public RpgRocketEntity(LivingEntity entity, Level level) { super(ModEntities.RPG_ROCKET.get(), entity, level); - } - - public RpgRocketEntity(LivingEntity entity, Level level, float damage) { - this(entity, level); - this.damage = damage; - } - - public RpgRocketEntity(LivingEntity entity, Level level, float damage, float explosionDamage, float explosionRadius) { - this(entity, level, damage); - this.explosionDamage = explosionDamage; - this.explosionRadius = explosionRadius; + this.durability = 2; } @@ -126,6 +116,23 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit return true; } + @Override + public void onHitBlock(@NotNull BlockHitResult blockHitResult) { + if (this.level() instanceof ServerLevel) { + BlockPos resultPos = blockHitResult.getBlockPos(); + float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); + if (hardness != -1) { + if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + this.level().destroyBlock(resultPos, true); + } + } + if (!ExplosionConfig.EXPLOSION_DESTROY.get()) { + causeExplode(blockHitResult.getLocation()); + this.discard(); + } + } + } + @Override protected void onHitEntity(EntityHitResult result) { float damageMultiplier = 1 + this.monsterMultiplier; @@ -153,54 +160,11 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit entity.invulnerableTime = 0; } - for (int i = 0; i < 5; i++) { - apExplode(result.getLocation().add(getDeltaMovement().normalize().scale(i))); - } - causeExplode(result.getLocation()); this.discard(); } } - @Override - public void onHitBlock(@NotNull BlockHitResult blockHitResult) { - if (this.level() instanceof ServerLevel) { - BlockPos resultPos = blockHitResult.getBlockPos(); - - float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); - - if (hardness == -1) { - this.discard(); - causeExplode(blockHitResult.getLocation()); - return; - } else { - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(resultPos, true); - } - } - - causeExplode(blockHitResult.getLocation()); - - for (int i = 0; i < 5; i++) { - Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i)); - AABB aabb = new AABB(hitPos, hitPos).inflate(0.25); - if (durability > 0) { - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - float hard = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); - durability -= (int) hard; - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(pos, true); - } - apExplode(hitPos); - }); - } - } - if (durability <= 0) { - discard(); - } - } - } - private void causeExplode(Vec3 vec3) { CustomExplosion explosion = new CustomExplosion(this.level(), this, ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), @@ -217,24 +181,7 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); - } - - private void apExplode(Vec3 vec3) { - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), - this, - this.getOwner()), - explosionDamage, - vec3.x, - vec3.y, - vec3.z, - explosionRadius * 0.5f, - ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true). - setDamageMultiplier(this.monsterMultiplier); - explosion.explode(); - EventHooks.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), vec3); + discard(); } @Override @@ -261,6 +208,12 @@ public class RpgRocketEntity extends FastThrowableProjectile implements GeoEntit } this.discard(); } + destroyBlock(); + } + + @Override + public void destroy(Vec3 pos) { + causeExplode(pos); } private PlayState movementPredicate(AnimationState event) { diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java index b017f2f76..50cfdb6a1 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java @@ -14,6 +14,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundSource; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -62,7 +63,7 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G } @Override - public void addAdditionalSaveData(CompoundTag pCompound) { + public void addAdditionalSaveData(@NotNull CompoundTag pCompound) { super.addAdditionalSaveData(pCompound); pCompound.putFloat("Damage", this.damage); pCompound.putFloat("ExplosionDamage", this.explosionDamage); @@ -70,7 +71,7 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G } @Override - public void readAdditionalSaveData(CompoundTag pCompound) { + public void readAdditionalSaveData(@NotNull CompoundTag pCompound) { super.readAdditionalSaveData(pCompound); if (pCompound.contains("Damage")) { this.damage = pCompound.getFloat("Damage"); @@ -129,7 +130,10 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); if (hardness != -1) { if (ExplosionConfig.EXPLOSION_DESTROY.get() && this.blockInteraction == null) { - this.level().destroyBlock(resultPos, true); + boolean destroy = Math.random() < Mth.clamp(1 - (hardness / 50), 0.1, 1); + if (destroy) { + this.level().destroyBlock(resultPos, true); + } } } } 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 66806d4c4..388d247d3 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/WgMissileEntity.java @@ -31,7 +31,6 @@ import net.minecraft.world.item.Item; import net.minecraft.world.level.ClipContext; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; -import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.EntityHitResult; import net.minecraft.world.phys.Vec3; @@ -52,8 +51,6 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit private float explosionDamage = 200f; private float explosionRadius = 10f; - private int durability = 70; - public WgMissileEntity(EntityType type, Level level) { super(type, level); this.noCulling = true; @@ -64,6 +61,7 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit this.damage = damage; this.explosionDamage = explosionDamage; this.explosionRadius = explosionRadius; + this.durability = 25; } @Override @@ -134,6 +132,23 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit return true; } + @Override + public void onHitBlock(@NotNull BlockHitResult blockHitResult) { + if (this.level() instanceof ServerLevel) { + BlockPos resultPos = blockHitResult.getBlockPos(); + float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); + if (hardness != -1) { + if (ExplosionConfig.EXPLOSION_DESTROY.get()) { + this.level().destroyBlock(resultPos, true); + } + } + if (!ExplosionConfig.EXPLOSION_DESTROY.get()) { + causeExplode(blockHitResult.getLocation()); + this.discard(); + } + } + } + @Override protected void onHitEntity(EntityHitResult result) { Entity entity = result.getEntity(); @@ -156,54 +171,11 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit entity.invulnerableTime = 0; } - for (int i = 0; i < 5; i++) { - apExplode(result.getLocation().add(getDeltaMovement().normalize().scale(i))); - } - causeExplode(result.getLocation()); this.discard(); } } - @Override - public void onHitBlock(@NotNull BlockHitResult blockHitResult) { - if (this.level() instanceof ServerLevel) { - BlockPos resultPos = blockHitResult.getBlockPos(); - - float hardness = this.level().getBlockState(resultPos).getBlock().defaultDestroyTime(); - - if (hardness == -1) { - this.discard(); - causeExplode(blockHitResult.getLocation()); - return; - } else { - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(resultPos, true); - } - } - - causeExplode(blockHitResult.getLocation()); - - for (int i = 0; i < 5; i++) { - Vec3 hitPos = blockHitResult.getLocation().add(getDeltaMovement().normalize().scale(i)); - AABB aabb = new AABB(hitPos, hitPos).inflate(0.25); - if (durability > 0) { - BlockPos.betweenClosedStream(aabb).forEach((pos) -> { - float hard = this.level().getBlockState(pos).getBlock().defaultDestroyTime(); - durability -= (int) hard; - if (ExplosionConfig.EXPLOSION_DESTROY.get()) { - this.level().destroyBlock(pos, true); - } - apExplode(hitPos); - }); - } - } - if (durability <= 0) { - discard(); - } - } - } - private void causeExplode(Vec3 vec3) { CustomExplosion explosion = new CustomExplosion(this.level(), this, ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), @@ -222,24 +194,6 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit ParticleTool.spawnHugeExplosionParticles(this.level(), vec3); } - private void apExplode(Vec3 vec3) { - CustomExplosion explosion = new CustomExplosion(this.level(), this, - ModDamageTypes.causeProjectileBoomDamage(this.level().registryAccess(), - this, - this.getOwner()), - explosionDamage, - vec3.x, - vec3.y, - vec3.z, - explosionRadius * 0.5f, - ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP, true). - setDamageMultiplier(1); - explosion.explode(); - EventHooks.onExplosionStart(this.level(), explosion); - explosion.finalizeExplosion(false); - ParticleTool.spawnMediumExplosionParticles(this.level(), vec3); - } - @Override public void tick() { super.tick(); @@ -286,8 +240,14 @@ public class WgMissileEntity extends FastThrowableProjectile implements GeoEntit } this.discard(); } + 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/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java index 2b4d320a9..379c07901 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mk42Entity.java @@ -92,7 +92,7 @@ public class Mk42Entity extends VehicleEntity implements GeoEntity, CannonEntity .hitDamage(VehicleConfig.MK42_HE_DAMAGE.get()) .explosionDamage(VehicleConfig.MK42_HE_EXPLOSION_DAMAGE.get()) .explosionRadius(VehicleConfig.MK42_HE_EXPLOSION_RADIUS.get().floatValue()) - .durability(0) + .durability(1) .fireProbability(0.18F) .fireTime(2) .gravity(shellGravity) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java index 28bec89da..3277afa46 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Mle1934Entity.java @@ -84,7 +84,7 @@ public class Mle1934Entity extends VehicleEntity implements GeoEntity, CannonEnt .hitDamage(VehicleConfig.MLE1934_HE_DAMAGE.get()) .explosionDamage(VehicleConfig.MLE1934_HE_EXPLOSION_DAMAGE.get()) .explosionRadius(VehicleConfig.MLE1934_HE_EXPLOSION_RADIUS.get().floatValue()) - .durability(0) + .durability(1) .fireProbability(0.24F) .fireTime(5) .gravity(shellGravity) 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 a9d844853..b114033ad 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Yx100Entity.java @@ -133,7 +133,7 @@ public class Yx100Entity extends ContainerMobileVehicleEntity implements GeoEnti .explosionDamage(VehicleConfig.YX_100_HE_CANNON_EXPLOSION_DAMAGE.get()) .fireProbability(0.18F) .fireTime(2) - .durability(0) + .durability(1) .velocity(25) .gravity(0.1f) .sound(ModSounds.INTO_CANNON.get()) diff --git a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java index 7b2b32259..9b6a7f4e7 100644 --- a/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java +++ b/src/main/java/com/atsuishio/superbwarfare/item/gun/launcher/JavelinItem.java @@ -159,7 +159,7 @@ public class JavelinItem extends GunItem { Entity seekingEntity = SeekTool.seekEntity(player, player.level(), 512, 8); - if (seekingEntity.getType().is(ModTags.EntityTypes.DECOY)) { + if (seekingEntity != null && seekingEntity.getType().is(ModTags.EntityTypes.DECOY)) { tag.putInt("SeekTime", 0); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java b/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java index 35df1d0b7..a84a2d005 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/TraceTool.java @@ -12,6 +12,9 @@ import net.minecraft.world.entity.projectile.ProjectileUtil; import net.minecraft.world.level.ClipContext; import net.minecraft.world.phys.*; +import java.util.ArrayList; +import java.util.List; + import static com.atsuishio.superbwarfare.tools.SeekTool.smokeFilter; public class TraceTool { @@ -175,4 +178,36 @@ public class TraceTool { Vec3 vec32 = pos.add(vec31.x * pHitDistance, vec31.y * pHitDistance, vec31.z * pHitDistance); return vehicle.level().clip(new ClipContext(pos, vec32, ClipContext.Block.COLLIDER, ClipContext.Fluid.ANY, vehicle)); } + + public static List getBlocksAlongRay(Vec3 start, Vec3 direction, double maxDistance) { + List blocks = new ArrayList<>(); + + // 标准化方向向量 + Vec3 normalizedDir = direction.normalize(); + Vec3 end = start.add(normalizedDir.scale(maxDistance)); + + // DDA算法参数 + double step = 0.1; // 步长(越小精度越高) + double distance = 0; + BlockPos lastPos = null; + + while (distance <= maxDistance) { + Vec3 currentPos = start.add(normalizedDir.scale(distance)); + BlockPos blockPos = new BlockPos( + (int) Math.floor(currentPos.x), + (int) Math.floor(currentPos.y), + (int) Math.floor(currentPos.z) + ); + + // 避免重复添加同一方块 + if (lastPos == null || !lastPos.equals(blockPos)) { + blocks.add(blockPos); + lastPos = blockPos; + } + + distance += step; + } + + return blocks; + } } diff --git a/src/main/resources/data/superbwarfare/guns/javelin.json b/src/main/resources/data/superbwarfare/guns/javelin.json index 791662916..3c860798e 100644 --- a/src/main/resources/data/superbwarfare/guns/javelin.json +++ b/src/main/resources/data/superbwarfare/guns/javelin.json @@ -6,8 +6,8 @@ "Weight": 10, "EmptyReloadTime": 78, "Damage": 700, - "ExplosionDamage": 60, - "ExplosionRadius": 5, + "ExplosionDamage": 120, + "ExplosionRadius": 9, "AmmoType": "superbwarfare:javelin_missile", "AvailablePerks": [ "superbwarfare:powerful_attraction",