From 213ecf561df8e7099317e6de5b13593c2cfe0841 Mon Sep 17 00:00:00 2001 From: Superkat32 Date: Sat, 30 Sep 2023 20:26:47 -0400 Subject: [PATCH] Version bump & emissive explosions BUILD: Bumped version FEAT: Made the particles (optionally) emissive! All particles which are orange always stay emissive, while the smoke begins emissive, but eventually go back to normal. Works with the underwater counterpart of the explosion effect too REFACTOR: The underwater blast wave particle now has its own factory, extending the blastwave particle factory. This is done to allow for the emissive explosion rule to be separate from the emissive underwater explosion rule REFACTOR: Deleted some old comments I think Signed-off-by: Superkat32 --- gradle.properties | 2 +- .../ExplosiveEnhancementClient.java | 2 +- .../config/ExplosiveConfig.java | 2 + .../config/YaclIntegration.java | 22 ++++++++++ .../particles/BlastWaveParticle.java | 8 ++++ .../particles/FireballParticle.java | 6 +++ .../particles/ShockwaveParticle.java | 6 +++ .../particles/SmokeParticle.java | 44 +++++++------------ .../particles/SparkParticle.java | 6 +++ .../UnderwaterBlastWaveParticle.java | 36 +++++++++++++++ .../particles/UnderwaterSparkParticle.java | 6 +++ .../explosiveenhancement/lang/en_us.json | 4 ++ 12 files changed, 113 insertions(+), 31 deletions(-) create mode 100644 src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterBlastWaveParticle.java diff --git a/gradle.properties b/gradle.properties index 56d79af..711ec15 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.19.2+build.28 loader_version=0.14.10 # Mod Properties -mod_version = 1.2.1-1.19.2 +mod_version = 1.2.2-1.19.2 maven_group = net.superkat archives_base_name = explosive-enhancement diff --git a/src/main/java/net/superkat/explosiveenhancement/ExplosiveEnhancementClient.java b/src/main/java/net/superkat/explosiveenhancement/ExplosiveEnhancementClient.java index 816f985..73882ce 100644 --- a/src/main/java/net/superkat/explosiveenhancement/ExplosiveEnhancementClient.java +++ b/src/main/java/net/superkat/explosiveenhancement/ExplosiveEnhancementClient.java @@ -26,7 +26,7 @@ public void onInitializeClient() { ParticleFactoryRegistry.getInstance().register(ExplosiveEnhancement.BUBBLE, BubbleParticle.Factory::new); ParticleFactoryRegistry.getInstance().register(ExplosiveEnhancement.SHOCKWAVE, ShockwaveParticle.Factory::new); ParticleFactoryRegistry.getInstance().register(ExplosiveEnhancement.BLANK_SHOCKWAVE, ShockwaveParticle.Factory::new); - ParticleFactoryRegistry.getInstance().register(ExplosiveEnhancement.UNDERWATERBLASTWAVE, BlastWaveParticle.Factory::new); + ParticleFactoryRegistry.getInstance().register(ExplosiveEnhancement.UNDERWATERBLASTWAVE, UnderwaterBlastWaveParticle.Factory::new); ParticleFactoryRegistry.getInstance().register(ExplosiveEnhancement.UNDERWATERSPARKS, UnderwaterSparkParticle.Factory::new); } diff --git a/src/main/java/net/superkat/explosiveenhancement/config/ExplosiveConfig.java b/src/main/java/net/superkat/explosiveenhancement/config/ExplosiveConfig.java index 28dc661..e07283c 100644 --- a/src/main/java/net/superkat/explosiveenhancement/config/ExplosiveConfig.java +++ b/src/main/java/net/superkat/explosiveenhancement/config/ExplosiveConfig.java @@ -42,6 +42,8 @@ public class ExplosiveConfig { public boolean attemptBetterSmallExplosions = true; public double smallExplosionYOffset = -0.5; public boolean modEnabled = true; + public boolean emissiveExplosion = true; + public boolean emissiveWaterExplosion = true; public boolean alwaysShow = false; public boolean debugLogs = false; diff --git a/src/main/java/net/superkat/explosiveenhancement/config/YaclIntegration.java b/src/main/java/net/superkat/explosiveenhancement/config/YaclIntegration.java index fb8354c..2187095 100644 --- a/src/main/java/net/superkat/explosiveenhancement/config/YaclIntegration.java +++ b/src/main/java/net/superkat/explosiveenhancement/config/YaclIntegration.java @@ -285,6 +285,26 @@ public static Screen makeScreen(Screen parent) { ) .controller(booleanOption -> new BooleanController(booleanOption, true)) .build(); + var emissiveExplosion = Option.createBuilder(boolean.class) + .name(Text.translatable("explosiveenhancement.extras.emissive")) + .tooltip(Text.translatable("explosiveenhancement.extras.emissive.tooltip")) + .binding( + defaults.emissiveExplosion, + () -> config.emissiveExplosion, + val -> config.emissiveExplosion = val + ) + .controller(booleanOption -> new BooleanController(booleanOption, true)) + .build(); + var emissiveWaterExplosion = Option.createBuilder(boolean.class) + .name(Text.translatable("explosiveenhancement.extras.emissivewater")) + .tooltip(Text.translatable("explosiveenhancement.extras.emissivewater.tooltip")) + .binding( + defaults.emissiveWaterExplosion, + () -> config.emissiveWaterExplosion, + val -> config.emissiveWaterExplosion = val + ) + .controller(booleanOption -> new BooleanController(booleanOption, true)) + .build(); var alwaysShow = Option.createBuilder(boolean.class) .name(Text.translatable("explosiveenhancement.extras.alwaysshow")) .tooltip(Text.translatable("explosiveenhancement.extras.alwaysshow.tooltip")) @@ -307,6 +327,8 @@ public static Screen makeScreen(Screen parent) { .controller(booleanOption -> new BooleanController(booleanOption, true)) .build(); extrasGroup.option(modEnabled); + extrasGroup.option(emissiveExplosion); + extrasGroup.option(emissiveWaterExplosion); extrasGroup.option(alwaysShow); extrasGroup.option(debugLogs); extrasCategoryBuilder.group(extrasGroup.build()); diff --git a/src/main/java/net/superkat/explosiveenhancement/particles/BlastWaveParticle.java b/src/main/java/net/superkat/explosiveenhancement/particles/BlastWaveParticle.java index 44cb608..7f3a0c8 100644 --- a/src/main/java/net/superkat/explosiveenhancement/particles/BlastWaveParticle.java +++ b/src/main/java/net/superkat/explosiveenhancement/particles/BlastWaveParticle.java @@ -12,6 +12,8 @@ import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3f; +import static net.superkat.explosiveenhancement.ExplosiveEnhancementClient.config; + @Environment(EnvType.CLIENT) public class BlastWaveParticle extends SpriteBillboardParticle { private final SpriteProvider sprites; @@ -76,6 +78,12 @@ public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } + //Makes the particle emissive + @Override + protected int getBrightness(float tint) { + return config.emissiveExplosion ? 15728880 : super.getBrightness(tint); + } + @Override public void tick() { super.tick(); diff --git a/src/main/java/net/superkat/explosiveenhancement/particles/FireballParticle.java b/src/main/java/net/superkat/explosiveenhancement/particles/FireballParticle.java index 4f5f18f..9523b0a 100644 --- a/src/main/java/net/superkat/explosiveenhancement/particles/FireballParticle.java +++ b/src/main/java/net/superkat/explosiveenhancement/particles/FireballParticle.java @@ -44,6 +44,12 @@ public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } + //Makes the particle emissive + @Override + protected int getBrightness(float tint) { + return config.emissiveExplosion ? 15728880 : super.getBrightness(tint); + } + @Environment(EnvType.CLIENT) public static class Factory implements ParticleFactory { private final SpriteProvider spriteProvider; diff --git a/src/main/java/net/superkat/explosiveenhancement/particles/ShockwaveParticle.java b/src/main/java/net/superkat/explosiveenhancement/particles/ShockwaveParticle.java index 94cc24c..0d5cc6d 100644 --- a/src/main/java/net/superkat/explosiveenhancement/particles/ShockwaveParticle.java +++ b/src/main/java/net/superkat/explosiveenhancement/particles/ShockwaveParticle.java @@ -45,6 +45,12 @@ public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } + //Makes the particle emissive + @Override + protected int getBrightness(float tint) { + return config.emissiveWaterExplosion ? 15728880 : super.getBrightness(tint); + } + @Environment(EnvType.CLIENT) public static class Factory implements ParticleFactory { private final SpriteProvider spriteProvider; diff --git a/src/main/java/net/superkat/explosiveenhancement/particles/SmokeParticle.java b/src/main/java/net/superkat/explosiveenhancement/particles/SmokeParticle.java index 450223c..6888394 100644 --- a/src/main/java/net/superkat/explosiveenhancement/particles/SmokeParticle.java +++ b/src/main/java/net/superkat/explosiveenhancement/particles/SmokeParticle.java @@ -5,13 +5,13 @@ import net.minecraft.client.particle.*; import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.DefaultParticleType; +import net.minecraft.util.math.MathHelper; + +import static net.superkat.explosiveenhancement.ExplosiveEnhancementClient.config; @Environment(EnvType.CLIENT) public class SmokeParticle extends SpriteBillboardParticle { private final SpriteProvider spriteProvider; -// private final double startX; -// private final double startY; -// private final double startZ; SmokeParticle(ClientWorld world, double x, double y, double z, double velX, double velY, double velZ, SpriteProvider spriteProvider) { super(world, x, y, z); @@ -39,43 +39,17 @@ public class SmokeParticle extends SpriteBillboardParticle { } this.velocityY = velY / 1.85; this.gravityStrength = 3.0E-6F; -// this.scale = 1F; -// this.gravityStrength = 0.008F; -// this.velocityX = velX; -// this.velocityZ = velZ; -// this.setBoundingBoxSpacing(0.02F, 0.02F); -// this.velocityX = this.random.nextFloat() + 0.07; -// this.velocityY = 0; -// this.velocityZ = this.random.nextFloat() + 0.07; -// this.startX = x; -// this.startY = y; -// this.startZ = z; this.collidesWithWorld = true; this.setSpriteForAge(spriteProvider); } public void tick() { -// int direction = this.random.nextBetween(1, 4); this.prevPosX = this.x; this.prevPosY = this.y; this.prevPosZ = this.z; if (this.age++ >= this.maxAge) { this.markDead(); } else { -// if (this.age == 1) { -// switch (direction) { -// case 2 -> { -// this.velocityX = this.velocityX * -1; -// } -// case 3 -> { -// this.velocityZ = this.velocityZ * -1; -// } -// case 4 -> { -// this.velocityX = this.velocityX * -1; -// this.velocityZ = this.velocityZ * -1; -// } -// } -// } this.setSpriteForAge(this.spriteProvider); if (this.age == 12) { this.velocityX = 0; @@ -90,6 +64,18 @@ public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } + //Makes the particle emissive + @Override + protected int getBrightness(float tint) { + if(config.emissiveExplosion && this.age <= this.maxAge * 0.12) { + return 15728880; + } else if (config.emissiveExplosion && this.age <= this.maxAge * 0.17) { + return MathHelper.clamp(super.getBrightness(tint) + this.age + 30, super.getBrightness(tint), 15728880); + } else { + return super.getBrightness(tint); + } + } + @Environment(EnvType.CLIENT) public static class Factory implements ParticleFactory { private final SpriteProvider spriteProvider; diff --git a/src/main/java/net/superkat/explosiveenhancement/particles/SparkParticle.java b/src/main/java/net/superkat/explosiveenhancement/particles/SparkParticle.java index 71ec645..9bc8398 100644 --- a/src/main/java/net/superkat/explosiveenhancement/particles/SparkParticle.java +++ b/src/main/java/net/superkat/explosiveenhancement/particles/SparkParticle.java @@ -44,6 +44,12 @@ public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } + //Makes the particle emissive + @Override + protected int getBrightness(float tint) { + return config.emissiveExplosion ? 15728880 : super.getBrightness(tint); + } + @Environment(EnvType.CLIENT) public static class Factory implements ParticleFactory { private final SpriteProvider spriteProvider; diff --git a/src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterBlastWaveParticle.java b/src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterBlastWaveParticle.java new file mode 100644 index 0000000..881698e --- /dev/null +++ b/src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterBlastWaveParticle.java @@ -0,0 +1,36 @@ +package net.superkat.explosiveenhancement.particles; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; +import net.minecraft.client.particle.Particle; +import net.minecraft.client.particle.ParticleFactory; +import net.minecraft.client.particle.SpriteProvider; +import net.minecraft.client.render.WorldRenderer; +import net.minecraft.client.world.ClientWorld; +import net.minecraft.particle.DefaultParticleType; +import net.minecraft.util.math.BlockPos; + +import static net.superkat.explosiveenhancement.ExplosiveEnhancementClient.config; + +public class UnderwaterBlastWaveParticle extends BlastWaveParticle{ + UnderwaterBlastWaveParticle(ClientWorld world, double x, double y, double z, double velX, double velY, double velZ, SpriteProvider sprites) { + super(world, x, y, z, velX, velY, velZ, sprites); + } + + //Makes the particle emissive + //Doesn't use super.getBrightness because that would cause the particle to appear emissive if + //emissive underwater explosion is turned off and emissive explosion is turned on + @Override + protected int getBrightness(float tint) { + BlockPos blockPos = new BlockPos(this.x, this.y, this.z); + return config.emissiveWaterExplosion ? 15728880 : this.world.isChunkLoaded(blockPos) ? WorldRenderer.getLightmapCoordinates(this.world, blockPos) : 0; +// return config.emissiveWaterExplosion ? 15728880 : super.getBrightness(tint); + } + + @Environment(EnvType.CLIENT) + public record Factory(SpriteProvider sprites) implements ParticleFactory { + public Particle createParticle(DefaultParticleType type, ClientWorld world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) { + return new UnderwaterBlastWaveParticle(world, x, y, z, xSpeed, ySpeed, zSpeed, sprites); + } + } +} diff --git a/src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterSparkParticle.java b/src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterSparkParticle.java index bdc8076..a3b7d76 100644 --- a/src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterSparkParticle.java +++ b/src/main/java/net/superkat/explosiveenhancement/particles/UnderwaterSparkParticle.java @@ -44,6 +44,12 @@ public ParticleTextureSheet getType() { return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; } + //Makes the particle emissive + @Override + protected int getBrightness(float tint) { + return config.emissiveWaterExplosion ? 15728880 : super.getBrightness(tint); + } + @Environment(EnvType.CLIENT) public static class Factory implements ParticleFactory { private final SpriteProvider spriteProvider; diff --git a/src/main/resources/assets/explosiveenhancement/lang/en_us.json b/src/main/resources/assets/explosiveenhancement/lang/en_us.json index 1d87c2d..99077fc 100644 --- a/src/main/resources/assets/explosiveenhancement/lang/en_us.json +++ b/src/main/resources/assets/explosiveenhancement/lang/en_us.json @@ -63,6 +63,10 @@ "explosiveenhancement.extras.group.tooltip": "Extra options", "explosiveenhancement.extras.enabled": "Mod Enabled", "explosiveenhancement.extras.enabled.tooltip": "Should the mod be enabled?", + "explosiveenhancement.extras.emissive": "Emissive Explosions", + "explosiveenhancement.extras.emissive.tooltip": "Should the normal explosions be emissive?", + "explosiveenhancement.extras.emissivewater": "Emissive Underwater Explosions", + "explosiveenhancement.extras.emissivewater.tooltip": "Should the underwater explosions be emissive?", "explosiveenhancement.extras.alwaysshow": "Always Show Particles", "explosiveenhancement.extras.alwaysshow.tooltip": "If enabled, the explosion particles will attempt to render from further away(roughly twice as far) AND on lower particle settings. Use wisely!", "explosiveenhancement.extras.logs": "Debug Logs",