From 7afeb2c82dab9121c8593202d627e156a8ec22d2 Mon Sep 17 00:00:00 2001 From: Micle Date: Fri, 6 Jun 2025 22:25:08 +0100 Subject: [PATCH] Added extra config options for always playing ambient sound and always spawning particles. --- .../block/FireflyBushBlock.java | 13 ++++++++----- .../micle/firefly_bush_backport/config/Config.java | 10 ++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/main/java/dev/micle/firefly_bush_backport/block/FireflyBushBlock.java b/src/main/java/dev/micle/firefly_bush_backport/block/FireflyBushBlock.java index 73ab596..4ba0ded 100644 --- a/src/main/java/dev/micle/firefly_bush_backport/block/FireflyBushBlock.java +++ b/src/main/java/dev/micle/firefly_bush_backport/block/FireflyBushBlock.java @@ -27,16 +27,19 @@ public class FireflyBushBlock extends BushBlock implements BonemealableBlock { @Override @ParametersAreNonnullByDefault public void animateTick(BlockState blockState, Level level, BlockPos blockPos, RandomSource randomSource) { - if (randomSource.nextInt(Config.Client.bushFireflyAmbientSoundChanceOneIn.get()) == 0 - && isMoonVisible(level) - && level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockPos.getX(), blockPos.getZ()) <= blockPos.getY()) { + if (randomSource.nextInt(Config.Client.bushFireflyAmbientSoundChanceOneIn.get()) == 0 && ( + Config.Client.bushExtraAlwaysPlayAmbientSound.get() || + (isMoonVisible(level) && level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockPos.getX(), blockPos.getZ()) <= blockPos.getY()) + )) { level.playLocalSound( blockPos, ModSounds.FIREFLY_BUSH_IDLE.get(), SoundSource.AMBIENT, 1.0F, 1.0F, false ); } - if ((isMoonVisible(level) || level.getMaxLocalRawBrightness(blockPos) <= Config.Client.bushFireflySpawnMaxBrightnessLevel.get()) && - randomSource.nextDouble() <= Config.Client.bushFireflyChancePerTick.get()) { + if (randomSource.nextDouble() <= Config.Client.bushFireflyChancePerTick.get() && ( + Config.Client.bushExtraAlwaysSpawnParticles.get() || + (isMoonVisible(level) || level.getMaxLocalRawBrightness(blockPos) <= Config.Client.bushFireflySpawnMaxBrightnessLevel.get()) + )) { double d0 = blockPos.getX() + randomSource.nextDouble() * Config.Client.bushFireflyHorizontalRange.get() - Config.Client.bushFireflyVerticalRange.get(); double d1 = blockPos.getY() + randomSource.nextDouble() * Config.Client.bushFireflyVerticalRange.get(); double d2 = blockPos.getZ() + randomSource.nextDouble() * Config.Client.bushFireflyHorizontalRange.get() - Config.Client.bushFireflyVerticalRange.get(); diff --git a/src/main/java/dev/micle/firefly_bush_backport/config/Config.java b/src/main/java/dev/micle/firefly_bush_backport/config/Config.java index 1283276..3ec34fa 100644 --- a/src/main/java/dev/micle/firefly_bush_backport/config/Config.java +++ b/src/main/java/dev/micle/firefly_bush_backport/config/Config.java @@ -60,6 +60,9 @@ public final class Config { public static ForgeConfigSpec.IntValue bushFireflySpawnMaxBrightnessLevel; public static ForgeConfigSpec.IntValue bushFireflyAmbientSoundChanceOneIn; + public static ForgeConfigSpec.BooleanValue bushExtraAlwaysPlayAmbientSound; + public static ForgeConfigSpec.BooleanValue bushExtraAlwaysSpawnParticles; + public static ForgeConfigSpec.DoubleValue particleFadeOutLightTime; public static ForgeConfigSpec.DoubleValue particleFadeInLightTime; public static ForgeConfigSpec.DoubleValue particleFadeOutAlphaTime; @@ -85,6 +88,13 @@ public final class Config { .defineInRange("bushFireflySpawnMaxBrightnessLevel", 13, 0, Level.MAX_BRIGHTNESS); bushFireflyAmbientSoundChanceOneIn = builder .defineInRange("bushFireflyAmbientSoundChanceOneIn", 30, 0, Integer.MAX_VALUE); + + builder.comment("Extra settings for the firefly bush.").push("extra"); + bushExtraAlwaysPlayAmbientSound = builder + .define("bushExtraAlwaysPlayAmbientSound", false); + bushExtraAlwaysSpawnParticles = builder + .define("bushExtraAlwaysSpawnParticles", false); + builder.pop(); builder.pop(); builder.comment("Settings for the firefly particle.").push("particle");