From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Wed, 27 Sep 2023 16:42:17 +0900 Subject: [PATCH] Optimize default configurations Reference: YouHaveTrouble/minecraft-optimization, AkiraDevelopment/SimplyMC diff --git a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java index 5f223856b06e901b100fcca8e6dd968e0b2e3a8e..13df89e7cc219cdb80c4114d05148c685ad2ecee 100644 --- a/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java +++ b/src/main/java/gg/pufferfish/pufferfish/PufferfishConfig.java @@ -72,7 +72,7 @@ public class PufferfishConfig { getString("info.version", "1.0"); setComment("info", "Pufferfish Configuration", - "Check out Pufferfish Host for maximum performance server hosting: https://pufferfish.host", + //"Check out Pufferfish Host for maximum performance server hosting: https://pufferfish.host", // Plazma - no advertisement "Join our Discord for support: https://discord.gg/reZw4vQV9H", "Download new builds at https://ci.pufferfish.host/job/Pufferfish"); @@ -219,7 +219,7 @@ public class PufferfishConfig { public static int maxProjectileLoadsPerTick; public static int maxProjectileLoadsPerProjectile; private static void projectileLoading() { - maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); + maxProjectileLoadsPerTick = getInt("projectile.max-loads-per-tick", org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 8 : 10, "Controls how many chunks are allowed", "to be sync loaded by projectiles in a tick."); // Plazma - Optimize default configurations maxProjectileLoadsPerProjectile = getInt("projectile.max-loads-per-projectile", 10, "Controls how many chunks a projectile", "can load in its lifetime before it gets", "automatically removed."); setComment("projectile", "Optimizes projectile settings"); @@ -233,7 +233,7 @@ public class PufferfishConfig { public static int activationDistanceMod; private static void dynamicActivationOfBrains() throws IOException { - dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", false); // Purpur + dearEnabled = getBoolean("dab.enabled", "activation-range.enabled", org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize()); // Purpur // Plazma - Optimize default configurations startDistance = getInt("dab.start-distance", "activation-range.start-distance", 12, "This value determines how far away an entity has to be", "from the player to start being effected by DEAR."); @@ -241,7 +241,7 @@ public class PufferfishConfig { maximumActivationPrio = getInt("dab.max-tick-freq", "activation-range.max-tick-freq", 20, "This value defines how often in ticks, the furthest entity", "will get their pathfinders and behaviors ticked. 20 = 1s"); - activationDistanceMod = getInt("dab.activation-dist-mod", "activation-range.activation-dist-mod", 8, + activationDistanceMod = getInt("dab.activation-dist-mod", "activation-range.activation-dist-mod", org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 7 : 8, // Plazma - Optimize default configurations "This value defines how much distance modifies an entity's", "tick frequency. freq = (distanceToPlayer^2) / (2^value)", "If you want further away entities to tick less often, use 7.", diff --git a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java index c69892a5f31895b85e530beadd8864ac32470ba7..5f652268dadaca96a98203ad12d7a0ba0b19563b 100644 --- a/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/GlobalConfiguration.java @@ -154,7 +154,7 @@ public class GlobalConfiguration extends ConfigurationPart { public class Watchdog extends ConfigurationPart { public int earlyWarningEvery = 5000; - public int earlyWarningDelay = 10000; + public int earlyWarningDelay = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 180000 : 10000; // Plazma - Optimize default configurations } public SpamLimiter spamLimiter; diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java index ec5e23136423e42e4f55e6ea646b8285c1ca14e2..a1d22ad65fc751fa93384f59853434ab65836133 100644 --- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -88,15 +88,27 @@ public class WorldConfiguration extends ConfigurationPart { public class AntiXray extends ConfigurationPart { public boolean enabled = false; - public EngineMode engineMode = EngineMode.HIDE; + public EngineMode engineMode = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? EngineMode.OBFUSCATE_LAYER : EngineMode.HIDE; // Plazma - Optimize default configurations public int maxBlockHeight = 64; public int updateRadius = 2; public boolean lavaObscures = false; public boolean usePermission = false; - public List hiddenBlocks = List.of("copper_ore", "deepslate_copper_ore", "gold_ore", "deepslate_gold_ore", "iron_ore", "deepslate_iron_ore", - "coal_ore", "deepslate_coal_ore", "lapis_ore", "deepslate_lapis_ore", "mossy_cobblestone", "obsidian", "chest", "diamond_ore", "deepslate_diamond_ore", - "redstone_ore", "deepslate_redstone_ore", "clay", "emerald_ore", "deepslate_emerald_ore", "ender_chest"); // TODO update type to List - public List replacementBlocks = List.of("stone", "oak_planks", "deepslate"); // TODO update type to List + // Plazma start - Optimize default configurations + public List hiddenBlocks = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? + List.of("air", "copper_ore", "deepslate_copper_ore", "raw_copper_block", "iron_ore", + "deepslate_iron_ore", "raw_iron_block", "gold_ore", "deepslate_gold_ore", "raw_gold_block", + "lapis_ore", "deepslate_lapis_ore", "redstone_ore", "deepslate_redstone_ore", "diamond_ore", + "deepslate_diamond_ore") : + List.of("copper_ore", "deepslate_copper_ore","gold_ore", "deepslate_gold_ore", + "iron_ore", "deepslate_iron_ore", "coal_ore", "deepslate_coal_ore", "lapis_ore", + "deepslate_lapis_ore", "mossy_cobblestone", "obsidian", "chest", "diamond_ore", + "deepslate_diamond_ore", "redstone_ore", "deepslate_redstone_ore", "clay", "emerald_ore", + "deepslate_emerald_ore", "ender_chest");; // TODO update type to List + public List replacementBlocks = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? + List.of("chest", "amethyst_block", "andesite", "budding_amethyst", "calcite", "coal_ore", + "deepslate_coal_ore", "deepslate", "diorite", "dirt", "emerald_ore", "granite", "gravel", + "oak_planks", "smooth_basalt", "stone", "tuff") : List.of("stone", "oak_planks", "deepslate"); // TODO update type to List + // Plazma end } } @@ -150,7 +162,7 @@ public class WorldConfiguration extends ConfigurationPart { @MergeMap public Reference2IntMap spawnLimits = Util.make(new Reference2IntOpenHashMap<>(NaturalSpawner.SPAWNING_CATEGORIES.length), map -> Arrays.stream(NaturalSpawner.SPAWNING_CATEGORIES).forEach(mobCategory -> map.put(mobCategory, -1))); @MergeMap - public Map despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), category.getDespawnDistance()))); + public Map despawnRanges = Arrays.stream(MobCategory.values()).collect(Collectors.toMap(Function.identity(), category -> new DespawnRange(category.getNoDespawnDistance(), org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? (net.minecraft.server.MinecraftServer.getServer().server.getSimulationDistance() * 16) + 8 : category.getDespawnDistance()))); // Plazma - Optimize default configurations @ConfigSerializable public record DespawnRange(@Required int soft, @Required int hard) { @@ -375,7 +387,7 @@ public class WorldConfiguration extends ConfigurationPart { public class Environment extends ConfigurationPart { public boolean disableThunder = false; public boolean disableIceAndSnow = false; - public boolean optimizeExplosions = false; + public boolean optimizeExplosions = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations public boolean disableExplosionKnockback = false; public boolean generateFlatBedrock = false; public FrostedIce frostedIce; @@ -427,7 +439,7 @@ public class WorldConfiguration extends ConfigurationPart { public Fixes fixes; public class Fixes extends ConfigurationPart { - public boolean fixItemsMergingThroughWalls = false; + public boolean fixItemsMergingThroughWalls = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations public boolean disableUnloadedChunkEnderpearlExploit = true; public boolean preventTntFromMovingInWater = false; public boolean splitOverstackedLoot = true; @@ -455,9 +467,9 @@ public class WorldConfiguration extends ConfigurationPart { public class Collisions extends ConfigurationPart { public boolean onlyPlayersCollide = false; public boolean allowVehicleCollisions = true; - public boolean fixClimbingBypassingCrammingRule = false; + public boolean fixClimbingBypassingCrammingRule = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations @RequiresSpigotInitialization(MaxEntityCollisionsInitializer.class) - public int maxEntityCollisions = 8; + public int maxEntityCollisions = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 2 : 8; // Plazma - Optimize default configurations public boolean allowPlayerCrammingDamage = false; } @@ -465,18 +477,40 @@ public class WorldConfiguration extends ConfigurationPart { public class Chunks extends ConfigurationPart { public AutosavePeriod autoSaveInterval = AutosavePeriod.def(); - public int maxAutoSaveChunksPerTick = 24; + public int maxAutoSaveChunksPerTick = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 8 : 24; // Plazma - Optimize default configurations public int fixedChunkInhabitedTime = -1; - public boolean preventMovingIntoUnloadedChunks = false; + public boolean preventMovingIntoUnloadedChunks = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations public Duration delayChunkUnloadsBy = Duration.of("10s"); public Reference2IntMap> entityPerChunkSaveLimit = Util.make(new Reference2IntOpenHashMap<>(BuiltInRegistries.ENTITY_TYPE.size()), map -> { - map.defaultReturnValue(-1); - map.put(EntityType.EXPERIENCE_ORB, -1); - map.put(EntityType.SNOWBALL, -1); - map.put(EntityType.ENDER_PEARL, -1); - map.put(EntityType.ARROW, -1); - map.put(EntityType.FIREBALL, -1); - map.put(EntityType.SMALL_FIREBALL, -1); + // Plazma start - Optimize default configurations + if (org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize()) { + map.put(EntityType.AREA_EFFECT_CLOUD, 8); + map.put(EntityType.ARROW, 16); + map.put(EntityType.DRAGON_FIREBALL, 3); + map.put(EntityType.EGG, 8); + map.put(EntityType.ENDER_PEARL, 8); + map.put(EntityType.EXPERIENCE_BOTTLE, 3); + map.put(EntityType.EXPERIENCE_ORB, 16); + map.put(EntityType.EYE_OF_ENDER, 8); + map.put(EntityType.FIREBALL, 8); + map.put(EntityType.FIREWORK_ROCKET, 8); + map.put(EntityType.LLAMA_SPIT, 3); + map.put(EntityType.POTION, 8); + map.put(EntityType.SHULKER_BULLET, 8); + map.put(EntityType.SMALL_FIREBALL, 8); + map.put(EntityType.SNOWBALL, 8); + map.put(EntityType.SPECTRAL_ARROW, 16); + map.put(EntityType.TRIDENT, 16); + map.put(EntityType.WITHER_SKULL, 4); + } else { + map.put(EntityType.EXPERIENCE_ORB, -1); + map.put(EntityType.SNOWBALL, -1); + map.put(EntityType.ENDER_PEARL, -1); + map.put(EntityType.ARROW, -1); + map.put(EntityType.FIREBALL, -1); + map.put(EntityType.SMALL_FIREBALL, -1); + } + // Plazma end }); public boolean flushRegionsOnSave = false; } @@ -491,9 +525,9 @@ public class WorldConfiguration extends ConfigurationPart { public TickRates tickRates; public class TickRates extends ConfigurationPart { - public int grassSpread = 1; + public int grassSpread = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 4 : 1; // Plazma - Optimize default configurations public int containerUpdate = 1; - public int mobSpawner = 1; + public int mobSpawner = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? 2 : 1; // Plazma - Optimize default configurations public Table, String, Integer> sensor = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "secondarypoisensor", 40)); public Table, String, Integer> behavior = Util.make(HashBasedTable.create(), table -> table.put(EntityType.VILLAGER, "validatenearbypoi", -1)); } @@ -517,9 +551,9 @@ public class WorldConfiguration extends ConfigurationPart { public class Misc extends ConfigurationPart { public int lightQueueSize = 20; - public boolean updatePathfindingOnBlockUpdate = true; + public boolean updatePathfindingOnBlockUpdate = !org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize(); // Plazma - Optimize default configurations public boolean showSignClickCommandFailureMsgsToPlayer = false; - public RedstoneImplementation redstoneImplementation = RedstoneImplementation.VANILLA; + public RedstoneImplementation redstoneImplementation = org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? RedstoneImplementation.ALTERNATE_CURRENT : RedstoneImplementation.VANILLA; // Plazma - Optimize default configurations public boolean disableEndCredits = false; public float maxLeashDistance = 10f; public boolean disableSprintInterruptionOnAttack = false; diff --git a/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java b/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java index 24763d3d270c29c95e0b3e85111145234f660a62..ba7cf430cdff947a74ae067fc79020ae01e7e457 100644 --- a/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java +++ b/src/main/java/io/papermc/paper/configuration/type/fallback/ArrowDespawnRate.java @@ -29,6 +29,7 @@ public class ArrowDespawnRate extends FallbackValue.Int { @Override protected int fallback() { + if (org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize()) return 100; // Plazma - Optimize default configurations return this.get(FallbackValue.SPIGOT_WORLD_CONFIG).arrowDespawnRate; } diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java index 30fc258faa6f087cf3c91411b48116a3ac416031..a32a1787cbcacb0d3ed6f0d751a04e8fa9d11dd6 100644 --- a/src/main/java/net/minecraft/server/Main.java +++ b/src/main/java/net/minecraft/server/Main.java @@ -163,7 +163,7 @@ public class Main { File configFile = (File) optionset.valueOf("bukkit-settings"); YamlConfiguration configuration = YamlConfiguration.loadConfiguration(configFile); configuration.options().copyDefaults(true); - configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8))); + configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(Main.class.getClassLoader().getResourceAsStream(org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? "configurations/bukkit_optimized.yml" : "configurations/bukkit.yml"), Charsets.UTF_8))); configuration.save(configFile); File commandFile = (File) optionset.valueOf("commands-settings"); @@ -177,8 +177,7 @@ public class Main { } // Spigot Start - boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" ); - eulaAgreed = eulaAgreed || Boolean.getBoolean("Paper.isRunDev"); + boolean eulaAgreed = Boolean.getBoolean( "com.mojang.eula.agree" ) || Boolean.getBoolean("Paper.isRunDev"); // Plazma if ( eulaAgreed ) { System.err.println( "You have used the Spigot command line EULA agreement flag." ); diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java index cda4544ae96a4fcb5c6c4483df67a59f1b53fd27..54f2c5187322c6dea70c4e0e63cce2e68e7ac647 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java @@ -130,15 +130,15 @@ public class DedicatedServerProperties extends Settings { return Mth.clamp(integer, 1, 29999984); }, 29999984); - this.syncChunkWrites = this.get("sync-chunk-writes", true) && Boolean.getBoolean("Paper.enable-sync-chunk-writes"); // Paper - hide behind flag + this.syncChunkWrites = this.get("sync-chunk-writes", Boolean.getBoolean("Paper.enable-sync-chunk-writes")); // Paper - hide behind flag // Plazma - Optimize default configurations this.enableJmxMonitoring = this.get("enable-jmx-monitoring", false); this.enableStatus = this.get("enable-status", true); this.hideOnlinePlayers = this.get("hide-online-players", false); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index 3e8f42811e9254567f2522e68b6018704bd63ae2..f8805e11551fddfda44aa36ba4e83f3df2f87500 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -431,7 +431,7 @@ public final class CraftServer implements Server { this.configuration = YamlConfiguration.loadConfiguration(this.getConfigFile()); this.configuration.options().copyDefaults(true); - this.configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"), Charsets.UTF_8))); + this.configuration.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(org.plazmamc.plazma.configurations.PlazmaConfigurations.doOptimize() ? "configurations/bukkit_optimized.yml" : "configurations/bukkit.yml"), Charsets.UTF_8))); // Plazma - Optimize default configurations ConfigurationSection legacyAlias = null; if (!this.configuration.isString("aliases")) { legacyAlias = this.configuration.getConfigurationSection("aliases"); diff --git a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java index 39db772735d57e12bbb26a6505ca7a5e360cdd78..eabd643bf096786285ee21e898b2bf8460cd5a26 100644 --- a/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java +++ b/src/main/java/org/plazmamc/plazma/configurations/PlazmaConfigurations.java @@ -302,7 +302,7 @@ public class PlazmaConfigurations extends Configurations