diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java index a337eeb4b..d9de4f544 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/CannonHudOverlay.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.client.screens; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.client.RenderHelper; +import com.atsuishio.superbwarfare.config.server.CannonConfig; import com.atsuishio.superbwarfare.entity.ICannonEntity; import com.atsuishio.superbwarfare.entity.Mk42Entity; import com.atsuishio.superbwarfare.entity.Mle1934Entity; @@ -109,12 +110,12 @@ public class CannonHudOverlay { if (cannon instanceof Mk42Entity) { health = cannon.getEntityData().get(Mk42Entity.HEALTH); - maxHealth = 700; + maxHealth = CannonConfig.MK42_HP.get(); } if (cannon instanceof Mle1934Entity) { health = cannon.getEntityData().get(Mle1934Entity.HEALTH); - maxHealth = 800; + maxHealth = CannonConfig.MLE1934_HP.get(); } GuiGraphics guiGraphics = event.getGuiGraphics(); diff --git a/src/main/java/com/atsuishio/superbwarfare/config/ServerConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/ServerConfig.java index 12adb3bf1..35c527972 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/ServerConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/ServerConfig.java @@ -1,5 +1,7 @@ package com.atsuishio.superbwarfare.config; +import com.atsuishio.superbwarfare.config.server.CannonConfig; +import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.config.server.SpawnConfig; import net.minecraftforge.common.ForgeConfigSpec; @@ -11,6 +13,8 @@ public class ServerConfig { SpawnConfig.init(builder); ExplosionDestroyConfig.init(builder); + ExplosionConfig.init(builder); + CannonConfig.init(builder); return builder.build(); } diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/CannonConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/CannonConfig.java new file mode 100644 index 000000000..229e76b3b --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/CannonConfig.java @@ -0,0 +1,75 @@ +package com.atsuishio.superbwarfare.config.server; + +import net.minecraftforge.common.ForgeConfigSpec; + +public class CannonConfig { + + public static ForgeConfigSpec.IntValue MK42_HP; + public static ForgeConfigSpec.IntValue MK42_AP_DAMAGE; + public static ForgeConfigSpec.IntValue MK42_AP_EXPLOSION_DAMAGE; + public static ForgeConfigSpec.IntValue MK42_AP_EXPLOSION_RADIUS; + public static ForgeConfigSpec.IntValue MK42_HE_DAMAGE; + public static ForgeConfigSpec.IntValue MK42_HE_EXPLOSION_DAMAGE; + public static ForgeConfigSpec.IntValue MK42_HE_EXPLOSION_RADIUS; + + public static ForgeConfigSpec.IntValue MLE1934_HP; + public static ForgeConfigSpec.IntValue MLE1934_AP_DAMAGE; + public static ForgeConfigSpec.IntValue MLE1934_AP_EXPLOSION_DAMAGE; + public static ForgeConfigSpec.IntValue MLE1934_AP_EXPLOSION_RADIUS; + public static ForgeConfigSpec.IntValue MLE1934_HE_DAMAGE; + public static ForgeConfigSpec.IntValue MLE1934_HE_EXPLOSION_DAMAGE; + public static ForgeConfigSpec.IntValue MLE1934_HE_EXPLOSION_RADIUS; + + public static void init(ForgeConfigSpec.Builder builder) { + builder.push("MK-42"); + + builder.comment("The HealthPoint of MK-42"); + MK42_HP = builder.defineInRange("Mk-42 HP", 500, 1, 10000000); + + builder.comment("The AP shell damage of MK-42"); + MK42_AP_DAMAGE = builder.defineInRange("Mk-42 AP damage", 300, 1, 10000000); + + builder.comment("The AP shell explosion damage of MK-42"); + MK42_AP_EXPLOSION_DAMAGE = builder.defineInRange("Mk-42 AP explosion damage", 120, 1, 10000000); + + builder.comment("The AP shell explosion radius of MK-42"); + MK42_AP_EXPLOSION_RADIUS = builder.defineInRange("Mk-42 AP explosion radius", 3, 1, 50); + + builder.comment("The HE shell damage of MK-42"); + MK42_HE_DAMAGE = builder.defineInRange("Mk-42 HE damage", 150, 1, 10000000); + + builder.comment("The HE shell explosion damage of MK-42"); + MK42_HE_EXPLOSION_DAMAGE = builder.defineInRange("Mk-42 HE explosion damage", 200, 1, 10000000); + + builder.comment("The HE shell explosion radius of MK-42"); + MK42_HE_EXPLOSION_RADIUS = builder.defineInRange("Mk-42 HE explosion radius", 10, 1, 50); + + builder.pop(); + + builder.push("MLE-1934"); + + builder.comment("The HealthPoint of MLE-1934"); + MLE1934_HP = builder.defineInRange("MLE-1934 HP", 600, 1, 10000000); + + builder.comment("The AP shell damage of MLE-1934"); + MLE1934_AP_DAMAGE = builder.defineInRange("MLE-1934 AP damage", 350, 1, 10000000); + + builder.comment("The AP shell explosion damage of MLE-1934"); + MLE1934_AP_EXPLOSION_DAMAGE = builder.defineInRange("MLE-1934 AP explosion damage", 150, 1, 10000000); + + builder.comment("The AP shell explosion radius of MLE-1934"); + MLE1934_AP_EXPLOSION_RADIUS = builder.defineInRange("MLE-1934 AP explosion radius", 4, 1, 50); + + builder.comment("The HE shell damage of MLE-1934"); + MLE1934_HE_DAMAGE = builder.defineInRange("MLE-1934 HE damage", 180, 1, 10000000); + + builder.comment("The HE shell explosion damage of MLE-1934"); + MLE1934_HE_EXPLOSION_DAMAGE = builder.defineInRange("MLE-1934 HE explosion damage", 240, 1, 10000000); + + builder.comment("The HE shell explosion radius of MLE-1934"); + MLE1934_HE_EXPLOSION_RADIUS = builder.defineInRange("MLE-1934 HE explosion radius", 12, 1, 50); + + builder.pop(); + } + +} diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/ExplosionConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/ExplosionConfig.java new file mode 100644 index 000000000..f9b39978f --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/ExplosionConfig.java @@ -0,0 +1,18 @@ +package com.atsuishio.superbwarfare.config.server; + +import net.minecraftforge.common.ForgeConfigSpec; + +public class ExplosionConfig { + + public static ForgeConfigSpec.IntValue EXPLOSION_PENETRATION_RATIO; + + public static void init(ForgeConfigSpec.Builder builder) { + builder.push("explosion_penetration"); + + builder.comment("The percentage of explosion damage you take behind cover"); + EXPLOSION_PENETRATION_RATIO = builder.defineInRange("explosion_destroy", 15, 0, 100); + + builder.pop(); + } + +} diff --git a/src/main/java/com/atsuishio/superbwarfare/config/server/ExplosionDestroyConfig.java b/src/main/java/com/atsuishio/superbwarfare/config/server/ExplosionDestroyConfig.java index 342bc512a..f02074b5d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/config/server/ExplosionDestroyConfig.java +++ b/src/main/java/com/atsuishio/superbwarfare/config/server/ExplosionDestroyConfig.java @@ -7,7 +7,7 @@ public class ExplosionDestroyConfig { public static ForgeConfigSpec.BooleanValue EXPLOSION_DESTROY; public static void init(ForgeConfigSpec.Builder builder) { - builder.push("spawn"); + builder.push("explosion"); builder.comment("Set TRUE to allow Explosion to destroy blocks"); EXPLOSION_DESTROY = builder.define("explosion_destroy", false); diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java index 5f6e1f5d8..b396332e5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mk42Entity.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.entity; import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.config.server.CannonConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity; import com.atsuishio.superbwarfare.init.*; @@ -53,7 +54,7 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { public static final EntityDataAccessor COOL_DOWN = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.INT); public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mk42Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); - public static final float MAX_HEALTH = 700.0f; + public static final float MAX_HEALTH = CannonConfig.MK42_HP.get(); protected int interpolationSteps; protected double serverYRot; protected double serverXRot; @@ -203,27 +204,27 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0)); } - if (this.entityData.get(HEALTH) <= 300) { + if (this.entityData.get(HEALTH) <= 0.4 * CannonConfig.MK42_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); } } - if (this.entityData.get(HEALTH) <= 200) { + if (this.entityData.get(HEALTH) <= 0.25 * CannonConfig.MK42_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); } } - if (this.entityData.get(HEALTH) <= 150) { + if (this.entityData.get(HEALTH) <= 0.15 * CannonConfig.MK42_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); } } - if (this.entityData.get(HEALTH) <= 100) { + if (this.entityData.get(HEALTH) <= 0.1 * CannonConfig.MK42_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); @@ -281,18 +282,18 @@ public class Mk42Entity extends Entity implements GeoEntity, ICannonEntity { int durability = 0; if (stack.is(ModItems.HE_5_INCHES.get())) { - hitDamage = 400; - explosionRadius = 12; - explosionDamage = 420; + hitDamage = CannonConfig.MK42_HE_DAMAGE.get(); + explosionRadius = CannonConfig.MK42_HE_EXPLOSION_RADIUS.get(); + explosionDamage = CannonConfig.MK42_HE_EXPLOSION_DAMAGE.get(); fireProbability = 0.18F; fireTime = 2; durability = 1; } if (stack.is(ModItems.AP_5_INCHES.get())) { - hitDamage = 800; - explosionRadius = 3; - explosionDamage = 200; + hitDamage = CannonConfig.MK42_AP_DAMAGE.get(); + explosionRadius = CannonConfig.MK42_AP_EXPLOSION_RADIUS.get(); + explosionDamage = CannonConfig.MK42_AP_EXPLOSION_DAMAGE.get(); fireProbability = 0; fireTime = 0; durability = 60; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java index f155fa6be..dce3fcd6c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/Mle1934Entity.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.entity; import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.config.server.CannonConfig; import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.entity.projectile.CannonShellEntity; import com.atsuishio.superbwarfare.init.*; @@ -56,7 +57,7 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(Mle1934Entity.class, EntityDataSerializers.FLOAT); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); - public static final float MAX_HEALTH = 800.0f; + public static final float MAX_HEALTH = CannonConfig.MLE1934_HP.get(); protected int interpolationSteps; protected double serverYRot; @@ -210,27 +211,27 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { this.setDeltaMovement(this.getDeltaMovement().add(0.0, -0.04, 0.0)); } - if (this.entityData.get(HEALTH) <= 300) { + if (this.entityData.get(HEALTH) <= 0.4 * CannonConfig.MLE1934_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); } } - if (this.entityData.get(HEALTH) <= 200) { + if (this.entityData.get(HEALTH) <= 0.25 * CannonConfig.MLE1934_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); } } - if (this.entityData.get(HEALTH) <= 150) { + if (this.entityData.get(HEALTH) <= 0.15 * CannonConfig.MLE1934_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 1, 0.75, 0.5, 0.75, 0.01, false); } } - if (this.entityData.get(HEALTH) <= 100) { + if (this.entityData.get(HEALTH) <= 0.1 * CannonConfig.MLE1934_HP.get()) { if (this.level() instanceof ServerLevel serverLevel) { ParticleTool.sendParticle(serverLevel, ParticleTypes.LARGE_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.getX(), this.getY() + 2.5, this.getZ(), 2, 0.75, 0.5, 0.75, 0.01, false); @@ -289,9 +290,9 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { boolean salvoShoot = false; if (stack.is(ModItems.HE_5_INCHES.get())) { - hitDamage = 450; - explosionRadius = 13; - explosionDamage = 480; + hitDamage = CannonConfig.MLE1934_HE_DAMAGE.get(); + explosionRadius = CannonConfig.MLE1934_HE_EXPLOSION_RADIUS.get(); + explosionDamage = CannonConfig.MLE1934_HE_EXPLOSION_DAMAGE.get(); fireProbability = 0.24F; fireTime = 5; durability = 1; @@ -299,9 +300,9 @@ public class Mle1934Entity extends Entity implements GeoEntity, ICannonEntity { } if (stack.is(ModItems.AP_5_INCHES.get())) { - hitDamage = 900; - explosionRadius = 3.8f; - explosionDamage = 220; + hitDamage = CannonConfig.MLE1934_AP_DAMAGE.get(); + explosionRadius = CannonConfig.MLE1934_AP_EXPLOSION_RADIUS.get(); + explosionDamage = CannonConfig.MLE1934_AP_EXPLOSION_DAMAGE.get(); fireProbability = 0; fireTime = 0; durability = 70; diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mk42DamageLayer.java b/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mk42DamageLayer.java index fdc3e8524..e43fbe416 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mk42DamageLayer.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mk42DamageLayer.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.entity.layer; import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.config.server.CannonConfig; import com.atsuishio.superbwarfare.entity.Mk42Entity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -24,7 +25,7 @@ public class Mk42DamageLayer extends GeoRenderLayer { @Override public void render(PoseStack poseStack, Mk42Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { RenderType glowRenderType = RenderType.entityTranslucent(LAYER); - float heal = Mth.clamp((300 - animatable.getEntityData().get(Mk42Entity.HEALTH)) * 0.0033f, 0.1f, 1); + float heal = Mth.clamp((0.3f * CannonConfig.MK42_HP.get() - animatable.getEntityData().get(Mk42Entity.HEALTH)) * 0.000007f * CannonConfig.MK42_HP.get(), 0.1f, 1); getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java b/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java index b8eec8683..02f522744 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/layer/Mle1934DamageLayer.java @@ -1,6 +1,8 @@ package com.atsuishio.superbwarfare.entity.layer; import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.config.server.CannonConfig; +import com.atsuishio.superbwarfare.entity.Mk42Entity; import com.atsuishio.superbwarfare.entity.Mle1934Entity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; @@ -23,7 +25,7 @@ public class Mle1934DamageLayer extends GeoRenderLayer { @Override public void render(PoseStack poseStack, Mle1934Entity animatable, BakedGeoModel bakedModel, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, float partialTick, int packedLight, int packedOverlay) { RenderType glowRenderType = RenderType.entityTranslucent(LAYER); - float heal = Mth.clamp((300 - animatable.getEntityData().get(Mle1934Entity.HEALTH)) * 0.0033f,0.1f,1); + float heal = Mth.clamp((0.3f * CannonConfig.MLE1934_HP.get() - animatable.getEntityData().get(Mk42Entity.HEALTH)) * 0.000007f * CannonConfig.MLE1934_HP.get(), 0.1f, 1); getRenderer().reRender(getDefaultBakedModel(animatable), poseStack, bufferSource, animatable, glowRenderType, bufferSource.getBuffer(glowRenderType), partialTick, packedLight, OverlayTexture.NO_OVERLAY, 1, 1, 1, heal); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java index 32ffd1961..7ad6336e0 100644 --- a/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java +++ b/src/main/java/com/atsuishio/superbwarfare/tools/CustomExplosion.java @@ -1,6 +1,7 @@ package com.atsuishio.superbwarfare.tools; import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.config.server.ExplosionConfig; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.google.common.collect.Sets; import net.minecraft.core.BlockPos; @@ -170,7 +171,7 @@ public class CustomExplosion extends Explosion { xDistance /= distance; yDistance /= distance; zDistance /= distance; - double seenPercent = Mth.clamp(getSeenPercent(position, entity), 0.125, Double.POSITIVE_INFINITY); + double seenPercent = Mth.clamp(getSeenPercent(position, entity), 0.01 * ExplosionConfig.EXPLOSION_PENETRATION_RATIO.get(), Double.POSITIVE_INFINITY); double damagePercent = (1.0D - distanceRate) * seenPercent; double damageFinal = (damagePercent * damagePercent + damagePercent) / 2.0D * damage;