Added extra config options for always playing ambient sound and always spawning particles.
This commit is contained in:
@ -27,16 +27,19 @@ public class FireflyBushBlock extends BushBlock implements BonemealableBlock {
|
|||||||
@Override
|
@Override
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public void animateTick(BlockState blockState, Level level, BlockPos blockPos, RandomSource randomSource) {
|
public void animateTick(BlockState blockState, Level level, BlockPos blockPos, RandomSource randomSource) {
|
||||||
if (randomSource.nextInt(Config.Client.bushFireflyAmbientSoundChanceOneIn.get()) == 0
|
if (randomSource.nextInt(Config.Client.bushFireflyAmbientSoundChanceOneIn.get()) == 0 && (
|
||||||
&& isMoonVisible(level)
|
Config.Client.bushExtraAlwaysPlayAmbientSound.get() ||
|
||||||
&& level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockPos.getX(), blockPos.getZ()) <= blockPos.getY()) {
|
(isMoonVisible(level) && level.getHeight(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, blockPos.getX(), blockPos.getZ()) <= blockPos.getY())
|
||||||
|
)) {
|
||||||
level.playLocalSound(
|
level.playLocalSound(
|
||||||
blockPos, ModSounds.FIREFLY_BUSH_IDLE.get(), SoundSource.AMBIENT, 1.0F, 1.0F, false
|
blockPos, ModSounds.FIREFLY_BUSH_IDLE.get(), SoundSource.AMBIENT, 1.0F, 1.0F, false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isMoonVisible(level) || level.getMaxLocalRawBrightness(blockPos) <= Config.Client.bushFireflySpawnMaxBrightnessLevel.get()) &&
|
if (randomSource.nextDouble() <= Config.Client.bushFireflyChancePerTick.get() && (
|
||||||
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 d0 = blockPos.getX() + randomSource.nextDouble() * Config.Client.bushFireflyHorizontalRange.get() - Config.Client.bushFireflyVerticalRange.get();
|
||||||
double d1 = blockPos.getY() + randomSource.nextDouble() * 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();
|
double d2 = blockPos.getZ() + randomSource.nextDouble() * Config.Client.bushFireflyHorizontalRange.get() - Config.Client.bushFireflyVerticalRange.get();
|
||||||
|
@ -60,6 +60,9 @@ public final class Config {
|
|||||||
public static ForgeConfigSpec.IntValue bushFireflySpawnMaxBrightnessLevel;
|
public static ForgeConfigSpec.IntValue bushFireflySpawnMaxBrightnessLevel;
|
||||||
public static ForgeConfigSpec.IntValue bushFireflyAmbientSoundChanceOneIn;
|
public static ForgeConfigSpec.IntValue bushFireflyAmbientSoundChanceOneIn;
|
||||||
|
|
||||||
|
public static ForgeConfigSpec.BooleanValue bushExtraAlwaysPlayAmbientSound;
|
||||||
|
public static ForgeConfigSpec.BooleanValue bushExtraAlwaysSpawnParticles;
|
||||||
|
|
||||||
public static ForgeConfigSpec.DoubleValue particleFadeOutLightTime;
|
public static ForgeConfigSpec.DoubleValue particleFadeOutLightTime;
|
||||||
public static ForgeConfigSpec.DoubleValue particleFadeInLightTime;
|
public static ForgeConfigSpec.DoubleValue particleFadeInLightTime;
|
||||||
public static ForgeConfigSpec.DoubleValue particleFadeOutAlphaTime;
|
public static ForgeConfigSpec.DoubleValue particleFadeOutAlphaTime;
|
||||||
@ -85,6 +88,13 @@ public final class Config {
|
|||||||
.defineInRange("bushFireflySpawnMaxBrightnessLevel", 13, 0, Level.MAX_BRIGHTNESS);
|
.defineInRange("bushFireflySpawnMaxBrightnessLevel", 13, 0, Level.MAX_BRIGHTNESS);
|
||||||
bushFireflyAmbientSoundChanceOneIn = builder
|
bushFireflyAmbientSoundChanceOneIn = builder
|
||||||
.defineInRange("bushFireflyAmbientSoundChanceOneIn", 30, 0, Integer.MAX_VALUE);
|
.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.pop();
|
||||||
|
|
||||||
builder.comment("Settings for the firefly particle.").push("particle");
|
builder.comment("Settings for the firefly particle.").push("particle");
|
||||||
|
Reference in New Issue
Block a user