From cc61709dc82977205537cbe497ffe904d544b206 Mon Sep 17 00:00:00 2001 From: AlphaKR93 Date: Tue, 7 Nov 2023 15:59:46 +0900 Subject: [PATCH] more more more work --- .../0024-Ignore-useless-entity-packets.patch | 4 +- .../0028-Optimise-state-lookup-more.patch | 41 ++++++++----------- ...ppress-errors-from-dirty-attributes.patch} | 28 ++++++------- .../0030-Skip-event-if-no-listeners.patch | 28 ++----------- .../0031-Optimize-spigot-event-bus.patch} | 16 ++++---- ...0024-Improve-biome-temperature-cache.patch | 28 ------------- .../0026-Configurable-sensor-tick.patch | 35 ---------------- 7 files changed, 47 insertions(+), 133 deletions(-) rename patches/{unapplied => }/server/0028-Optimise-state-lookup-more.patch (60%) rename patches/{unapplied/server/0029-Suppress-error-from-dirty-attributes.patch => server/0029-Suppress-errors-from-dirty-attributes.patch} (50%) rename patches/{unapplied => }/server/0030-Skip-event-if-no-listeners.patch (58%) rename patches/{unapplied/server/0031-Optimize-Spigot-event-bus.patch => server/0031-Optimize-spigot-event-bus.patch} (79%) delete mode 100644 patches/unapplied/server/0024-Improve-biome-temperature-cache.patch delete mode 100644 patches/unapplied/server/0026-Configurable-sensor-tick.patch diff --git a/patches/server/0024-Ignore-useless-entity-packets.patch b/patches/server/0024-Ignore-useless-entity-packets.patch index 56fd82e88..882026018 100644 --- a/patches/server/0024-Ignore-useless-entity-packets.patch +++ b/patches/server/0024-Ignore-useless-entity-packets.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Ignore useless entity packets diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index c6ef510d335b8baea58c4491853414a52a06b66b..ccc2f5f71181c1d5c36dcb85de3e48982db0aa8f 100644 +index c6ef510d335b8baea58c4491853414a52a06b66b..e2dcdc9f317a4ab1a9b30e482607dc041abb7035 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java @@ -200,6 +200,8 @@ public class ServerEntity { @@ -13,7 +13,7 @@ index c6ef510d335b8baea58c4491853414a52a06b66b..ccc2f5f71181c1d5c36dcb85de3e4898 flag5 = true; } + -+ if (this.entity.level().plazmaConfig().entity.ignoreUselessPackets && isUselessPacket(packet1)) packet1 = null; // Plazma ++ if (this.level.plazmaConfig().entity.ignoreUselessPackets && isUselessPacket(packet1)) packet1 = null; // Plazma } if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { diff --git a/patches/unapplied/server/0028-Optimise-state-lookup-more.patch b/patches/server/0028-Optimise-state-lookup-more.patch similarity index 60% rename from patches/unapplied/server/0028-Optimise-state-lookup-more.patch rename to patches/server/0028-Optimise-state-lookup-more.patch index 3a1cdd378..b5e90226a 100644 --- a/patches/unapplied/server/0028-Optimise-state-lookup-more.patch +++ b/patches/server/0028-Optimise-state-lookup-more.patch @@ -1,59 +1,54 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Sat, 30 Sep 2023 22:02:58 +0900 +Date: Tue, 7 Nov 2023 15:47:45 +0900 Subject: [PATCH] Optimise state lookup more diff --git a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java -index 57d0cd3ad6f972e986c72a57f1a6e36003f190c2..0832e4fa92b6464a6206475fbceb3b36462757b3 100644 +index 57d0cd3ad6f972e986c72a57f1a6e36003f190c2..50d97c5ab33f33b81dbafd7cf42da5afd9856eeb 100644 --- a/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java +++ b/src/main/java/io/papermc/paper/util/table/ZeroCollidingReferenceStateTable.java @@ -17,6 +17,7 @@ public final class ZeroCollidingReferenceStateTable { protected final StateHolder this_state; protected long[] index_table; -+ public long[] index_table() { return this.index_table; } // Plazma - getter ++ public long[] index_table() { return this.index_table; } // Plazma - Getter protected StateHolder[][] value_table; public ZeroCollidingReferenceStateTable(final StateHolder state, final Map, Comparable> this_map) { diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java -index 5f285d190186a2ff5a61d05070593e1d633dd79a..7b61a956892e90c7556db46d9277da8d252547cd 100644 +index 5f285d190186a2ff5a61d05070593e1d633dd79a..25a2d70ce34fe57dc3838d4351ac88794acb7109 100644 --- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java +++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java -@@ -114,21 +114,15 @@ public abstract class StateHolder { +@@ -114,6 +114,13 @@ public abstract class StateHolder { } public , V extends T> S trySetValue(Property property, V value) { -- Comparable comparable = this.values.get(property); -- if (comparable != null && !comparable.equals(value)) { -- S object = this.neighbours.get(property, value); -- if (object == null) { -- throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); -- } else { -- return object; -- } -- } else { -- return (S)this; -- } -+ // Plazma start - optimise state lookup more -+ final S ret = (S) this.optimisedTable.get(property, value); -+ if (ret == null) throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); -+ return ret; ++ // Plazma start - Optimise state lookup more ++ if (true) { ++ final S ret = (S) this.optimisedTable.get(property, value); ++ if (ret == null) throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); ++ return ret; ++ } + // Plazma end + Comparable comparable = this.values.get(property); + if (comparable != null && !comparable.equals(value)) { + S object = this.neighbours.get(property, value); +@@ -128,7 +135,7 @@ public abstract class StateHolder { } public void populateNeighbours(Map, Comparable>, S> states) { - if (this.neighbours != null) { -+ if (this.optimisedTable.index_table() != null) { // Plazma - optimise state lookup more ++ if (this.optimisedTable.index_table() != null) { // Plazma - Optimise state holder more throw new IllegalStateException(); } else { Table, Comparable, S> table = HashBasedTable.create(); -@@ -143,7 +137,7 @@ public abstract class StateHolder { +@@ -143,7 +150,7 @@ public abstract class StateHolder { } } - this.neighbours = (Table, Comparable, S>)(table.isEmpty() ? table : ArrayTable.create(table)); this.optimisedTable.loadInTable((Table)this.neighbours, this.values); // Paper - optimise state lookup -+ this.optimisedTable.loadInTable((Table) (table.isEmpty() ? table : ArrayTable.create(table)), this.values); // Paper - optimise state lookup // Plazma - more ++ this.optimisedTable.loadInTable((Table) (table.isEmpty() ? table : ArrayTable.create(table)), this.values); // Plazma - Optimize state lookup more } } diff --git a/patches/unapplied/server/0029-Suppress-error-from-dirty-attributes.patch b/patches/server/0029-Suppress-errors-from-dirty-attributes.patch similarity index 50% rename from patches/unapplied/server/0029-Suppress-error-from-dirty-attributes.patch rename to patches/server/0029-Suppress-errors-from-dirty-attributes.patch index 91d707f7f..8638223d2 100644 --- a/patches/unapplied/server/0029-Suppress-error-from-dirty-attributes.patch +++ b/patches/server/0029-Suppress-errors-from-dirty-attributes.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Sat, 30 Sep 2023 22:06:00 +0900 -Subject: [PATCH] Suppress error from dirty attributes +Date: Tue, 7 Nov 2023 15:52:24 +0900 +Subject: [PATCH] Suppress errors from dirty attributes diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index b2770e053f6db173dedbf044d67aa315e2fd7302..30b4c6bf1a0c847d00fc466ca9c997f9049bb697 100644 +index e2dcdc9f317a4ab1a9b30e482607dc041abb7035..46e489dd059bc3bf8f1c5efa073fbcd892bc389d 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java @@ -395,7 +395,8 @@ public class ServerEntity { @@ -14,7 +14,7 @@ index b2770e053f6db173dedbf044d67aa315e2fd7302..30b4c6bf1a0c847d00fc466ca9c997f9 if (this.entity instanceof LivingEntity) { - Set set = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes(); + Set attributes = ((LivingEntity) this.entity).getAttributes().getDirtyAttributes(); // Plazma - Suppress error from dirty attributes -+ final Set set = this.entity.level().plazmaLevelConfiguration().entity.suppressErrorFromDirtyAttributes ? java.util.Collections.synchronizedSet(attributes) : attributes; // Plazma - Suppress error from dirty attributes ++ final Set set = this.level.plazmaConfig().entity.suppressErrorsFromDirtyAttributes ? Collections.synchronizedSet(attributes) : attributes; // Plazma - Suppress error from dirty attributes if (!set.isEmpty()) { // CraftBukkit start - Send scaled max health @@ -27,15 +27,15 @@ index b2770e053f6db173dedbf044d67aa315e2fd7302..30b4c6bf1a0c847d00fc466ca9c997f9 } } -diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index cb21da3cff4dbb08c7786c09b39e381abdf45c33..dfd408dc42a6000eb5fa56bbdb64f2329e545078 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -36,6 +36,7 @@ public class LevelConfigurations extends ConfigurationPart { - public int sensorTick = DO_OPTIMIZE ? 10 : 1; +diff --git a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java +index fae1913ec6b3689388f14f4b9c925dd53954cf62..ee84ac47adc29c54d668fc9e1729444e51649659 100644 +--- a/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java ++++ b/src/main/java/org/plazmamc/plazma/configurations/WorldConfigurations.java +@@ -30,6 +30,7 @@ public class WorldConfigurations extends ConfigurationPart { - public boolean ignoreUselessPackets = DO_OPTIMIZE; -+ public boolean suppressErrorFromDirtyAttributes = false; + public boolean ignoreUselessPackets = OPTIMIZE; + public int sensorTick = 1; ++ public boolean suppressErrorsFromDirtyAttributes = OPTIMIZE; - public Player player; - public class Player extends ConfigurationPart { + public Phantom phantom; + public class Phantom extends ConfigurationPart { diff --git a/patches/unapplied/server/0030-Skip-event-if-no-listeners.patch b/patches/server/0030-Skip-event-if-no-listeners.patch similarity index 58% rename from patches/unapplied/server/0030-Skip-event-if-no-listeners.patch rename to patches/server/0030-Skip-event-if-no-listeners.patch index 6b854ad15..52761dd5c 100644 --- a/patches/unapplied/server/0030-Skip-event-if-no-listeners.patch +++ b/patches/server/0030-Skip-event-if-no-listeners.patch @@ -1,23 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Sat, 30 Sep 2023 22:10:59 +0900 +Date: Tue, 7 Nov 2023 15:56:21 +0900 Subject: [PATCH] Skip event if no listeners diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..6016c304ddbeb6ffbd591f30914c85fcb6371e80 100644 +index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..fb4135cb5d9e4162336c43d3b61c9d9a175a4dd5 100644 --- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -@@ -26,7 +26,7 @@ import java.util.Map; - import java.util.Set; - import java.util.logging.Level; - --class PaperEventManager { -+public class PaperEventManager { // Plazma - package -> public - - private final Server server; - -@@ -36,15 +36,17 @@ class PaperEventManager { +@@ -36,15 +36,18 @@ class PaperEventManager { // SimplePluginManager public void callEvent(@NotNull Event event) { @@ -26,6 +17,7 @@ index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..6016c304ddbeb6ffbd591f30914c85fc + RegisteredListener[] listeners = handlers.getRegisteredListeners(); + if (listeners.length == 0) return; + // Plazma end ++ if (event.isAsynchronous() && this.server.isPrimaryThread()) { throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) { @@ -38,15 +30,3 @@ index 7ce9ebba8ce304d1f3f21d4f15ee5f3560d7700b..6016c304ddbeb6ffbd591f30914c85fc for (RegisteredListener registration : listeners) { if (!registration.getPlugin().isEnabled()) { continue; -diff --git a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -index d17df5621717b1c8d1d9a5549feb73c3600ecf3d..ddbc37857bd2706844074925bc27b7a84efa5832 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/GlobalConfiguration.java -@@ -31,7 +31,6 @@ public class GlobalConfiguration extends ConfigurationPart { - @Override - public void postProcess() { - -- - } - - public boolean reduceCreateRandomInstance = DO_OPTIMIZE; diff --git a/patches/unapplied/server/0031-Optimize-Spigot-event-bus.patch b/patches/server/0031-Optimize-spigot-event-bus.patch similarity index 79% rename from patches/unapplied/server/0031-Optimize-Spigot-event-bus.patch rename to patches/server/0031-Optimize-spigot-event-bus.patch index 6335f3ee0..61f1859c6 100644 --- a/patches/unapplied/server/0031-Optimize-Spigot-event-bus.patch +++ b/patches/server/0031-Optimize-spigot-event-bus.patch @@ -1,23 +1,25 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: AlphaKR93 -Date: Sat, 30 Sep 2023 22:17:02 +0900 -Subject: [PATCH] Optimize Spigot event bus +Date: Tue, 7 Nov 2023 15:59:07 +0900 +Subject: [PATCH] Optimize spigot event bus diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -index 6016c304ddbeb6ffbd591f30914c85fcb6371e80..482e2cdbd4f76f2a56c62bec12bfc39d7193b6ce 100644 +index fb4135cb5d9e4162336c43d3b61c9d9a175a4dd5..b0ea2013433429cb0ae0314d8c483e4536a8d04f 100644 --- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -@@ -41,11 +41,14 @@ public class PaperEventManager { // Plazma - package -> public +@@ -40,13 +40,15 @@ class PaperEventManager { + HandlerList handlers = event.getHandlers(); RegisteredListener[] listeners = handlers.getRegisteredListeners(); if (listeners.length == 0) return; - // Plazma end +- // Plazma end + - if (event.isAsynchronous() && this.server.isPrimaryThread()) { - throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); - } else if (!event.isAsynchronous() && !this.server.isPrimaryThread() && !this.server.isStopping()) { - throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously."); -+ // Plazma start - Optimize Spigot event bus -+ if (event.asynchronous() != net.kyori.adventure.util.TriState.NOT_SET) { ++ // Optimize Spigot event bus ++ if (event.asynchronous() == net.kyori.adventure.util.TriState.NOT_SET) { + final boolean async = event.isAsynchronous(); + final boolean primary = this.server.isPrimaryThread(); + if (async && primary) throw new IllegalStateException(event.getEventName() + " may only be triggered asynchronously."); diff --git a/patches/unapplied/server/0024-Improve-biome-temperature-cache.patch b/patches/unapplied/server/0024-Improve-biome-temperature-cache.patch deleted file mode 100644 index 98b6241c3..000000000 --- a/patches/unapplied/server/0024-Improve-biome-temperature-cache.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Thu, 28 Sep 2023 12:33:14 +0900 -Subject: [PATCH] Improve biome temperature cache - - -diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java -index ed439b7e94646141c93a7dd3704d1cdeb5c27e16..71880b6fde3a287aa75c3799ffdd82a7943bb9db 100644 ---- a/src/main/java/net/minecraft/world/level/biome/Biome.java -+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java -@@ -67,7 +67,7 @@ public final class Biome { - private final MobSpawnSettings mobSettings; - private final BiomeSpecialEffects specialEffects; - // Pufferfish start - use our cache -- private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> { -+ private static final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> { // Plazma - Improve BiomeTemperatureCache - return Util.make(() -> { - /* - Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) { -@@ -125,7 +125,7 @@ public final class Biome { - public float getTemperature(BlockPos blockPos) { - long l = blockPos.asLong(); - // Pufferfish start -- gg.airplane.structs.Long2FloatAgingCache cache = this.temperatureCache.get(); -+ gg.airplane.structs.Long2FloatAgingCache cache = temperatureCache.get(); // Plazma - Improve BiomeTemperatureCache - float f = cache.getValue(l); - if (!Float.isNaN(f)) { - return f; diff --git a/patches/unapplied/server/0026-Configurable-sensor-tick.patch b/patches/unapplied/server/0026-Configurable-sensor-tick.patch deleted file mode 100644 index 780ba9a6a..000000000 --- a/patches/unapplied/server/0026-Configurable-sensor-tick.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: AlphaKR93 -Date: Fri, 29 Sep 2023 21:12:38 +0900 -Subject: [PATCH] Configurable sensor tick - - -diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index fb5c21ba15995d00da87ee6ef9e4ab8f6678d67f..4710f85197bc80e554cc1b2b84058c8dc8049c1f 100644 ---- a/src/main/java/net/minecraft/world/entity/Mob.java -+++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -938,10 +938,10 @@ public abstract class Mob extends LivingEntity implements Targeting { - } - // Paper end - //this.level().getProfiler().push("sensing"); // Purpur -- this.sensing.tick(); - //this.level().getProfiler().pop(); // Purpur - int i = this.level().getServer().getTickCount() + this.getId(); - -+ if (i % this.level().plazmaLevelConfiguration().entity.sensorTick == 0) this.sensing.tick(); // Plazma - moved down - if (i % 2 != 0 && this.tickCount > 1) { - //this.level().getProfiler().push("targetSelector"); // Purpur - if (this.targetSelector.inactiveTick(this.activatedPriority, false)) // Pufferfish - use this to alternate ticking -diff --git a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -index bb0f561f0b0d71697de52c834d2ed1798b2022df..6711b3d93eb5292314bcd89280d88f367eada9df 100644 ---- a/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -+++ b/src/main/java/org/plazmamc/plazma/configurations/LevelConfigurations.java -@@ -33,6 +33,8 @@ public class LevelConfigurations extends ConfigurationPart { - public Entity entity; - public class Entity extends ConfigurationPart { - -+ public int sensorTick = DO_OPTIMIZE ? 10 : 1; -+ - public boolean ignoreUselessPackets = DO_OPTIMIZE; - - public Player player;