From b81fffb934690e6733a69b8ad755e4d0d89498c9 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 15 Jun 2024 19:24:11 +0200 Subject: [PATCH] Add back more optimization patches --- .../server/API-for-checking-sent-chunks.patch | 19 ++++---- ...nate-Current-redstone-implementation.patch | 10 ++-- ...lementation-for-blockstate-state-loo.patch | 0 .../Eigencraft-redstone-implementation.patch | 0 ...y-type-tags-suggestions-in-selectors.patch | 2 +- ...e-Oversized-block-entities-in-chunks.patch | 0 ...ng-PreCreatureSpawnEvent-with-per-pl.patch | 8 ++-- .../Optimize-Bit-Operations-by-inlining.patch | 0 ...oalSelector-Goal.Flag-Set-operations.patch | 0 .../server/Optimize-Hoppers.patch | 0 ...der-Remove-Streams-Optimized-collect.patch | 0 .../server/Optimize-Voxel-Shape-Merging.patch | 0 .../server/Remove-streams-from-hot-code.patch | 0 ...ocity-compression-and-cipher-natives.patch | 4 +- patches/server/stubs.patch | 48 ------------------- 15 files changed, 21 insertions(+), 70 deletions(-) rename patches/{unapplied => }/server/API-for-checking-sent-chunks.patch (72%) rename patches/{unapplied => }/server/Add-Alternate-Current-redstone-implementation.patch (99%) rename patches/{unapplied => }/server/Custom-table-implementation-for-blockstate-state-loo.patch (100%) rename patches/{unapplied => }/server/Eigencraft-redstone-implementation.patch (100%) rename patches/{unapplied => }/server/Fix-entity-type-tags-suggestions-in-selectors.patch (97%) rename patches/{unapplied => }/server/Handle-Oversized-block-entities-in-chunks.patch (100%) rename patches/{unapplied => }/server/Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch (96%) rename patches/{unapplied => }/server/Optimize-Bit-Operations-by-inlining.patch (100%) rename patches/{unapplied => }/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch (100%) rename patches/{unapplied => }/server/Optimize-Hoppers.patch (100%) rename patches/{unapplied => }/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch (100%) rename patches/{unapplied => }/server/Optimize-Voxel-Shape-Merging.patch (100%) rename patches/{unapplied => }/server/Remove-streams-from-hot-code.patch (100%) rename patches/{unapplied => }/server/Use-Velocity-compression-and-cipher-natives.patch (99%) delete mode 100644 patches/server/stubs.patch diff --git a/patches/unapplied/server/API-for-checking-sent-chunks.patch b/patches/server/API-for-checking-sent-chunks.patch similarity index 72% rename from patches/unapplied/server/API-for-checking-sent-chunks.patch rename to patches/server/API-for-checking-sent-chunks.patch index 6f444e2fd1..516805afe7 100644 --- a/patches/unapplied/server/API-for-checking-sent-chunks.patch +++ b/patches/server/API-for-checking-sent-chunks.patch @@ -4,11 +4,11 @@ Date: Mon, 8 Apr 2024 16:43:16 +0200 Subject: [PATCH] API for checking sent chunks -diff --git a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java +diff --git a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java -+++ b/src/main/java/io/papermc/paper/chunk/system/RegionizedPlayerChunkLoader.java -@@ -0,0 +0,0 @@ public class RegionizedPlayerChunkLoader { +--- a/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java ++++ b/src/main/java/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java +@@ -0,0 +0,0 @@ public final class RegionizedPlayerChunkLoader { // now all tickets should be removed, which is all of our external state } @@ -18,8 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return this.sentChunks; + } } - - // TODO rebase into util patch + } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -33,18 +32,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public Set getSentChunkKeys() { + org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks"); + return it.unimi.dsi.fastutil.longs.LongSets.unmodifiable( -+ this.getHandle().chunkLoader.getSentChunksRaw().clone() ++ this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().clone() + ); + } + + @Override + public Set getSentChunks() { + org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks"); -+ final it.unimi.dsi.fastutil.longs.LongOpenHashSet rawChunkKeys = this.getHandle().chunkLoader.getSentChunksRaw(); ++ final it.unimi.dsi.fastutil.longs.LongOpenHashSet rawChunkKeys = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw(); + final it.unimi.dsi.fastutil.objects.ObjectOpenHashSet chunks = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>(rawChunkKeys.size()); + final org.bukkit.World world = this.getWorld(); + -+ final it.unimi.dsi.fastutil.longs.LongIterator iter = this.getHandle().chunkLoader.getSentChunksRaw().longIterator(); ++ final it.unimi.dsi.fastutil.longs.LongIterator iter = this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().longIterator(); + while (iter.hasNext()) chunks.add(world.getChunkAt(iter.nextLong(), false)); + + return it.unimi.dsi.fastutil.objects.ObjectSets.unmodifiable(chunks); @@ -53,7 +52,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Override + public boolean isChunkSent(final long chunkKey) { + org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks"); -+ return this.getHandle().chunkLoader.getSentChunksRaw().contains(chunkKey); ++ return this.getHandle().moonrise$getChunkLoader().getSentChunksRaw().contains(chunkKey); + } + // Paper end + diff --git a/patches/unapplied/server/Add-Alternate-Current-redstone-implementation.patch b/patches/server/Add-Alternate-Current-redstone-implementation.patch similarity index 99% rename from patches/unapplied/server/Add-Alternate-Current-redstone-implementation.patch rename to patches/server/Add-Alternate-Current-redstone-implementation.patch index 40d6619a4f..783e5c9764 100644 --- a/patches/unapplied/server/Add-Alternate-Current-redstone-implementation.patch +++ b/patches/server/Add-Alternate-Current-redstone-implementation.patch @@ -2012,7 +2012,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/mai index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. public final UUID uuid; public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent @@ -2020,7 +2020,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public LevelChunk getChunkIfLoaded(int x, int z) { return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately -@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -0,0 +0,0 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. return crashreportsystemdetails; } @@ -2038,10 +2038,10 @@ diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/ index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - return ret; +@@ -0,0 +0,0 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + } } - // Paper end + // Paper end - notify observers even if grow failed + // Paper start - optimize redstone (Alternate Current) + public alternate.current.wire.WireHandler getWireHandler() { + // This method is overridden in ServerLevel. diff --git a/patches/unapplied/server/Custom-table-implementation-for-blockstate-state-loo.patch b/patches/server/Custom-table-implementation-for-blockstate-state-loo.patch similarity index 100% rename from patches/unapplied/server/Custom-table-implementation-for-blockstate-state-loo.patch rename to patches/server/Custom-table-implementation-for-blockstate-state-loo.patch diff --git a/patches/unapplied/server/Eigencraft-redstone-implementation.patch b/patches/server/Eigencraft-redstone-implementation.patch similarity index 100% rename from patches/unapplied/server/Eigencraft-redstone-implementation.patch rename to patches/server/Eigencraft-redstone-implementation.patch diff --git a/patches/unapplied/server/Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch similarity index 97% rename from patches/unapplied/server/Fix-entity-type-tags-suggestions-in-selectors.patch rename to patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch index 18aaa7a545..d47499b76e 100644 --- a/patches/unapplied/server/Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch @@ -39,7 +39,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/commands/Commands.java +++ b/src/main/java/net/minecraft/commands/Commands.java @@ -0,0 +0,0 @@ public class Commands { - private void fillUsableCommands(CommandNode tree, CommandNode result, CommandSourceStack source, Map, CommandNode> resultNodes) { + resultNodes.keySet().removeIf((node) -> !org.spigotmc.SpigotConfig.sendNamespaced && node.getName().contains( ":" )); // Paper - Remove namedspaced from result nodes to prevent redirect trimming ~ see comment below Iterator iterator = tree.getChildren().iterator(); + boolean registeredAskServerSuggestionsForTree = false; // Paper - tell clients to ask server for suggestions for EntityArguments diff --git a/patches/unapplied/server/Handle-Oversized-block-entities-in-chunks.patch b/patches/server/Handle-Oversized-block-entities-in-chunks.patch similarity index 100% rename from patches/unapplied/server/Handle-Oversized-block-entities-in-chunks.patch rename to patches/server/Handle-Oversized-block-entities-in-chunks.patch diff --git a/patches/unapplied/server/Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/patches/server/Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch similarity index 96% rename from patches/unapplied/server/Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch rename to patches/server/Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch index dc8263f9a1..e9945140c8 100644 --- a/patches/unapplied/server/Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch +++ b/patches/server/Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch @@ -10,9 +10,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java @@ -0,0 +0,0 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + ++((ServerPlayer)backingSet[i]).mobCounts[index]; } } - + // Paper start - per player mob count backoff + public void updateFailurePlayerMobTypeMap(int chunkX, int chunkZ, net.minecraft.world.entity.MobCategory mobCategory) { + if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { @@ -33,9 +33,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public int getMobCountNear(final ServerPlayer player, final net.minecraft.world.entity.MobCategory mobCategory) { - return player.mobCounts[mobCategory.ordinal()]; + return player.mobCounts[mobCategory.ordinal()] + player.mobBackoffCounts[mobCategory.ordinal()]; // Paper - per player mob count backoff + // Paper end - Optional per player mob spawns } - // Paper end - Optional per player mob spawns - + // Paper end diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java @@ -63,7 +63,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -0,0 +0,0 @@ public class ServerPlayer extends Player { +@@ -0,0 +0,0 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper // Paper end - Optional per player mob spawns diff --git a/patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch b/patches/server/Optimize-Bit-Operations-by-inlining.patch similarity index 100% rename from patches/unapplied/server/Optimize-Bit-Operations-by-inlining.patch rename to patches/server/Optimize-Bit-Operations-by-inlining.patch diff --git a/patches/unapplied/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch b/patches/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch similarity index 100% rename from patches/unapplied/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch rename to patches/server/Optimize-GoalSelector-Goal.Flag-Set-operations.patch diff --git a/patches/unapplied/server/Optimize-Hoppers.patch b/patches/server/Optimize-Hoppers.patch similarity index 100% rename from patches/unapplied/server/Optimize-Hoppers.patch rename to patches/server/Optimize-Hoppers.patch diff --git a/patches/unapplied/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch b/patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch similarity index 100% rename from patches/unapplied/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch rename to patches/server/Optimize-Pathfinder-Remove-Streams-Optimized-collect.patch diff --git a/patches/unapplied/server/Optimize-Voxel-Shape-Merging.patch b/patches/server/Optimize-Voxel-Shape-Merging.patch similarity index 100% rename from patches/unapplied/server/Optimize-Voxel-Shape-Merging.patch rename to patches/server/Optimize-Voxel-Shape-Merging.patch diff --git a/patches/unapplied/server/Remove-streams-from-hot-code.patch b/patches/server/Remove-streams-from-hot-code.patch similarity index 100% rename from patches/unapplied/server/Remove-streams-from-hot-code.patch rename to patches/server/Remove-streams-from-hot-code.patch diff --git a/patches/unapplied/server/Use-Velocity-compression-and-cipher-natives.patch b/patches/server/Use-Velocity-compression-and-cipher-natives.patch similarity index 99% rename from patches/unapplied/server/Use-Velocity-compression-and-cipher-natives.patch rename to patches/server/Use-Velocity-compression-and-cipher-natives.patch index f2efb316c2..c25be596b4 100644 --- a/patches/unapplied/server/Use-Velocity-compression-and-cipher-natives.patch +++ b/patches/server/Use-Velocity-compression-and-cipher-natives.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -0,0 +0,0 @@ dependencies { - runtimeOnly("org.xerial:sqlite-jdbc:3.45.3.0") - runtimeOnly("com.mysql:mysql-connector-j:8.3.0") + runtimeOnly("org.xerial:sqlite-jdbc:3.46.0.0") + runtimeOnly("com.mysql:mysql-connector-j:8.4.0") runtimeOnly("com.lmax:disruptor:3.4.4") // Paper + // Paper start - Use Velocity cipher + implementation("com.velocitypowered:velocity-native:3.1.2-SNAPSHOT") { diff --git a/patches/server/stubs.patch b/patches/server/stubs.patch deleted file mode 100644 index 83ed687cab..0000000000 --- a/patches/server/stubs.patch +++ /dev/null @@ -1,48 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Nassim Jahnke -Date: Fri, 14 Jun 2024 17:19:59 +0200 -Subject: [PATCH] stubs - - -diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -0,0 +0,0 @@ import net.minecraft.world.level.saveddata.maps.MapItemSavedData; - import org.bukkit.BanEntry; - import org.bukkit.BanList; - import org.bukkit.Bukkit; -+import org.bukkit.Chunk; - import org.bukkit.DyeColor; - import org.bukkit.Effect; - import org.bukkit.GameMode; -@@ -0,0 +0,0 @@ import org.bukkit.scoreboard.Scoreboard; - import org.jetbrains.annotations.NotNull; - - import net.md_5.bungee.api.chat.BaseComponent; // Spigot -+import org.jetbrains.annotations.Unmodifiable; - - @DelegateDeserialization(CraftOfflinePlayer.class) - public class CraftPlayer extends CraftHumanEntity implements Player { -@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - public void resetIdleDuration() { - this.getHandle().resetLastActionTime(); - } -+ -+ @Override -+ public @NotNull @Unmodifiable Set getSentChunkKeys() { -+ throw new UnsupportedOperationException("Not implemented yet"); -+ } -+ -+ @Override -+ public @NotNull @Unmodifiable Set getSentChunks() { -+ throw new UnsupportedOperationException("Not implemented yet"); -+ } -+ -+ @Override -+ public boolean isChunkSent(final long chunkKey) { -+ throw new UnsupportedOperationException("Not implemented yet"); -+ } - // Paper end - - public Player.Spigot spigot()