Skip to content

Commit

Permalink
Add option to disable rain & drip puddle particle
Browse files Browse the repository at this point in the history
  • Loading branch information
Hantonik committed Nov 11, 2024
1 parent 33db5aa commit ceb8d00
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 26 deletions.
18 changes: 14 additions & 4 deletions Common/src/main/java/hantonik/fbp/config/FBPConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ public CampfireSmoke copy() {
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public static class Rain implements IFBPConfig<Rain> {
private static final boolean DEFAULT_ENABLED = true;
private static final boolean DEFAULT_PUDDLE = true;

private static final boolean DEFAULT_RANDOM_SIZE = true;
private static final boolean DEFAULT_RANDOM_FADING_SPEED = true;
Expand All @@ -854,14 +855,15 @@ public static class Rain implements IFBPConfig<Rain> {
private static final float DEFAULT_GRAVITY_MULTIPLIER = 1.0F;

public static final Rain DEFAULT_CONFIG = new Rain(
DEFAULT_ENABLED,
DEFAULT_ENABLED, DEFAULT_PUDDLE,
DEFAULT_RANDOM_SIZE, DEFAULT_RANDOM_FADING_SPEED,
DEFAULT_RENDER_DISTANCE, DEFAULT_SIMULATION_DISTANCE,
DEFAULT_TRANSPARENCY, DEFAULT_PARTICLE_DENSITY,
DEFAULT_SIZE_MULTIPLIER, DEFAULT_GRAVITY_MULTIPLIER
);

private boolean enabled;
private boolean puddle;

private boolean randomSize;
private boolean randomFadingSpeed;
Expand All @@ -878,6 +880,7 @@ public static class Rain implements IFBPConfig<Rain> {
@Override
public void setConfig(Rain config) {
this.enabled = config.enabled;
this.puddle = config.puddle;

this.randomSize = config.randomSize;
this.randomFadingSpeed = config.randomFadingSpeed;
Expand All @@ -895,6 +898,7 @@ public void setConfig(Rain config) {
@Override
public void load(JsonObject json) {
this.enabled = GsonHelper.getAsBoolean(json, "enabled", DEFAULT_ENABLED);
this.puddle = GsonHelper.getAsBoolean(json, "puddle", DEFAULT_PUDDLE);

this.randomSize = GsonHelper.getAsBoolean(json, "randomSize", DEFAULT_RANDOM_SIZE);
this.randomFadingSpeed = GsonHelper.getAsBoolean(json, "randomFadingSpeed", DEFAULT_RANDOM_FADING_SPEED);
Expand All @@ -914,6 +918,7 @@ public JsonObject save() {
var json = new JsonObject();

json.addProperty("enabled", this.enabled);
json.addProperty("puddle", this.puddle);

json.addProperty("randomSize", this.randomSize);
json.addProperty("randomFadingSpeed", this.randomFadingSpeed);
Expand All @@ -938,7 +943,7 @@ public void reset() {
@Override
public Rain copy() {
return new Rain(
this.enabled,
this.enabled, this.puddle,
this.randomSize, this.randomFadingSpeed,
this.renderDistance, this.simulationDistance,
this.transparency, this.particleDensity,
Expand Down Expand Up @@ -1125,6 +1130,7 @@ public Snow copy() {
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public static class Drip implements IFBPConfig<Drip> {
private static final boolean DEFAULT_ENABLED = true;
private static final boolean DEFAULT_PUDDLE = true;

private static final boolean DEFAULT_SPAWN_WHILE_FROZEN = true;

Expand All @@ -1138,14 +1144,15 @@ public static class Drip implements IFBPConfig<Drip> {
private static final float DEFAULT_GRAVITY_MULTIPLIER = 1.0F;

public static final Drip DEFAULT_CONFIG = new Drip(
DEFAULT_ENABLED,
DEFAULT_ENABLED, DEFAULT_PUDDLE,
DEFAULT_SPAWN_WHILE_FROZEN,
DEFAULT_RANDOM_SIZE, DEFAULT_RANDOM_FADING_SPEED,
DEFAULT_MIN_LIFETIME, DEFAULT_MAX_LIFETIME,
DEFAULT_SIZE_MULTIPLIER, DEFAULT_GRAVITY_MULTIPLIER
);

private boolean enabled;
private boolean puddle;

private boolean spawnWhileFrozen;

Expand All @@ -1161,6 +1168,7 @@ public static class Drip implements IFBPConfig<Drip> {
@Override
public void setConfig(Drip config) {
this.enabled = config.enabled;
this.puddle = config.puddle;

this.spawnWhileFrozen = config.spawnWhileFrozen;

Expand All @@ -1177,6 +1185,7 @@ public void setConfig(Drip config) {
@Override
public void load(JsonObject json) {
this.enabled = GsonHelper.getAsBoolean(json, "enabled", DEFAULT_ENABLED);
this.puddle = GsonHelper.getAsBoolean(json, "puddle", DEFAULT_PUDDLE);

this.spawnWhileFrozen = GsonHelper.getAsBoolean(json, "spawnWhileFrozen", DEFAULT_SPAWN_WHILE_FROZEN);

Expand All @@ -1195,6 +1204,7 @@ public JsonObject save() {
var json = new JsonObject();

json.addProperty("enabled", this.enabled);
json.addProperty("puddle", this.puddle);

json.addProperty("spawnWhileFrozen", this.spawnWhileFrozen);

Expand All @@ -1218,7 +1228,7 @@ public void reset() {
@Override
public Drip copy() {
return new Drip(
this.enabled,
this.enabled, this.puddle,
this.spawnWhileFrozen,
this.randomSize, this.randomFadingSpeed,
this.minLifetime, this.maxLifetime,
Expand Down
18 changes: 15 additions & 3 deletions Common/src/main/java/hantonik/fbp/particle/FBPDripParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,14 @@ public void tick() {
this.xd *= 0.6D;
this.yd *= 1.00025D;
this.zd *= 0.6D;
}

if (this.onGround && this.age < this.lifetime) {
this.xd = 0.0D;
this.zd = 0.0D;

if (this.onGround && this.age < this.lifetime) {
this.xd = 0.0D;
if (FancyBlockParticles.CONFIG.drip.isPuddle()) {
this.yd = -0.25D;
this.zd = 0.0D;

if (this.height > 0.075F)
this.height *= 0.725F;
Expand All @@ -181,6 +184,15 @@ public void tick() {
if (this.alpha < 0.01F)
this.remove();
}
} else {
this.quadSize *= 0.85F * this.multiplier;
this.height = this.quadSize;

if (this.alpha >= 0.01F)
this.alpha *= 0.75F * this.multiplier;

if (this.alpha < 0.01F)
this.remove();
}
}

Expand Down
36 changes: 24 additions & 12 deletions Common/src/main/java/hantonik/fbp/particle/FBPRainParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,38 @@ public void tick() {

if (this.onGround) {
this.xd = 0.0D;
this.yd = -0.25D;
this.zd = 0.0D;

if (this.height > 0.075F)
this.height *= 0.725F;
if (FancyBlockParticles.CONFIG.rain.isPuddle()) {
this.yd = -0.25D;

if (this.quadSize < this.targetSize) {
this.quadSize += this.targetSize / 10.0F;
if (this.height > 0.075F)
this.height *= 0.725F;

if (this.quadSize > this.targetSize)
this.quadSize = this.targetSize;
}
if (this.quadSize < this.targetSize) {
this.quadSize += this.targetSize / 10.0F;

if (this.quadSize > this.targetSize)
this.quadSize = this.targetSize;
}

if (this.quadSize >= this.targetSize / 2.0F) {
this.alpha *= 0.75F * this.multiplier;

if (this.quadSize >= this.targetSize / 2.0F) {
this.alpha *= 0.75F * this.multiplier;
if (this.alpha < 0.01F)
this.remove();
} else
this.alpha = FancyBlockParticles.CONFIG.rain.getTransparency();
} else {
this.quadSize *= 0.85F * this.multiplier;
this.height = this.quadSize;

if (this.alpha >= 0.01F)
this.alpha *= 0.75F * this.multiplier;

if (this.alpha < 0.01F)
this.remove();
} else
this.alpha = FancyBlockParticles.CONFIG.rain.getTransparency();
}
} else
this.alpha = FancyBlockParticles.CONFIG.rain.getTransparency();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ protected void initOptions() {
}, () -> !FancyBlockParticles.CONFIG.global.isLocked(), Tooltip.create(Component.translatable("tooltip.fbp.common.max_lifetime").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.literal(String.valueOf(FBPConfig.DEFAULT_CONFIG.drip.getMaxLifetime())).append(Component.translatable("button.fbp.common.ticks")).withStyle(ChatFormatting.YELLOW)))));


this.list.addBig(
new FBPToggleButton(310, 20, Component.translatable("button.fbp.drip.fancy_dripping_particles"), this.config.drip::isEnabled, button -> this.config.drip.setEnabled(!this.config.drip.isEnabled()), Tooltip.create(Component.translatable("tooltip.fbp.drip.fancy_dripping_particles").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.drip.isEnabled()))))
);

this.list.addSmall(
new FBPToggleButton(150, 20, Component.translatable("button.fbp.drip.fancy_dripping_particles"), this.config.drip::isEnabled, button -> this.config.drip.setEnabled(!this.config.drip.isEnabled()), Tooltip.create(Component.translatable("tooltip.fbp.drip.fancy_dripping_particles").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.drip.isEnabled())))),
new FBPToggleButton(150, 20, Component.translatable("button.fbp.common.puddle"), this.config.drip::isPuddle, button -> this.config.drip.setPuddle(!this.config.drip.isPuddle()), Tooltip.create(Component.translatable("tooltip.fbp.common.puddle").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.drip.isPuddle())))),

new FBPToggleButton(150, 20, Component.translatable("button.fbp.common.spawn_while_frozen"), this.config.drip::isSpawnWhileFrozen, button -> this.config.drip.setSpawnWhileFrozen(!this.config.drip.isSpawnWhileFrozen()), Tooltip.create(Component.translatable("tooltip.fbp.common.spawn_while_frozen").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.drip.isSpawnWhileFrozen())))),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ public FBPRainScreen(Screen lastScreen, FBPConfig config) {
protected void initOptions() {
var formatter = new DecimalFormat("0.00");

this.list.addBig(
new FBPToggleButton(310, 20, Component.translatable("button.fbp.rain.fancy_rain_particles"), this.config.rain::isEnabled, button -> this.config.rain.setEnabled(!this.config.rain.isEnabled()), Tooltip.create(Component.translatable("tooltip.fbp.rain.fancy_rain_particles").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.rain.isEnabled()))))
);

this.list.addSmall(
new FBPToggleButton(150, 20, Component.translatable("button.fbp.rain.fancy_rain_particles"), this.config.rain::isEnabled, button -> this.config.rain.setEnabled(!this.config.rain.isEnabled()), Tooltip.create(Component.translatable("tooltip.fbp.rain.fancy_rain_particles").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.rain.isEnabled())))),
new FBPToggleButton(150, 20, Component.translatable("button.fbp.common.puddle"), this.config.rain::isPuddle, button -> this.config.rain.setPuddle(!this.config.rain.isPuddle()), Tooltip.create(Component.translatable("tooltip.fbp.common.puddle").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.rain.isPuddle())))),

new FBPToggleButton(150, 20, Component.translatable("button.fbp.common.random_size"), this.config.rain::isRandomSize, button -> this.config.rain.setRandomSize(!this.config.rain.isRandomSize()), Tooltip.create(Component.translatable("tooltip.fbp.common.random_size").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.rain.isRandomSize())))),
new FBPToggleButton(150, 20, Component.translatable("button.fbp.common.random_fading_speed"), this.config.rain::isRandomFadingSpeed, button -> this.config.rain.setRandomFadingSpeed(!this.config.rain.isRandomFadingSpeed()), Tooltip.create(Component.translatable("tooltip.fbp.common.random_fading_speed").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp.common." + FBPConfig.DEFAULT_CONFIG.rain.isRandomFadingSpeed())))),

Expand Down
4 changes: 4 additions & 0 deletions Common/src/main/resources/assets/fbp/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button.fbp.common.min_lifetime": "Minimale Lebensdauer",
"button.fbp.common.max_lifetime": "Maximale Lebensdauer",

"button.fbp.common.puddle": "Pfütze",

"button.fbp.common.transparency": "Partikel-Transparenz",

"button.fbp.common.size_multiplier": "Größenmultiplikator",
Expand Down Expand Up @@ -141,6 +143,8 @@
"tooltip.fbp.common.min_lifetime": "Minimale Partikel-Lebensdauer.",
"tooltip.fbp.common.max_lifetime": "Maximale Partikel-Lebensdauer.",

"tooltip.fbp.common.puddle": "Sollen Pfützen entstehen, wenn ein Partikel auf den Boden trifft?",

"tooltip.fbp.common.transparency": "Transparenz der Partikel.",

"tooltip.fbp.common.size_multiplier": "Partikelgrößen-Multiplikator.",
Expand Down
4 changes: 4 additions & 0 deletions Common/src/main/resources/assets/fbp/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button.fbp.common.min_lifetime": "Minimum lifetime",
"button.fbp.common.max_lifetime": "Maximum lifetime",

"button.fbp.common.puddle": "Puddle",

"button.fbp.common.transparency": "Transparency",

"button.fbp.common.size_multiplier": "Size multiplier",
Expand Down Expand Up @@ -141,6 +143,8 @@
"tooltip.fbp.common.min_lifetime": "Minimum particle lifetime.",
"tooltip.fbp.common.max_lifetime": "Maximum particle lifetime.",

"tooltip.fbp.common.puddle": "Should a puddle appear when a particle hits the ground?",

"tooltip.fbp.common.transparency": "Transparency of particles.",

"tooltip.fbp.common.size_multiplier": "Particle size multiplier.",
Expand Down
4 changes: 4 additions & 0 deletions Common/src/main/resources/assets/fbp/lang/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button.fbp.common.min_lifetime": "Tiempo de vida mínimo",
"button.fbp.common.max_lifetime": "Tiempo de vida máximo",

"button.fbp.common.puddle": "Charco",

"button.fbp.common.transparency": "Transparencia",

"button.fbp.common.size_multiplier": "Multiplicador de tamaño",
Expand Down Expand Up @@ -141,6 +143,8 @@
"tooltip.fbp.common.min_lifetime": "Tiempo de vida mínimo de la partícula.",
"tooltip.fbp.common.max_lifetime": "Tiempo de vida máximo de la partícula.",

"tooltip.fbp.common.puddle": "¿Deberían aparecer charcos cuando una partícula toca el suelo?",

"tooltip.fbp.common.transparency": "Transparencia de partículas.",

"tooltip.fbp.common.size_multiplier": "Multiplicador de tamaño de la partícula.",
Expand Down
4 changes: 4 additions & 0 deletions Common/src/main/resources/assets/fbp/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button.fbp.common.min_lifetime": "Durée de vie minimale",
"button.fbp.common.max_lifetime": "Durée de vie maximale",

"button.fbp.common.puddle": "Flaque",

"button.fbp.common.transparency": "Transparence",

"button.fbp.common.size_multiplier": "Multiplicateur de taille",
Expand Down Expand Up @@ -141,6 +143,8 @@
"tooltip.fbp.common.min_lifetime": "Durée de vie minimale des particules.",
"tooltip.fbp.common.max_lifetime": "Durée de vie maximale des particules.",

"tooltip.fbp.common.puddle": "Les flaques devraient-elles apparaître lorsque des particules touchent le sol?",

"tooltip.fbp.common.transparency": "Transparence des particules.",

"tooltip.fbp.common.size_multiplier": "Multiplicateur de taille des particules.",
Expand Down
4 changes: 4 additions & 0 deletions Common/src/main/resources/assets/fbp/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button.fbp.common.min_lifetime": "最小寿命",
"button.fbp.common.max_lifetime": "最大寿命",

"button.fbp.common.puddle": "水たまり",

"button.fbp.common.transparency": "透明性",

"button.fbp.common.size_multiplier": "サイズ倍率",
Expand Down Expand Up @@ -141,6 +143,8 @@
"tooltip.fbp.common.min_lifetime": "パーティクルの最小寿命。",
"tooltip.fbp.common.max_lifetime": "パーティクルの最大寿命。",

"tooltip.fbp.common.puddle": "粒子が地面に当たったとき、水たまりができるようにしますか?",

"tooltip.fbp.common.transparency": "粒子の透明度。",

"tooltip.fbp.common.size_multiplier": "パーティクルのサイズ倍率。",
Expand Down
4 changes: 4 additions & 0 deletions Common/src/main/resources/assets/fbp/lang/pl_pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button.fbp.common.min_lifetime": "Minimalny czas istnienia",
"button.fbp.common.max_lifetime": "Maksymalny czas istnienia",

"button.fbp.common.puddle": "Kałuża",

"button.fbp.common.transparency": "Przezroczystość",

"button.fbp.common.size_multiplier": "Mnożnik rozmiaru",
Expand Down Expand Up @@ -141,6 +143,8 @@
"tooltip.fbp.common.min_lifetime": "Minimalna długość istnienia cząsteczek.",
"tooltip.fbp.common.max_lifetime": "Maksymalna długość istnienia cząsteczek.",

"tooltip.fbp.common.puddle": "Czy powinna pojawić się kałuża w momencie uderzenia cząsteczki o ziemię?",

"tooltip.fbp.common.transparency": "Przezroczystość cząsteczek.",

"tooltip.fbp.common.size_multiplier": "Mnożnik rozmiaru cząsteczek.",
Expand Down
4 changes: 4 additions & 0 deletions Common/src/main/resources/assets/fbp/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"button.fbp.common.min_lifetime": "最短寿命",
"button.fbp.common.max_lifetime": "最长寿命",

"button.fbp.common.puddle": "水坑",

"button.fbp.common.transparency": "透明度",

"button.fbp.common.size_multiplier": "大小倍增器",
Expand Down Expand Up @@ -141,6 +143,8 @@
"tooltip.fbp.common.min_lifetime": "粒子最短寿命。",
"tooltip.fbp.common.max_lifetime": "粒子最长寿命。",

"tooltip.fbp.common.puddle": "粒子落到地面时是否应该出现水坑?",

"tooltip.fbp.common.transparency": "颗粒透明度。",

"tooltip.fbp.common.size_multiplier": "粒子大小倍增器。",
Expand Down
4 changes: 2 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"homepage": "https://www.curseforge.com/minecraft/mc-mods/fbp-renewed",

"promos": {
"1.19.4-latest": "19.4.1.2"
"1.19.4-latest": "19.4.2.0"
},

"1.19.4": {
"19.4.1.2": "Fix rain and snow particle density option not saving. Fix incorrect FBPSnowParticle texture",
"19.4.2.0": "Add option to disable rain & drip puddle particle. Fix rain and snow particle density option not saving. Fix incorrect FBPSnowParticle texture",
"19.4.1.1": "Fix crash when pos is null",
"19.4.1.0": "Add Oculus warning screen. Fix Done button disappearing from screen. Add snowball and slime ball particles. Optimize performance. Add FBPRainParticle transparency adjustment option. Add FBPCampfireSmokeParticle. Fix flame particles not spawning while frozen. Add FBPSnowParticle water physics. Particle physics improvements. Fix shaders incompatibility. Code cleanup & improvements. Add FBPDripParticle. Add block placing animation. Fix incorrect lighting of FBPTerrainParticle",
"19.4.0.5-beta": "Fix error while adding FBPTerrainParticle",
Expand Down

0 comments on commit ceb8d00

Please sign in to comment.