Minimal Particles config option & optimizations

This commit is contained in:
Sn0wStorm
2020-11-16 21:52:25 +01:00
parent 4111ceec81
commit c91e441eab
14 changed files with 139 additions and 25 deletions
+4
View File
@@ -50,6 +50,7 @@ drainItems:
- MILK_BUCKET/2 - MILK_BUCKET/2
# Partikel steigen von Kesseln auf wenn sie Zutaten und eine Feuerquelle haben [true] # Partikel steigen von Kesseln auf wenn sie Zutaten und eine Feuerquelle haben [true]
# Die sich ändernde Farbe der Partikel kann beim Fermentieren mancher Rezepte helfen
enableCauldronParticles: true enableCauldronParticles: true
# Ob das craften und das benutzen des Trank-Versiegelungs-Tisches aktiviert ist (2 Flaschen über 4 Holz) [true, true] # Ob das craften und das benutzen des Trank-Versiegelungs-Tisches aktiviert ist (2 Flaschen über 4 Holz) [true, true]
@@ -502,6 +503,9 @@ colorInBrewer: true
# Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true] # Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen
minimalParticles: false
# -- Chat Veränderungs Einstellungen -- # -- Chat Veränderungs Einstellungen --
+4
View File
@@ -50,6 +50,7 @@ drainItems:
- MILK_BUCKET/2 - MILK_BUCKET/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show Particles over Cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -503,6 +504,9 @@ colorInBrewer: true
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true] # If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- Chat Distortion Settings -- # -- Chat Distortion Settings --
+4
View File
@@ -51,6 +51,7 @@ drainItems:
- MILK_BUCKET/2 - MILK_BUCKET/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show Particles over Cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -498,6 +499,9 @@ colorInBrewer: true
# Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true] # Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- Paramètres de la distorsion du Chat -- # -- Paramètres de la distorsion du Chat --
+5 -1
View File
@@ -49,7 +49,8 @@ drainItems:
- BREAD/4 - BREAD/4
- MILK_BUCKET/2 - MILK_BUCKET/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show particles over cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -490,6 +491,9 @@ colorInBrewer: true
# Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true] # Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- Imostazioni di distorsione della chat -- # -- Imostazioni di distorsione della chat --
+4
View File
@@ -50,6 +50,7 @@ drainItems:
- Milk_Bucket/2 - Milk_Bucket/2
# Partikel steigen von Kesseln auf wenn sie Zutaten und eine Feuerquelle haben [true] # Partikel steigen von Kesseln auf wenn sie Zutaten und eine Feuerquelle haben [true]
# Die sich ändernde Farbe der Partikel kann beim Fermentieren mancher Rezepte helfen
enableCauldronParticles: true enableCauldronParticles: true
# Ob das craften und das benutzen des Trank-Versiegelungs-Tisches aktiviert ist (2 Flaschen über 4 Holz) [true, true] # Ob das craften und das benutzen des Trank-Versiegelungs-Tisches aktiviert ist (2 Flaschen über 4 Holz) [true, true]
@@ -899,6 +900,9 @@ colorInBrewer: true
# Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true] # Ob große Fässer an jedem Block geöffnet werden können, nicht nur an Zapfhahn und Schild. Bei kleinen Fässern geht dies immer. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# Ob nur ein Minimum an Kessel-Partikeln dargestellt werden sollen
minimalParticles: false
# -- Chat Veränderungs Einstellungen -- # -- Chat Veränderungs Einstellungen --
+4
View File
@@ -50,6 +50,7 @@ drainItems:
- Milk_Bucket/2 - Milk_Bucket/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show Particles over Cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -891,6 +892,9 @@ colorInBrewer: true
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true] # If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- Chat Distortion Settings -- # -- Chat Distortion Settings --
+4
View File
@@ -50,6 +50,7 @@ drainItems:
- Milk_Bucket/2 - Milk_Bucket/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show Particles over Cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -891,6 +892,9 @@ colorInBrewer: true
# If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true] # If a Large Barrel can be opened by clicking on any of its blocks, not just Spigot or Sign. This is always true for Small Barrels. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- Chat Distortion Settings -- # -- Chat Distortion Settings --
+4
View File
@@ -51,6 +51,7 @@ drainItems:
- Milk_Bucket/2 - Milk_Bucket/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show Particles over Cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -897,6 +898,9 @@ colorInBrewer: true
# Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true] # Si le grand tonneau peut être ouvert en cliquant sur n'importe quel bloc, non seulement le robinet ou le panneau. Toujours "true" pour les petits tonneaux. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- Paramètres de la distorsion du Chat -- # -- Paramètres de la distorsion du Chat --
+4
View File
@@ -50,6 +50,7 @@ drainItems:
- Milk_Bucket/2 - Milk_Bucket/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show Particles over Cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -891,6 +892,9 @@ colorInBrewer: true
# Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true] # Se un barile grande può essere aperto cliccandoci sopra, non solo sul cartello e sulla staccionata. Questo è sempre true per i barili piccoli. [true]
openLargeBarrelEverywhere: true openLargeBarrelEverywhere: true
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- Imostazioni di distorsione della chat -- # -- Imostazioni di distorsione della chat --
+4
View File
@@ -52,6 +52,7 @@ drainItems:
- Milk_Bucket/2 - Milk_Bucket/2
# Show Particles over Cauldrons when they have ingredients and a heat source. [true] # Show Particles over Cauldrons when they have ingredients and a heat source. [true]
# The changing color of the particles can help with timing some recipes
enableCauldronParticles: true enableCauldronParticles: true
# If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true] # If crafting and using of the Brew Sealing Table is enabled (2 Bottles over 4 Planks) [true, true]
@@ -895,6 +896,9 @@ colorInBrewer: true
# 大型熟成木桶可以通过右击桶身任意一个位置来打开, 而不需要专门右击其龙头. 这一操作对小型酒桶总为真.[true] # 大型熟成木桶可以通过右击桶身任意一个位置来打开, 而不需要专门右击其龙头. 这一操作对小型酒桶总为真.[true]
openLargeBarrelEverywhere: false openLargeBarrelEverywhere: false
# If Cauldron Particles should be reduced to the bare minimum
minimalParticles: false
# -- 口糊设置 -- # -- 口糊设置 --
+12 -4
View File
@@ -6,7 +6,7 @@ authors: [Milan Albrecht, Frank Baumann, ProgrammerDan, Daniel Saukel]
api-version: 1.13 api-version: 1.13
commands: commands:
brewery: brewery:
description: Command for Administration description: Mostly admin commands to create/modify Brews and drunkeness
aliases: [brew] aliases: [brew]
permissions: permissions:
# -- Groups -- # -- Groups --
@@ -42,6 +42,8 @@ permissions:
brewery.cmd.pukeOther: true brewery.cmd.pukeOther: true
brewery.cmd.player: true brewery.cmd.player: true
brewery.cmd.create: true brewery.cmd.create: true
brewery.cmd.drink: true
brewery.cmd.drinkOther: true
brewery.cmd.copy: true brewery.cmd.copy: true
brewery.cmd.delete: true brewery.cmd.delete: true
brewery.cmd.static: true brewery.cmd.static: true
@@ -73,12 +75,18 @@ permissions:
description: Set Player-values description: Set Player-values
brewery.cmd.wakeup: brewery.cmd.wakeup:
description: Set, Check and Remove Wakeup Points description: Set, Check and Remove Wakeup Points
brewery.cmd.create:
description: Create Brews
brewery.cmd.drink:
description: Simulate drinking Brews
brewery.cmd.drinkOther:
description: Simulate other players drinking Brews
brewery.cmd.copy: brewery.cmd.copy:
description: Copy Potions description: Copy Brews
brewery.cmd.delete: brewery.cmd.delete:
description: Delete Potions description: Delete Brews
brewery.cmd.static: brewery.cmd.static:
description: Make Potions Static description: Make Brews Static
brewery.cmd.reload: brewery.cmd.reload:
description: Reload config description: Reload config
+63 -17
View File
@@ -101,9 +101,9 @@ public class BCauldron {
if (state > 0) { if (state > 0) {
state--; state--;
} }
if (BConfig.enableCauldronParticles) { if (BConfig.enableCauldronParticles && !BConfig.minimalParticles) {
// Few little sparks and lots of water splashes. Offset by 0.2 in x and z // Few little sparks and lots of water splashes. Offset by 0.2 in x and z
block.getWorld().spawnParticle(Particle.SPELL_INSTANT, particleLocation,3, 0.2, 0, 0.2); block.getWorld().spawnParticle(Particle.SPELL_INSTANT, particleLocation,2, 0.2, 0, 0.2);
block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 10, 0.2, 0, 0.2); block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 10, 0.2, 0, 0.2);
} }
} }
@@ -238,6 +238,20 @@ public class BCauldron {
public void cookEffect() { public void cookEffect() {
if (BUtil.isChunkLoaded(block) && LegacyUtil.isCauldronHeatsource(block.getRelative(BlockFace.DOWN))) { if (BUtil.isChunkLoaded(block) && LegacyUtil.isCauldronHeatsource(block.getRelative(BlockFace.DOWN))) {
Color color = getParticleColor();
// Colorable spirally spell, 0 count enables color instead of the offset variables
// Configurable RGB color. The last parameter seems to control the hue and motion, but i couldn't find
// how exactly in the client code. 1025 seems to be the best for color brightness and upwards motion
block.getWorld().spawnParticle(Particle.SPELL_MOB, getRandParticleLoc(), 0,
((double) color.getRed()) / 255.0,
((double) color.getGreen()) / 255.0,
((double) color.getBlue()) / 255.0,
1025.0);
if (BConfig.minimalParticles) {
return;
}
if (particleRandom.nextFloat() > 0.85) { if (particleRandom.nextFloat() > 0.85) {
// Dark pixely smoke cloud at 0.4 random in x and z // Dark pixely smoke cloud at 0.4 random in x and z
// 0 count enables direction, send to y = 1 with speed 0.09 // 0 count enables direction, send to y = 1 with speed 0.09
@@ -247,17 +261,9 @@ public class BCauldron {
// A Water Splash with 0.2 offset in x and z // A Water Splash with 0.2 offset in x and z
block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 1, 0.2, 0, 0.2); block.getWorld().spawnParticle(Particle.WATER_SPLASH, particleLocation, 1, 0.2, 0, 0.2);
} }
Color color = getParticleColor();
// Colorable spirally spell, 0 count enables color instead of the offset variables
// Configurable RGB color. 1025 seems to be the best for color brightness and upwards motion
block.getWorld().spawnParticle(Particle.SPELL_MOB, getRandParticleLoc(), 0,
((double) color.getRed()) / 255.0,
((double) color.getGreen()) / 255.0,
((double) color.getBlue()) / 255.0,
1025.0);
if (P.use1_13 && particleRandom.nextFloat() > 0.4) { if (P.use1_13 && particleRandom.nextFloat() > 0.4) {
// Two hovering pixely dust clouds, a bit offset with DustOptions to give some color and size // Two hovering pixely dust clouds, a bit offset and with DustOptions to give some color and size
block.getWorld().spawnParticle(Particle.REDSTONE, particleLocation, 2, 0.15, 0.2, 0.15, new Particle.DustOptions(color, 1.5f)); block.getWorld().spawnParticle(Particle.REDSTONE, particleLocation, 2, 0.15, 0.2, 0.15, new Particle.DustOptions(color, 1.5f));
} }
} }
@@ -345,12 +351,52 @@ public class BCauldron {
return particleColor; return particleColor;
} }
public static void processNextCookEffects() { /*public static void processCookEffects() {
if (!BConfig.enableCauldronParticles) return; if (!BConfig.enableCauldronParticles) return;
int size = bcauldrons.size(); int size = bcauldrons.size();
if (size <= 0) { if (size <= 0) {
return; return;
} }
final int skipSize = PARTICLEPAUSE - 1 + (BConfig.minimalParticles ? 20 : 0);
int skip = particleRandom.nextInt(skipSize);
if (skip >= size) {
return;
}
Iterator<BCauldron> cauldronsIter = bcauldrons.values().iterator();
while (cauldronsIter.hasNext()) {
BCauldron cauldron = cauldronsIter.next();
if (skip == 0) {
cauldron.cookEffect();
skip = skipSize;
} else {
skip--;
}
}
}*/
public static void processCookEffects() {
if (!BConfig.enableCauldronParticles) return;
if (bcauldrons.isEmpty()) {
return;
}
final float chance = 1f / PARTICLEPAUSE;
for (BCauldron cauldron : bcauldrons.values()) {
if (particleRandom.nextFloat() < chance) {
cauldron.cookEffect();
}
}
}
public static void old_processNextCookEffects() {
if (!BConfig.enableCauldronParticles) return;
int size = bcauldrons.size();
if (size <= 0) {
return;
}
int useParticlePause = PARTICLEPAUSE;
// The Particle Delay is reduced every time, independent on how many cauldrons are processed // The Particle Delay is reduced every time, independent on how many cauldrons are processed
// If it did not reach zero as we process all cauldrons, skip some tasks // If it did not reach zero as we process all cauldrons, skip some tasks
@@ -358,17 +404,17 @@ public class BCauldron {
if (particleCauldron >= size) { if (particleCauldron >= size) {
if (particleDelay <= 0) { if (particleDelay <= 0) {
particleCauldron = 0; particleCauldron = 0;
particleDelay = PARTICLEPAUSE; particleDelay = useParticlePause;
} }
return; return;
} }
// Decide how many cauldrons to process this time // Decide how many cauldrons to process this time
int cauldronsToProcess; int cauldronsToProcess;
if (size < PARTICLEPAUSE) { if (size < useParticlePause) {
cauldronsToProcess = 1; cauldronsToProcess = 1;
} else { } else {
cauldronsToProcess = (int) Math.ceil((float) size / (float) PARTICLEPAUSE); cauldronsToProcess = (int) Math.ceil((float) size / (float) useParticlePause);
} }
Iterator<BCauldron> cauldronsIter = bcauldrons.values().iterator(); Iterator<BCauldron> cauldronsIter = bcauldrons.values().iterator();
@@ -383,7 +429,7 @@ public class BCauldron {
if (particleDelay <= 0) { if (particleDelay <= 0) {
// Processing all cauldrons took as long as the delay, start over right away // Processing all cauldrons took as long as the delay, start over right away
particleCauldron = 0; particleCauldron = 0;
particleDelay = PARTICLEPAUSE; particleDelay = useParticlePause;
} }
return; return;
} }
@@ -516,7 +562,7 @@ public class BCauldron {
* Recalculate the Cauldron Particle Recipe * Recalculate the Cauldron Particle Recipe
*/ */
public static void reload() { public static void reload() {
for (BCauldron cauldron : BCauldron.bcauldrons.values()) { for (BCauldron cauldron : bcauldrons.values()) {
cauldron.particleRecipe = null; cauldron.particleRecipe = null;
cauldron.particleColor = null; cauldron.particleColor = null;
if (BConfig.enableCauldronParticles) { if (BConfig.enableCauldronParticles) {
+19 -1
View File
@@ -23,6 +23,9 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@@ -517,10 +520,25 @@ public class P extends JavaPlugin {
} }
private int ticks = 0;
private double times = 0;
public class CauldronParticles implements Runnable { public class CauldronParticles implements Runnable {
@Override @Override
public void run() { public void run() {
BCauldron.processNextCookEffects(); if (BConfig.minimalParticles && BCauldron.particleRandom.nextFloat() > 0.5f) {
return;
}
long t1 = System.nanoTime();
BCauldron.processCookEffects();
long t2 = System.nanoTime();
times += (t2 - t1) / 1000.0;
ticks++;
if (ticks == BCauldron.PARTICLEPAUSE) {
ticks = 0;
P.p.log("Particles: ~ " + BigDecimal.valueOf(times / BCauldron.PARTICLEPAUSE).round(new MathContext(5, RoundingMode.HALF_UP)) + "µs");
times = 0;
}
} }
} }
@@ -65,6 +65,7 @@ public class BConfig {
// Cauldron // Cauldron
public static boolean useOffhandForCauldron; public static boolean useOffhandForCauldron;
public static boolean enableCauldronParticles; public static boolean enableCauldronParticles;
public static boolean minimalParticles;
//BPlayer //BPlayer
public static Map<Material, Integer> drainItems = new HashMap<>();// DrainItem Material and Strength public static Map<Material, Integer> drainItems = new HashMap<>();// DrainItem Material and Strength
@@ -250,6 +251,7 @@ public class BConfig {
enableEncode = config.getBoolean("enableEncode", false); enableEncode = config.getBoolean("enableEncode", false);
openEverywhere = config.getBoolean("openLargeBarrelEverywhere", false); openEverywhere = config.getBoolean("openLargeBarrelEverywhere", false);
enableCauldronParticles = P.use1_9 && config.getBoolean("enableCauldronParticles", false); enableCauldronParticles = P.use1_9 && config.getBoolean("enableCauldronParticles", false);
minimalParticles = config.getBoolean("minimalParticles", false);
useOffhandForCauldron = config.getBoolean("useOffhandForCauldron", false); useOffhandForCauldron = config.getBoolean("useOffhandForCauldron", false);
loadDataAsync = config.getBoolean("loadDataAsync", true); loadDataAsync = config.getBoolean("loadDataAsync", true);