Replaced particle fields with config options.
This commit is contained in:
@ -58,8 +58,15 @@ public final class Config {
|
|||||||
public static ForgeConfigSpec.DoubleValue bushFireflyAmbientSoundVolume;
|
public static ForgeConfigSpec.DoubleValue bushFireflyAmbientSoundVolume;
|
||||||
public static ForgeConfigSpec.DoubleValue bushFireflyAmbientSoundPitch;
|
public static ForgeConfigSpec.DoubleValue bushFireflyAmbientSoundPitch;
|
||||||
|
|
||||||
|
public static ForgeConfigSpec.DoubleValue particleFadeOutLightTime;
|
||||||
|
public static ForgeConfigSpec.DoubleValue particleFadeInLightTime;
|
||||||
|
public static ForgeConfigSpec.DoubleValue particleFadeOutAlphaTime;
|
||||||
|
public static ForgeConfigSpec.DoubleValue particleFadeInAlphaTime;
|
||||||
|
public static ForgeConfigSpec.IntValue particleMinLifetime;
|
||||||
|
public static ForgeConfigSpec.IntValue particleMaxLifetime;
|
||||||
|
|
||||||
Client(ForgeConfigSpec.Builder builder) {
|
Client(ForgeConfigSpec.Builder builder) {
|
||||||
builder.comment("Official settings for the firefly bush.").push("bush");
|
builder.comment("Settings for the firefly bush.").push("bush");
|
||||||
bushFireflyChancePerTick = builder
|
bushFireflyChancePerTick = builder
|
||||||
.defineInRange("bushFireflyChancePerTick", 0.7, 0, 1);
|
.defineInRange("bushFireflyChancePerTick", 0.7, 0, 1);
|
||||||
bushFireflyHorizontalRange = builder
|
bushFireflyHorizontalRange = builder
|
||||||
@ -75,6 +82,21 @@ public final class Config {
|
|||||||
bushFireflyAmbientSoundPitch = builder
|
bushFireflyAmbientSoundPitch = builder
|
||||||
.defineInRange("bushFireflyAmbientSoundPitch", 1.0, 0, Double.MAX_VALUE);
|
.defineInRange("bushFireflyAmbientSoundPitch", 1.0, 0, Double.MAX_VALUE);
|
||||||
builder.pop();
|
builder.pop();
|
||||||
|
|
||||||
|
builder.comment("Settings for the firefly particle.").push("particle");
|
||||||
|
particleFadeOutLightTime = builder
|
||||||
|
.defineInRange("particleFadeOutLightTime", 0.3, 0, 1.0);
|
||||||
|
particleFadeInLightTime = builder
|
||||||
|
.defineInRange("particleFadeInLightTime", 0.1, 0, 1.0);
|
||||||
|
particleFadeOutAlphaTime = builder
|
||||||
|
.defineInRange("particleFadeOutAlphaTime", 0.5, 0, 1.0);
|
||||||
|
particleFadeInAlphaTime = builder
|
||||||
|
.defineInRange("particleFadeInAlphaTime", 0.3, 0, 1.0);
|
||||||
|
particleMinLifetime = builder
|
||||||
|
.defineInRange("particleMinLifetime", 36, 0, Integer.MAX_VALUE);
|
||||||
|
particleMaxLifetime = builder
|
||||||
|
.defineInRange("particleMaxLifetime", 180, 0, Integer.MAX_VALUE);
|
||||||
|
builder.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void onConfigReload() {}
|
private static void onConfigReload() {}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.micle.firefly_bush_backport.particle;
|
package dev.micle.firefly_bush_backport.particle;
|
||||||
|
|
||||||
|
import dev.micle.firefly_bush_backport.config.Config;
|
||||||
import net.minecraft.client.multiplayer.ClientLevel;
|
import net.minecraft.client.multiplayer.ClientLevel;
|
||||||
import net.minecraft.client.particle.*;
|
import net.minecraft.client.particle.*;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@ -13,13 +14,6 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class FireflyParticle extends TextureSheetParticle {
|
public class FireflyParticle extends TextureSheetParticle {
|
||||||
private static final float PARTICLE_FADE_OUT_LIGHT_TIME = 0.3F;
|
|
||||||
private static final float PARTICLE_FADE_IN_LIGHT_TIME = 0.1F;
|
|
||||||
private static final float PARTICLE_FADE_OUT_ALPHA_TIME = 0.5F;
|
|
||||||
private static final float PARTICLE_FADE_IN_ALPHA_TIME = 0.3F;
|
|
||||||
private static final int PARTICLE_MIN_LIFETIME = 36;
|
|
||||||
private static final int PARTICLE_MAX_LIFETIME = 180;
|
|
||||||
|
|
||||||
protected FireflyParticle(ClientLevel clientLevel, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
protected FireflyParticle(ClientLevel clientLevel, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
|
||||||
super(clientLevel, x, y, z, xSpeed, ySpeed, zSpeed);
|
super(clientLevel, x, y, z, xSpeed, ySpeed, zSpeed);
|
||||||
this.speedUpWhenYMotionIsBlocked = true;
|
this.speedUpWhenYMotionIsBlocked = true;
|
||||||
@ -37,7 +31,11 @@ public class FireflyParticle extends TextureSheetParticle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLightColor(float partialTick) {
|
public int getLightColor(float partialTick) {
|
||||||
return (int) (255.0F * getFadeAmount(this.getLifetimeProgress(this.age + partialTick), PARTICLE_FADE_IN_LIGHT_TIME, PARTICLE_FADE_OUT_LIGHT_TIME));
|
return (int) (255.0F * getFadeAmount(
|
||||||
|
this.getLifetimeProgress(this.age + partialTick),
|
||||||
|
Config.Client.particleFadeInLightTime.get().floatValue(),
|
||||||
|
Config.Client.particleFadeOutLightTime.get().floatValue())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float getFadeAmount(float lifetimeProgress, float fadeIn, float fadeOut) {
|
private static float getFadeAmount(float lifetimeProgress, float fadeIn, float fadeOut) {
|
||||||
@ -58,7 +56,10 @@ public class FireflyParticle extends TextureSheetParticle {
|
|||||||
if (!this.level.getBlockState(BlockPos.containing(this.x, this.y, this.z)).isAir()) {
|
if (!this.level.getBlockState(BlockPos.containing(this.x, this.y, this.z)).isAir()) {
|
||||||
this.remove();
|
this.remove();
|
||||||
} else {
|
} else {
|
||||||
this.setAlpha(getFadeAmount(this.getLifetimeProgress(this.age), PARTICLE_FADE_IN_ALPHA_TIME, PARTICLE_FADE_OUT_ALPHA_TIME));
|
this.setAlpha(getFadeAmount(this.getLifetimeProgress(this.age),
|
||||||
|
Config.Client.particleFadeInAlphaTime.get().floatValue(),
|
||||||
|
Config.Client.particleFadeOutAlphaTime.get().floatValue())
|
||||||
|
);
|
||||||
if (Math.random() > 0.95 || this.age == 1) {
|
if (Math.random() > 0.95 || this.age == 1) {
|
||||||
this.setParticleSpeed(-0.05F + 0.1F * Math.random(), -0.05F + 0.1F * Math.random(), -0.05F + 0.1F * Math.random());
|
this.setParticleSpeed(-0.05F + 0.1F * Math.random(), -0.05F + 0.1F * Math.random(), -0.05F + 0.1F * Math.random());
|
||||||
}
|
}
|
||||||
@ -93,7 +94,9 @@ public class FireflyParticle extends TextureSheetParticle {
|
|||||||
clientLevel.random.nextBoolean() ? ySpeed : -ySpeed,
|
clientLevel.random.nextBoolean() ? ySpeed : -ySpeed,
|
||||||
0.5 - clientLevel.random.nextDouble()
|
0.5 - clientLevel.random.nextDouble()
|
||||||
);
|
);
|
||||||
fireflyParticle.setLifetime(clientLevel.random.nextIntBetweenInclusive(PARTICLE_MIN_LIFETIME, PARTICLE_MAX_LIFETIME));
|
fireflyParticle.setLifetime(clientLevel.random.nextIntBetweenInclusive(
|
||||||
|
Config.Client.particleMinLifetime.get(), Config.Client.particleMaxLifetime.get()
|
||||||
|
));
|
||||||
fireflyParticle.scale(1.5F);
|
fireflyParticle.scale(1.5F);
|
||||||
fireflyParticle.pickSprite(this.sprite);
|
fireflyParticle.pickSprite(this.sprite);
|
||||||
fireflyParticle.setAlpha(0.0F);
|
fireflyParticle.setAlpha(0.0F);
|
||||||
|
Reference in New Issue
Block a user