Skip to content

Commit

Permalink
Add particle culling toggle option
Browse files Browse the repository at this point in the history
  • Loading branch information
Hantonik committed Feb 22, 2024
1 parent f31f3ec commit 28f857d
Show file tree
Hide file tree
Showing 19 changed files with 90 additions and 17 deletions.
10 changes: 8 additions & 2 deletions Fabric/src/main/java/hantonik/fbp/config/FBPConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public final class FBPConfig {
private static final boolean DEFAULT_FROZEN = false;
private static final boolean DEFAULT_INFINITE_DURATION = false;
private static final boolean DEFAULT_CARTOON_MODE = false;
private static final boolean DEFAULT_CULL_PARTICLES = false;

private static final boolean DEFAULT_FANCY_FLAME = true;
private static final boolean DEFAULT_FANCY_SMOKE = true;
Expand Down Expand Up @@ -73,7 +74,7 @@ public final class FBPConfig {

public static final FBPConfig DEFAULT_CONFIG = new FBPConfig(
DEFAULT_ENABLED, DEFAULT_LOCKED,
DEFAULT_FROZEN, DEFAULT_INFINITE_DURATION, DEFAULT_CARTOON_MODE,
DEFAULT_FROZEN, DEFAULT_INFINITE_DURATION, DEFAULT_CARTOON_MODE, DEFAULT_CULL_PARTICLES,
DEFAULT_FANCY_FLAME, DEFAULT_FANCY_SMOKE, DEFAULT_FANCY_RAIN, DEFAULT_FANCY_SNOW, DEFAULT_SMOOTH_ANIMATION_LIGHTING,
DEFAULT_SMART_BREAKING, DEFAULT_LOW_TRACTION, DEFAULT_SPAWN_WHILE_FROZEN, DEFAULT_SMOOTH_ANIMATION_LIGHTING,
DEFAULT_SPAWN_PLACE_PARTICLES,
Expand All @@ -91,6 +92,7 @@ public final class FBPConfig {
private boolean frozen;
private boolean infiniteDuration;
private boolean cartoonMode;
private boolean cullParticles;

private boolean fancyFlame;
private boolean fancySmoke;
Expand Down Expand Up @@ -169,6 +171,7 @@ public void setConfig(FBPConfig config) {
this.frozen = config.frozen;
this.infiniteDuration = config.infiniteDuration;
this.cartoonMode = config.cartoonMode;
this.cullParticles = config.cullParticles;

this.fancyFlame = config.fancyFlame;
this.fancySmoke = config.fancySmoke;
Expand Down Expand Up @@ -212,6 +215,7 @@ public void applyConfig(FBPConfig config) {
this.frozen = config.frozen;
this.infiniteDuration = config.infiniteDuration;
this.cartoonMode = config.cartoonMode;
this.cullParticles = config.cullParticles;

this.fancyFlame = config.fancyFlame;
this.fancySmoke = config.fancySmoke;
Expand Down Expand Up @@ -279,6 +283,7 @@ public void reload() {
this.frozen = GsonHelper.getAsBoolean(json, "frozen", DEFAULT_FROZEN);
this.infiniteDuration = GsonHelper.getAsBoolean(json, "infiniteDuration", DEFAULT_INFINITE_DURATION);
this.cartoonMode = GsonHelper.getAsBoolean(json, "cartoonMode", DEFAULT_CARTOON_MODE);
this.cullParticles = GsonHelper.getAsBoolean(json, "cullParticles", DEFAULT_CULL_PARTICLES);

this.fancyFlame = GsonHelper.getAsBoolean(json, "fancyFlame", DEFAULT_FANCY_FLAME);
this.fancySmoke = GsonHelper.getAsBoolean(json, "fancySmoke", DEFAULT_FANCY_SMOKE);
Expand Down Expand Up @@ -342,6 +347,7 @@ public void save() {
json.addProperty("frozen", this.frozen);
json.addProperty("infiniteDuration", this.infiniteDuration);
json.addProperty("cartoonMode", this.cartoonMode);
json.addProperty("cullParticles", this.cullParticles);

json.addProperty("fancyFlame", this.fancyFlame);
json.addProperty("fancySmoke", this.fancySmoke);
Expand Down Expand Up @@ -394,7 +400,7 @@ public void save() {
public FBPConfig copy() {
return new FBPConfig(
this.enabled, this.locked,
this.frozen, this.infiniteDuration, this.cartoonMode,
this.frozen, this.infiniteDuration, this.cartoonMode, this.cullParticles,
this.fancyFlame, this.fancySmoke, this.fancyRain, this.fancySnow, this.fancyPlaceAnimation,
this.smartBreaking, this.lowTraction, this.spawnWhileFrozen, this.smoothAnimationLighting,
this.spawnPlaceParticles,
Expand Down
25 changes: 20 additions & 5 deletions Fabric/src/main/java/hantonik/fbp/screen/FBPOptionsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public FBPOptionsScreen() {

this.config = FancyBlockParticles.CONFIG.copy();

this.pageCount = 3;
this.pageCount = 4;
this.page = 1;
}

Expand Down Expand Up @@ -137,21 +137,21 @@ protected void init() {
helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.cartoon_mode"), this.config::isCartoonMode, button -> this.config.setCartoonMode(!this.config.isCartoonMode())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.cartoon_mode").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isCartoonMode()))));
helper.addChild(SpacerElement.width(75));
helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.cull_particles"), this.config::isCullParticles, button -> this.config.setCullParticles(!this.config.isCullParticles())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.cull_particles").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isCullParticles()))));
helper.addChild(SpacerElement.width(75));

helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.smart_breaking"), this.config::isSmartBreaking, button -> this.config.setSmartBreaking(!this.config.isSmartBreaking())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.smart_breaking").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isSmartBreaking()))));
helper.addChild(SpacerElement.width(75));
helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.low_traction"), this.config::isLowTraction, button -> this.config.setLowTraction(!this.config.isLowTraction())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.low_traction").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isLowTraction()))));
helper.addChild(SpacerElement.width(75));
helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.spawn_while_frozen"), this.config::isSpawnWhileFrozen, button -> this.config.setSpawnWhileFrozen(!this.config.isSpawnWhileFrozen())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.spawn_while_frozen").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isSpawnWhileFrozen()))));
helper.addChild(SpacerElement.width(75));
}

case 3 -> {
helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.smooth_animation_lighting"), this.config::isSmoothAnimationLighting, button -> this.config.setSmoothAnimationLighting(!this.config.isSmoothAnimationLighting())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.smooth_animation_lighting").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isSmoothAnimationLighting()))));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.spawn_while_frozen"), this.config::isSpawnWhileFrozen, button -> this.config.setSpawnWhileFrozen(!this.config.isSpawnWhileFrozen())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.spawn_while_frozen").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isSpawnWhileFrozen()))));
helper.addChild(SpacerElement.width(75));
helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.spawn_place_particles"), this.config::isSpawnPlaceParticles, button -> this.config.setSpawnPlaceParticles(!this.config.isSpawnPlaceParticles())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.spawn_place_particles").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isSpawnPlaceParticles()))));
Expand Down Expand Up @@ -180,6 +180,21 @@ protected void init() {
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.random_fading_speed"), this.config::isRandomFadingSpeed, button -> this.config.setRandomFadingSpeed(!this.config.isRandomFadingSpeed())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.random_fading_speed").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isRandomFadingSpeed()))));
helper.addChild(SpacerElement.width(75));
}

case 4 -> {
helper.addChild(SpacerElement.width(75));
helper.addChild(new FBPToggleButton(0, 0, 275, 20, Component.translatable("button.fbp.smooth_animation_lighting"), this.config::isSmoothAnimationLighting, button -> this.config.setSmoothAnimationLighting(!this.config.isSmoothAnimationLighting())), 4).setTooltip(Tooltip.create(Component.translatable("tooltip.fbp.smooth_animation_lighting").append(CommonComponents.NEW_LINE).append(CommonComponents.NEW_LINE).append(Component.translatable("tooltip.fbp.default")).append(Component.translatable("button.fbp." + defaultConfig.isSmoothAnimationLighting()))));
helper.addChild(SpacerElement.width(75));

helper.addChild(SpacerElement.height(20), 6);
helper.addChild(SpacerElement.height(20), 6);
helper.addChild(SpacerElement.height(20), 6);
helper.addChild(SpacerElement.height(20), 6);
helper.addChild(SpacerElement.height(20), 6);
helper.addChild(SpacerElement.height(20), 6);
helper.addChild(SpacerElement.height(20), 6);
helper.addChild(SpacerElement.height(20), 6);
}
}

var previousButton = helper.addChild(Button.builder(Component.translatable("button.fbp.previous"), button -> {
Expand Down
5 changes: 4 additions & 1 deletion Fabric/src/main/java/hantonik/fbp/util/FBPConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ public void begin(BufferBuilder buffer, TextureManager manager) {
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
RenderSystem.setShader(GameRenderer::getRendertypeTranslucentShader);

RenderSystem.enableCull();
if (FancyBlockParticles.CONFIG.isCullParticles())
RenderSystem.enableCull();
else
RenderSystem.disableCull();

buffer.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
}
Expand Down
2 changes: 2 additions & 0 deletions Fabric/src/main/resources/assets/fbp/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"button.fbp.fancy_place_animation": "Elegante Platzierungsanimation",

"button.fbp.cartoon_mode": "Cartoon-Modus",
"button.fbp.cull_particles": "Partikel eliminieren",

"button.fbp.smart_breaking": "Intelligentes Abbauen",
"button.fbp.low_traction": "Geringe Traktion",
Expand Down Expand Up @@ -81,6 +82,7 @@
"tooltip.fbp.fancy_place_animation": "Aktiviere oder deaktiviere schicke Blockplatzierungsanimation.",

"tooltip.fbp.cartoon_mode": "Aktivieren oder deaktivieren Sie den Partikel-Cartoon-Modus.",
"tooltip.fbp.cull_particles": "Aktiviere oder deaktiviere das Aussortieren von Partikeln.",

"tooltip.fbp.smart_breaking": "Aktiviere oder deaktiviere intelligentes Brechen.",
"tooltip.fbp.low_traction": "Aktiviere oder deaktiviere Partikel mit geringer Traktion.",
Expand Down
2 changes: 2 additions & 0 deletions Fabric/src/main/resources/assets/fbp/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"button.fbp.fancy_place_animation": "Fancy placing animation",

"button.fbp.cartoon_mode": "Cartoon mode",
"button.fbp.cull_particles": "Cull particles",

"button.fbp.smart_breaking": "Smart breaking",
"button.fbp.low_traction": "Low traction",
Expand Down Expand Up @@ -81,6 +82,7 @@
"tooltip.fbp.fancy_place_animation": "Enable or disable fancy block placing animation.",

"tooltip.fbp.cartoon_mode": "Enable or disable particles cartoon mode.",
"tooltip.fbp.cull_particles": "Enable or disable particle culling.",

"tooltip.fbp.smart_breaking": "Enable or disable smart breaking.",
"tooltip.fbp.low_traction": "Enable or disable particle low traction.",
Expand Down
2 changes: 2 additions & 0 deletions Fabric/src/main/resources/assets/fbp/lang/es_es.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"button.fbp.fancy_place_animation": "Animación de Colocación Elegante",

"button.fbp.cartoon_mode": "Modo caricatura",
"button.fbp.cull_particles": "Eliminar partículas",

"button.fbp.smart_breaking": "Ruptura Inteligente",
"button.fbp.low_traction": "Baja Tracción",
Expand Down Expand Up @@ -81,6 +82,7 @@
"tooltip.fbp.fancy_place_animation": "Activar o desactivar animación elegante al colocar bloques.",

"tooltip.fbp.cartoon_mode": "Activar o desactivar el modo caricatura de partículas.",
"tooltip.fbp.cull_particles": "Activar o desactivar el eliminado de partículas.",

"tooltip.fbp.smart_breaking": "Activar o desactivar ruptura inteligente.",
"tooltip.fbp.low_traction": "Activar o desactivar partículas de baja tracción.",
Expand Down
2 changes: 2 additions & 0 deletions Fabric/src/main/resources/assets/fbp/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"button.fbp.fancy_place_animation": "Animation de placement élégante",

"button.fbp.cartoon_mode": "Mode dessin animé",
"button.fbp.cull_particles": "Éliminer les particules",

"button.fbp.smart_breaking": "Cassage intelligent",
"button.fbp.low_traction": "Faible traction",
Expand Down Expand Up @@ -81,6 +82,7 @@
"tooltip.fbp.fancy_place_animation": "Activer ou désactiver l'animation de placement élégante.",

"tooltip.fbp.cartoon_mode": "Activer ou désactiver le mode dessin animé des particules.",
"tooltip.fbp.cull_particles": "Activer ou désactiver l'élimination des particules.",

"tooltip.fbp.smart_breaking": "Activer ou désactiver le cassage intelligent.",
"tooltip.fbp.low_traction": "Activer ou désactiver la faible traction des particules.",
Expand Down
2 changes: 2 additions & 0 deletions Fabric/src/main/resources/assets/fbp/lang/pl_pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"button.fbp.fancy_place_animation": "Fantazyjna animacja stawiania",

"button.fbp.cartoon_mode": "Tryb kreskówkowy",
"button.fbp.cull_particles": "Eliminacja cząsteczek",

"button.fbp.smart_breaking": "Inteligentne burzenie",
"button.fbp.low_traction": "Niska trakcja",
Expand Down Expand Up @@ -81,6 +82,7 @@
"tooltip.fbp.fancy_place_animation": "Włącz lub wyłącz fantazyjną animację stawiania.",

"tooltip.fbp.cartoon_mode": "Włącz lub wyłącz tryb kreskówkowy cząsteczek.",
"tooltip.fbp.cull_particles": "Włącz lub wyłącz eliminację cząsteczek.",

"tooltip.fbp.smart_breaking": "Włącz lub wyłącz inteligentne burzenie.",
"tooltip.fbp.low_traction": "Włącz lub wyłącz niską trakcję cząsteczek.",
Expand Down
2 changes: 2 additions & 0 deletions Fabric/src/main/resources/assets/fbp/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"button.fbp.fancy_place_animation": "华丽放置动画",

"button.fbp.cartoon_mode": "卡通模式",
"button.fbp.cull_particles": "剔除粒子",

"button.fbp.smart_breaking": "智能破坏",
"button.fbp.low_traction": "低牵引力",
Expand Down Expand Up @@ -81,6 +82,7 @@
"tooltip.fbp.fancy_place_animation": "启用或禁用华丽的方块放置动画。",

"tooltip.fbp.cartoon_mode": "启用或禁用颗粒卡通模式。",
"tooltip.fbp.cull_particles": "启用或禁用粒子剔除。",

"tooltip.fbp.smart_breaking": "启用或禁用智能破坏。",
"tooltip.fbp.low_traction": "启用或禁用粒子低牵引力。",
Expand Down
10 changes: 8 additions & 2 deletions Forge/src/main/java/hantonik/fbp/config/FBPConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public final class FBPConfig {
private static final boolean DEFAULT_FROZEN = false;
private static final boolean DEFAULT_INFINITE_DURATION = false;
private static final boolean DEFAULT_CARTOON_MODE = false;
private static final boolean DEFAULT_CULL_PARTICLES = false;

private static final boolean DEFAULT_FANCY_FLAME = true;
private static final boolean DEFAULT_FANCY_SMOKE = true;
Expand Down Expand Up @@ -74,7 +75,7 @@ public final class FBPConfig {

public static final FBPConfig DEFAULT_CONFIG = new FBPConfig(
DEFAULT_ENABLED, DEFAULT_LOCKED,
DEFAULT_FROZEN, DEFAULT_INFINITE_DURATION, DEFAULT_CARTOON_MODE,
DEFAULT_FROZEN, DEFAULT_INFINITE_DURATION, DEFAULT_CARTOON_MODE, DEFAULT_CULL_PARTICLES,
DEFAULT_FANCY_FLAME, DEFAULT_FANCY_SMOKE, DEFAULT_FANCY_RAIN, DEFAULT_FANCY_SNOW, DEFAULT_SMOOTH_ANIMATION_LIGHTING,
DEFAULT_SMART_BREAKING, DEFAULT_LOW_TRACTION, DEFAULT_SPAWN_WHILE_FROZEN, DEFAULT_SMOOTH_ANIMATION_LIGHTING,
DEFAULT_SPAWN_PLACE_PARTICLES,
Expand All @@ -92,6 +93,7 @@ public final class FBPConfig {
private boolean frozen;
private boolean infiniteDuration;
private boolean cartoonMode;
private boolean cullParticles;

private boolean fancyFlame;
private boolean fancySmoke;
Expand Down Expand Up @@ -170,6 +172,7 @@ public void setConfig(FBPConfig config) {
this.frozen = config.frozen;
this.infiniteDuration = config.infiniteDuration;
this.cartoonMode = config.cartoonMode;
this.cullParticles = config.cullParticles;

this.fancyFlame = config.fancyFlame;
this.fancySmoke = config.fancySmoke;
Expand Down Expand Up @@ -213,6 +216,7 @@ public void applyConfig(FBPConfig config) {
this.frozen = config.frozen;
this.infiniteDuration = config.infiniteDuration;
this.cartoonMode = config.cartoonMode;
this.cullParticles = config.cullParticles;

this.fancyFlame = config.fancyFlame;
this.fancySmoke = config.fancySmoke;
Expand Down Expand Up @@ -280,6 +284,7 @@ public void reload() {
this.frozen = GsonHelper.getAsBoolean(json, "frozen", DEFAULT_FROZEN);
this.infiniteDuration = GsonHelper.getAsBoolean(json, "infiniteDuration", DEFAULT_INFINITE_DURATION);
this.cartoonMode = GsonHelper.getAsBoolean(json, "cartoonMode", DEFAULT_CARTOON_MODE);
this.cullParticles = GsonHelper.getAsBoolean(json, "cullParticles", DEFAULT_CULL_PARTICLES);

this.fancyFlame = GsonHelper.getAsBoolean(json, "fancyFlame", DEFAULT_FANCY_FLAME);
this.fancySmoke = GsonHelper.getAsBoolean(json, "fancySmoke", DEFAULT_FANCY_SMOKE);
Expand Down Expand Up @@ -343,6 +348,7 @@ public void save() {
json.addProperty("frozen", this.frozen);
json.addProperty("infiniteDuration", this.infiniteDuration);
json.addProperty("cartoonMode", this.cartoonMode);
json.addProperty("cullParticles", this.cullParticles);

json.addProperty("fancyFlame", this.fancyFlame);
json.addProperty("fancySmoke", this.fancySmoke);
Expand Down Expand Up @@ -395,7 +401,7 @@ public void save() {
public FBPConfig copy() {
return new FBPConfig(
this.enabled, this.locked,
this.frozen, this.infiniteDuration, this.cartoonMode,
this.frozen, this.infiniteDuration, this.cartoonMode, this.cullParticles,
this.fancyFlame, this.fancySmoke, this.fancyRain, this.fancySnow, this.fancyPlaceAnimation,
this.smartBreaking, this.lowTraction, this.spawnWhileFrozen, this.smoothAnimationLighting,
this.spawnPlaceParticles,
Expand Down
Loading

0 comments on commit 28f857d

Please sign in to comment.