diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java index b6e984768..f9872e458 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/VehicleConfig.java @@ -65,6 +65,7 @@ public class VehicleConfig { public static ModConfigSpec.IntValue AH_6_ROCKET_DAMAGE; public static ModConfigSpec.IntValue AH_6_ROCKET_EXPLOSION_DAMAGE; public static ModConfigSpec.IntValue AH_6_ROCKET_EXPLOSION_RADIUS; + public static ModConfigSpec.BooleanValue AH_6_CANNON_DESTROY; public static ModConfigSpec.IntValue LAV_150_HP; public static ModConfigSpec.IntValue LAV_150_ENERGY_COST; @@ -308,6 +309,9 @@ public class VehicleConfig { builder.comment("The rocket explosion radius of AH-6"); AH_6_ROCKET_EXPLOSION_RADIUS = builder.defineInRange("ah_6_rocket_explosion_radius", 5, 1, 10000000); + builder.comment("Whether to destroy the block when cannon of AH-6 hits a block"); + AH_6_CANNON_DESTROY = builder.define("ah_6_cannon_destroy", true); + builder.pop(); builder.push("LAV-150"); 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 b73db28a7..2afb25934 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/projectile/SmallCannonShellEntity.java @@ -39,6 +39,7 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G private float explosionDamage = 80f; private float explosionRadius = 5f; private boolean aa; + private Explosion.BlockInteraction blockInteraction; private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); public SmallCannonShellEntity(EntityType type, Level world) { @@ -54,6 +55,11 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G this.aa = aa; } + public SmallCannonShellEntity setBlockInteraction(Explosion.BlockInteraction blockInteraction) { + this.blockInteraction = blockInteraction; + return this; + } + @Override protected @NotNull Item getDefaultItem() { return ModItems.SMALL_SHELL.get(); @@ -112,8 +118,10 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G vec3.y, vec3.z, explosionRadius, - hitEntity ? Explosion.BlockInteraction.KEEP : (ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP)). - setDamageMultiplier(1.25f); + this.blockInteraction != null ? this.blockInteraction : + hitEntity ? Explosion.BlockInteraction.KEEP : + (ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP) + ).setDamageMultiplier(1.25f); explosion.explode(); EventHooks.onExplosionStart(this.level(), explosion); explosion.finalizeExplosion(false); @@ -154,13 +162,11 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G .filter(entity -> !(entity instanceof SmallCannonShellEntity) && (entity.getBbWidth() >= 0.3 || entity.getBbHeight() >= 0.3)) .toList(); for (var entity : entities) { - causeExplode(entity.position(), false); entity.discard(); this.discard(); } - } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java index 8b737d72e..331e98047 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/Ah6Entity.java @@ -81,6 +81,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity return new VehicleWeapon[][]{ new VehicleWeapon[]{ new SmallCannonShellWeapon() + .blockInteraction(VehicleConfig.AH_6_CANNON_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP) .damage(VehicleConfig.AH_6_CANNON_DAMAGE.get()) .explosionDamage(VehicleConfig.AH_6_CANNON_EXPLOSION_DAMAGE.get().floatValue()) .explosionRadius(VehicleConfig.AH_6_CANNON_EXPLOSION_RADIUS.get().floatValue()) diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/SmallCannonShellWeapon.java b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/SmallCannonShellWeapon.java index 319171cf8..b20da0446 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/SmallCannonShellWeapon.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/vehicle/weapon/SmallCannonShellWeapon.java @@ -2,12 +2,13 @@ package com.atsuishio.superbwarfare.entity.vehicle.weapon; import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Explosion; public class SmallCannonShellWeapon extends VehicleWeapon { public float damage = 40, explosionDamage = 80, explosionRadius = 5; - public boolean aa = false; + public Explosion.BlockInteraction blockInteraction = null; public SmallCannonShellWeapon damage(float damage) { this.damage = damage; @@ -29,7 +30,12 @@ public class SmallCannonShellWeapon extends VehicleWeapon { return this; } + public SmallCannonShellWeapon blockInteraction(Explosion.BlockInteraction blockInteraction) { + this.blockInteraction = blockInteraction; + return this; + } + public SmallCannonShellEntity create(LivingEntity entity) { - return new SmallCannonShellEntity(entity, entity.level(), damage, explosionDamage, explosionRadius, aa); + return new SmallCannonShellEntity(entity, entity.level(), damage, explosionDamage, explosionRadius, aa).setBlockInteraction(blockInteraction); } }