给小鸟添加了单独的破坏配置

This commit is contained in:
17146 2025-05-12 21:02:58 +08:00 committed by Light_Quanta
parent 6340223db3
commit 566a504923
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 23 additions and 6 deletions

View file

@ -65,6 +65,7 @@ public class VehicleConfig {
public static ModConfigSpec.IntValue AH_6_ROCKET_DAMAGE; 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_DAMAGE;
public static ModConfigSpec.IntValue AH_6_ROCKET_EXPLOSION_RADIUS; 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_HP;
public static ModConfigSpec.IntValue LAV_150_ENERGY_COST; public static ModConfigSpec.IntValue LAV_150_ENERGY_COST;
@ -308,6 +309,9 @@ public class VehicleConfig {
builder.comment("The rocket explosion radius of AH-6"); builder.comment("The rocket explosion radius of AH-6");
AH_6_ROCKET_EXPLOSION_RADIUS = builder.defineInRange("ah_6_rocket_explosion_radius", 5, 1, 10000000); 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.pop();
builder.push("LAV-150"); builder.push("LAV-150");

View file

@ -39,6 +39,7 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
private float explosionDamage = 80f; private float explosionDamage = 80f;
private float explosionRadius = 5f; private float explosionRadius = 5f;
private boolean aa; private boolean aa;
private Explosion.BlockInteraction blockInteraction;
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
public SmallCannonShellEntity(EntityType<? extends SmallCannonShellEntity> type, Level world) { public SmallCannonShellEntity(EntityType<? extends SmallCannonShellEntity> type, Level world) {
@ -54,6 +55,11 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
this.aa = aa; this.aa = aa;
} }
public SmallCannonShellEntity setBlockInteraction(Explosion.BlockInteraction blockInteraction) {
this.blockInteraction = blockInteraction;
return this;
}
@Override @Override
protected @NotNull Item getDefaultItem() { protected @NotNull Item getDefaultItem() {
return ModItems.SMALL_SHELL.get(); return ModItems.SMALL_SHELL.get();
@ -112,8 +118,10 @@ public class SmallCannonShellEntity extends FastThrowableProjectile implements G
vec3.y, vec3.y,
vec3.z, vec3.z,
explosionRadius, explosionRadius,
hitEntity ? Explosion.BlockInteraction.KEEP : (ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP)). this.blockInteraction != null ? this.blockInteraction :
setDamageMultiplier(1.25f); hitEntity ? Explosion.BlockInteraction.KEEP :
(ExplosionConfig.EXPLOSION_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP)
).setDamageMultiplier(1.25f);
explosion.explode(); explosion.explode();
EventHooks.onExplosionStart(this.level(), explosion); EventHooks.onExplosionStart(this.level(), explosion);
explosion.finalizeExplosion(false); 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)) .filter(entity -> !(entity instanceof SmallCannonShellEntity) && (entity.getBbWidth() >= 0.3 || entity.getBbHeight() >= 0.3))
.toList(); .toList();
for (var entity : entities) { for (var entity : entities) {
causeExplode(entity.position(), false); causeExplode(entity.position(), false);
entity.discard(); entity.discard();
this.discard(); this.discard();
} }
} }
} }

View file

@ -81,6 +81,7 @@ public class Ah6Entity extends ContainerMobileVehicleEntity implements GeoEntity
return new VehicleWeapon[][]{ return new VehicleWeapon[][]{
new VehicleWeapon[]{ new VehicleWeapon[]{
new SmallCannonShellWeapon() new SmallCannonShellWeapon()
.blockInteraction(VehicleConfig.AH_6_CANNON_DESTROY.get() ? Explosion.BlockInteraction.DESTROY : Explosion.BlockInteraction.KEEP)
.damage(VehicleConfig.AH_6_CANNON_DAMAGE.get()) .damage(VehicleConfig.AH_6_CANNON_DAMAGE.get())
.explosionDamage(VehicleConfig.AH_6_CANNON_EXPLOSION_DAMAGE.get().floatValue()) .explosionDamage(VehicleConfig.AH_6_CANNON_EXPLOSION_DAMAGE.get().floatValue())
.explosionRadius(VehicleConfig.AH_6_CANNON_EXPLOSION_RADIUS.get().floatValue()) .explosionRadius(VehicleConfig.AH_6_CANNON_EXPLOSION_RADIUS.get().floatValue())

View file

@ -2,12 +2,13 @@ package com.atsuishio.superbwarfare.entity.vehicle.weapon;
import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity; import com.atsuishio.superbwarfare.entity.projectile.SmallCannonShellEntity;
import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Explosion;
public class SmallCannonShellWeapon extends VehicleWeapon { public class SmallCannonShellWeapon extends VehicleWeapon {
public float damage = 40, explosionDamage = 80, explosionRadius = 5; public float damage = 40, explosionDamage = 80, explosionRadius = 5;
public boolean aa = false; public boolean aa = false;
public Explosion.BlockInteraction blockInteraction = null;
public SmallCannonShellWeapon damage(float damage) { public SmallCannonShellWeapon damage(float damage) {
this.damage = damage; this.damage = damage;
@ -29,7 +30,12 @@ public class SmallCannonShellWeapon extends VehicleWeapon {
return this; return this;
} }
public SmallCannonShellWeapon blockInteraction(Explosion.BlockInteraction blockInteraction) {
this.blockInteraction = blockInteraction;
return this;
}
public SmallCannonShellEntity create(LivingEntity entity) { 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);
} }
} }