From de6dfedfef7a4afa0ed0e77f094529601dcd0bba Mon Sep 17 00:00:00 2001 From: stonar96 Date: Tue, 9 Jun 2020 10:12:20 +0200 Subject: [PATCH] Make Anti-Xray multithreaded (#3520) Obfuscate multiple chunks at a time over the server thread pool. Will speed up chunk processing when anti xray is enabled. Co-authored-by: Aikar --- Spigot-Server-Patches/0384-Anti-Xray.patch | 95 ++++++++++--------- ...al-Spawned-mobs-towards-natural-spaw.patch | 6 +- ...gurable-projectile-relative-velocity.patch | 4 +- ...90-Asynchronous-chunk-IO-and-loading.patch | 4 +- ...etChunkIfLoadedImmediately-in-places.patch | 6 +- ...lement-alternative-item-despawn-rate.patch | 4 +- ...ement-optional-per-player-mob-spawns.patch | 6 +- .../0400-Generator-Settings.patch | 4 +- ...ro-tick-instant-grow-farms-MC-113809.patch | 6 +- ...d-option-to-disable-pillager-patrols.patch | 4 +- ...5656-Fix-Follow-Range-Initial-Target.patch | 4 +- .../0414-Optimize-Hoppers.patch | 8 +- ...n-to-nerf-pigmen-from-nether-portals.patch | 4 +- ...-chance-of-villager-zombie-infection.patch | 4 +- ...imise-TickListServer-by-rewriting-it.patch | 4 +- ...spawn-settings-and-per-player-option.patch | 4 +- .../0458-Increase-Light-Queue-Size.patch | 6 +- ...asks-Speed-up-processing-of-chunk-lo.patch | 4 +- ...ntom-creative-and-insomniac-controls.patch | 4 +- ...No-Tick-view-distance-implementation.patch | 6 +- ...and-End-Portal-Frames-from-being-des.patch | 2 +- ...unk-Unloads-based-on-Player-Movement.patch | 4 +- 22 files changed, 100 insertions(+), 93 deletions(-) diff --git a/Spigot-Server-Patches/0384-Anti-Xray.patch b/Spigot-Server-Patches/0384-Anti-Xray.patch index 5ffe1e8ca..47bca2c29 100644 --- a/Spigot-Server-Patches/0384-Anti-Xray.patch +++ b/Spigot-Server-Patches/0384-Anti-Xray.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 48676152152faf7a7b9524ac37d8b4a8c32c4e2c..ca2ac17747d4f2acf1df056759c5c182be050125 100644 +index 48676152152faf7a7b9524ac37d8b4a8c32c4e2c..f7c7c2871726e3a1673a693b9bd93910a28189b2 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -1,7 +1,9 @@ @@ -18,13 +18,12 @@ index 48676152152faf7a7b9524ac37d8b4a8c32c4e2c..ca2ac17747d4f2acf1df056759c5c182 import org.bukkit.Bukkit; import org.bukkit.configuration.file.YamlConfiguration; import org.spigotmc.SpigotWorldConfig; -@@ -502,4 +504,33 @@ public class PaperWorldConfig { +@@ -502,4 +504,31 @@ public class PaperWorldConfig { private void maxAutoSaveChunksPerTick() { maxAutoSaveChunksPerTick = getInt("max-auto-save-chunks-per-tick", 24); } + + public boolean antiXray; -+ public boolean asynchronous; + public EngineMode engineMode; + public int maxChunkSectionIndex; + public int updateRadius; @@ -32,7 +31,6 @@ index 48676152152faf7a7b9524ac37d8b4a8c32c4e2c..ca2ac17747d4f2acf1df056759c5c182 + public List replacementBlocks; + private void antiXray() { + antiXray = getBoolean("anti-xray.enabled", false); -+ asynchronous = true; + engineMode = EngineMode.getById(getInt("anti-xray.engine-mode", EngineMode.HIDE.getId())); + engineMode = engineMode == null ? EngineMode.HIDE : engineMode; + maxChunkSectionIndex = getInt("anti-xray.max-chunk-section-index", 3); @@ -100,18 +98,17 @@ index 0000000000000000000000000000000000000000..df7e4183d8842f5be8ae9d0698f8fa90 +} diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java new file mode 100644 -index 0000000000000000000000000000000000000000..9c017eb027ce52ea6a2414af2d0190b3bd52522c +index 0000000000000000000000000000000000000000..4ecd180fa84376319ef78bf9b21bf669b22ff817 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java -@@ -0,0 +1,628 @@ +@@ -0,0 +1,620 @@ +package com.destroystokyo.paper.antixray; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; -+import java.util.concurrent.ExecutorService; -+import java.util.concurrent.Executors; ++import java.util.concurrent.Executor; + +import net.minecraft.server.*; +import org.bukkit.Bukkit; @@ -121,9 +118,7 @@ index 0000000000000000000000000000000000000000..9c017eb027ce52ea6a2414af2d0190b3 + +public final class ChunkPacketBlockControllerAntiXray extends ChunkPacketBlockController { + -+ private static ExecutorService executorServiceInstance = null; -+ private final ExecutorService executorService; -+ private final boolean asynchronous; ++ private final Executor executor; + private final EngineMode engineMode; + private final int maxChunkSectionIndex; + private final int updateRadius; @@ -140,17 +135,12 @@ index 0000000000000000000000000000000000000000..9c017eb027ce52ea6a2414af2d0190b3 + private final ChunkSection[] emptyNearbyChunkSections = {Chunk.EMPTY_CHUNK_SECTION, Chunk.EMPTY_CHUNK_SECTION, Chunk.EMPTY_CHUNK_SECTION, Chunk.EMPTY_CHUNK_SECTION}; + private final int maxBlockYUpdatePosition; + -+ public ChunkPacketBlockControllerAntiXray(PaperWorldConfig paperWorldConfig) { -+ asynchronous = paperWorldConfig.asynchronous; ++ public ChunkPacketBlockControllerAntiXray(PaperWorldConfig paperWorldConfig, Executor executor) { + engineMode = paperWorldConfig.engineMode; + maxChunkSectionIndex = paperWorldConfig.maxChunkSectionIndex; + updateRadius = paperWorldConfig.updateRadius; + -+ if (asynchronous) { -+ executorService = getExecutorServiceInstance(); -+ } else { -+ executorService = null; -+ } ++ this.executor = executor; + + List toObfuscate; + @@ -216,12 +206,8 @@ index 0000000000000000000000000000000000000000..9c017eb027ce52ea6a2414af2d0190b3 + this.maxBlockYUpdatePosition = (maxChunkSectionIndex + 1) * 16 + updateRadius - 1; + } + -+ private static ExecutorService getExecutorServiceInstance() { -+ if (executorServiceInstance == null) { -+ executorServiceInstance = Executors.newSingleThreadExecutor(); -+ } -+ -+ return executorServiceInstance; ++ private int getPredefinedBlockDataLength() { ++ return engineMode == EngineMode.HIDE ? 1 : predefinedBlockData.length; + } + + @Override @@ -274,26 +260,30 @@ index 0000000000000000000000000000000000000000..9c017eb027ce52ea6a2414af2d0190b3 + (Chunk) world.getChunkIfLoadedImmediately(x, z - 1), + (Chunk) world.getChunkIfLoadedImmediately(x, z + 1)); + -+ if (asynchronous) { -+ executorService.submit((ChunkPacketInfoAntiXray) chunkPacketInfo); -+ } else { -+ obfuscate((ChunkPacketInfoAntiXray) chunkPacketInfo); -+ } ++ executor.execute((ChunkPacketInfoAntiXray) chunkPacketInfo); + } + -+ // Actually these fields should be variables inside the obfuscate method but in sync mode or with SingleThreadExecutor in async mode it's okay -+ private int[] predefinedBlockDataBits; -+ private final boolean[] solid = new boolean[Block.REGISTRY_ID.size()]; -+ private final boolean[] obfuscate = new boolean[Block.REGISTRY_ID.size()]; ++ // Actually these fields should be variables inside the obfuscate method but in sync mode or with SingleThreadExecutor in async mode it's okay (even without ThreadLocal) ++ // If an ExecutorService with multiple threads is used, ThreadLocal must be used here ++ private final ThreadLocal predefinedBlockDataBits = ThreadLocal.withInitial(() -> new int[getPredefinedBlockDataLength()]); ++ private static final ThreadLocal solid = ThreadLocal.withInitial(() -> new boolean[Block.REGISTRY_ID.size()]); ++ private static final ThreadLocal obfuscate = ThreadLocal.withInitial(() -> new boolean[Block.REGISTRY_ID.size()]); + // These boolean arrays represent chunk layers, true means don't obfuscate, false means obfuscate -+ private boolean[][] current = new boolean[16][16]; -+ private boolean[][] next = new boolean[16][16]; -+ private boolean[][] nextNext = new boolean[16][16]; -+ private final DataBitsReader dataBitsReader = new DataBitsReader(); -+ private final DataBitsWriter dataBitsWriter = new DataBitsWriter(); -+ private final ChunkSection[] nearbyChunkSections = new ChunkSection[4]; ++ private static final ThreadLocal current = ThreadLocal.withInitial(() -> new boolean[16][16]); ++ private static final ThreadLocal next = ThreadLocal.withInitial(() -> new boolean[16][16]); ++ private static final ThreadLocal nextNext = ThreadLocal.withInitial(() -> new boolean[16][16]); + + public void obfuscate(ChunkPacketInfoAntiXray chunkPacketInfoAntiXray) { ++ int[] predefinedBlockDataBits = this.predefinedBlockDataBits.get(); ++ boolean[] solid = this.solid.get(); ++ boolean[] obfuscate = this.obfuscate.get(); ++ boolean[][] current = this.current.get(); ++ boolean[][] next = this.next.get(); ++ boolean[][] nextNext = this.nextNext.get(); ++ // dataBitsReader, dataBitsWriter and nearbyChunkSections could also be reused (with ThreadLocal if necessary) but it's not worth it ++ DataBitsReader dataBitsReader = new DataBitsReader(); ++ DataBitsWriter dataBitsWriter = new DataBitsWriter(); ++ ChunkSection[] nearbyChunkSections = new ChunkSection[4]; + boolean[] solidTemp = null; + boolean[] obfuscateTemp = null; + dataBitsReader.setDataBits(chunkPacketInfoAntiXray.getData()); @@ -307,7 +297,7 @@ index 0000000000000000000000000000000000000000..9c017eb027ce52ea6a2414af2d0190b3 + if (chunkPacketInfoAntiXray.getDataPalette(chunkSectionIndex) == ChunkSection.GLOBAL_PALETTE) { + predefinedBlockDataBitsTemp = engineMode == EngineMode.HIDE ? chunkPacketInfoAntiXray.getChunk().world.getWorld().getEnvironment() == Environment.NETHER ? predefinedBlockDataBitsNetherrackGlobal : chunkPacketInfoAntiXray.getChunk().world.getWorld().getEnvironment() == Environment.THE_END ? predefinedBlockDataBitsEndStoneGlobal : predefinedBlockDataBitsStoneGlobal : predefinedBlockDataBitsGlobal; + } else { -+ predefinedBlockDataBitsTemp = predefinedBlockDataBits == null ? predefinedBlockDataBits = engineMode == EngineMode.HIDE ? new int[1] : new int[predefinedBlockData.length] : predefinedBlockDataBits; ++ predefinedBlockDataBitsTemp = predefinedBlockDataBits; + + for (int i = 0; i < predefinedBlockDataBitsTemp.length; i++) { + predefinedBlockDataBitsTemp[i] = chunkPacketInfoAntiXray.getDataPalette(chunkSectionIndex).getOrCreateIdFor(chunkPacketInfoAntiXray.getPredefinedObjects(chunkSectionIndex)[i]); @@ -1392,7 +1382,7 @@ index b740e82622e282bdf543a84a559af69dd5b8568c..6db6e74886943559e3582c350ffae548 } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 69db339c29c8f06026f05b0b5bb8019099af3fdf..4608d5f50d3c572f56bcc20dae2d537a07d05202 100644 +index 69db339c29c8f06026f05b0b5bb8019099af3fdf..479b87eaae67909768db1ba23854f05d2e61110c 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -2,6 +2,8 @@ package net.minecraft.server; @@ -1412,11 +1402,15 @@ index 69db339c29c8f06026f05b0b5bb8019099af3fdf..4608d5f50d3c572f56bcc20dae2d537a public final co.aikar.timings.WorldTimingsHandler timings; // Paper public static BlockPosition lastPhysicsProblem; // Spigot -@@ -119,6 +122,7 @@ public abstract class World implements GeneratorAccess, AutoCloseable { - protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { +@@ -116,9 +119,10 @@ public abstract class World implements GeneratorAccess, AutoCloseable { + return ((ChunkProviderServer) this.chunkProvider).getChunkAt(x, z, false); + } + +- protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { ++ protected World(WorldData worlddata, DimensionManager dimensionmanager, java.util.concurrent.Executor executor, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { // Paper - executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig( worlddata.getName() ); // Spigot this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(worlddata.getName(), this.spigotConfig); // Paper -+ this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this.paperConfig) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray ++ this.chunkPacketBlockController = this.paperConfig.antiXray ? new ChunkPacketBlockControllerAntiXray(this.paperConfig, executor) : ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray this.generator = gen; if (dimensionmanager.world == null) dimensionmanager.world = (WorldServer) this; // Paper this.world = new CraftWorld((WorldServer) this, gen, env); @@ -1428,6 +1422,19 @@ index 69db339c29c8f06026f05b0b5bb8019099af3fdf..4608d5f50d3c572f56bcc20dae2d537a if (iblockdata1 == null) { // CraftBukkit start - remove blockstate if failed (or the same) +diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java +index a0484d8062ecfb817cfd5b996915dc8f9a4eb2bd..c019f0287711f8301b47a3c8f3740ff2aecb998b 100644 +--- a/src/main/java/net/minecraft/server/WorldServer.java ++++ b/src/main/java/net/minecraft/server/WorldServer.java +@@ -84,7 +84,7 @@ public class WorldServer extends World { + + // Add env and gen to constructor + public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { +- super(worlddata, dimensionmanager, (world, worldprovider) -> { ++ super(worlddata, dimensionmanager, executor, (world, worldprovider) -> { // Paper - pass executor down + // CraftBukkit start + ChunkGenerator chunkGenerator; + diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java index a53bb7295c5d510f2976ff3787d68857548e11cc..47f1b970b9ba39f9050ac34a5ac15593c25f8a70 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java diff --git a/Spigot-Server-Patches/0385-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch b/Spigot-Server-Patches/0385-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch index 1fc40ddd1..29b06fd92 100644 --- a/Spigot-Server-Patches/0385-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch +++ b/Spigot-Server-Patches/0385-Only-count-Natural-Spawned-mobs-towards-natural-spaw.patch @@ -17,7 +17,7 @@ This should fully solve all of the issues around it so that only natural influences natural spawns. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index ca2ac17747d4f2acf1df056759c5c182be050125..a3fc76b512244ed6ca6b4d8f4babcb81f3cce226 100644 +index f7c7c2871726e3a1673a693b9bd93910a28189b2..e8e61ce505cafccb3c8338bc5bbdf941f903bb27 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -505,6 +505,16 @@ public class PaperWorldConfig { @@ -35,10 +35,10 @@ index ca2ac17747d4f2acf1df056759c5c182be050125..a3fc76b512244ed6ca6b4d8f4babcb81 + } + public boolean antiXray; - public boolean asynchronous; public EngineMode engineMode; + public int maxChunkSectionIndex; diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index a0484d8062ecfb817cfd5b996915dc8f9a4eb2bd..36a951cfcd617baf1a840f394e639567bd044308 100644 +index c019f0287711f8301b47a3c8f3740ff2aecb998b..702dcc0387f85ebae8f1cfe9a8e79affef24281b 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -960,6 +960,13 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/0386-Configurable-projectile-relative-velocity.patch b/Spigot-Server-Patches/0386-Configurable-projectile-relative-velocity.patch index b6fc52b54..73ac6c25e 100644 --- a/Spigot-Server-Patches/0386-Configurable-projectile-relative-velocity.patch +++ b/Spigot-Server-Patches/0386-Configurable-projectile-relative-velocity.patch @@ -25,10 +25,10 @@ P3) Solutions for 1) and especially 2) might not be future-proof, while this server-internal fix makes this change future-proof. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index a3fc76b512244ed6ca6b4d8f4babcb81f3cce226..90ba51e05bbed0366b43bc9315f6dfa9e39eee03 100644 +index e8e61ce505cafccb3c8338bc5bbdf941f903bb27..7101ef0912221bdb1c32d2cafbac5d9d53e7037d 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -543,4 +543,9 @@ public class PaperWorldConfig { +@@ -541,4 +541,9 @@ public class PaperWorldConfig { } log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks / Update Radius: " + updateRadius); } diff --git a/Spigot-Server-Patches/0390-Asynchronous-chunk-IO-and-loading.patch b/Spigot-Server-Patches/0390-Asynchronous-chunk-IO-and-loading.patch index 974ec152b..284ba1276 100644 --- a/Spigot-Server-Patches/0390-Asynchronous-chunk-IO-and-loading.patch +++ b/Spigot-Server-Patches/0390-Asynchronous-chunk-IO-and-loading.patch @@ -3933,7 +3933,7 @@ index c999f8c9bf8a59e19b3d6d1b7ad8b5fb6e48b928..1a5ec6152c15a6ece227d4bac00c3b02 HAS_SPACE(VillagePlaceRecord::d), IS_OCCUPIED(VillagePlaceRecord::e), ANY((villageplacerecord) -> { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 58018bfcee5396d440b0f022a7aa9ed452e67ec5..f84248ad9f90aaaf02afa35a4147fb11f703fdcb 100644 +index 83585f3ba7ef9e72f3702079a82f62c8b17e4077..83e6c872028107a17de1c08a5f6e8a02d62277ea 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -82,6 +82,79 @@ public class WorldServer extends World { @@ -4015,7 +4015,7 @@ index 58018bfcee5396d440b0f022a7aa9ed452e67ec5..f84248ad9f90aaaf02afa35a4147fb11 + // Add env and gen to constructor public WorldServer(MinecraftServer minecraftserver, Executor executor, WorldNBTStorage worldnbtstorage, WorldData worlddata, DimensionManager dimensionmanager, GameProfilerFiller gameprofilerfiller, WorldLoadListener worldloadlistener, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen) { - super(worlddata, dimensionmanager, (world, worldprovider) -> { + super(worlddata, dimensionmanager, executor, (world, worldprovider) -> { // Paper - pass executor down @@ -125,6 +198,8 @@ public class WorldServer extends World { this.mobSpawnerTrader = this.worldProvider.getDimensionManager().getType() == DimensionManager.OVERWORLD ? new MobSpawnerTrader(this) : null; // CraftBukkit - getType() diff --git a/Spigot-Server-Patches/0391-Use-getChunkIfLoadedImmediately-in-places.patch b/Spigot-Server-Patches/0391-Use-getChunkIfLoadedImmediately-in-places.patch index 333640ff6..eab049a61 100644 --- a/Spigot-Server-Patches/0391-Use-getChunkIfLoadedImmediately-in-places.patch +++ b/Spigot-Server-Patches/0391-Use-getChunkIfLoadedImmediately-in-places.patch @@ -8,7 +8,7 @@ ticket level 33 (yes getChunkIfLoaded will actually perform a chunk load in that case). diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index c626134752f685d6357f2ee4d4e9f64eb0dbb8bf..5d9bca7a87f463ede1ff0a478d5d6d524ccb877b 100644 +index 6a7bdf8c5f38ca4eb578e1104375e5773269330c..ee186ed5a076ede4d89702aeb5a2128d6e7ac8cf 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -996,7 +996,7 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -21,7 +21,7 @@ index c626134752f685d6357f2ee4d4e9f64eb0dbb8bf..5d9bca7a87f463ede1ff0a478d5d6d52 return; } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 7faaef50a5430c8bdf85ca0e37a4ad24ad56b1ef..21bb992cad2fd2692940ebe26360b8014c1df136 100644 +index 479b87eaae67909768db1ba23854f05d2e61110c..8e5c54af26d2c7abf2daae081af97caee7fd9f7a 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -116,8 +116,16 @@ public abstract class World implements GeneratorAccess, AutoCloseable { @@ -40,7 +40,7 @@ index 7faaef50a5430c8bdf85ca0e37a4ad24ad56b1ef..21bb992cad2fd2692940ebe26360b801 + + // Paper end - protected World(WorldData worlddata, DimensionManager dimensionmanager, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { + protected World(WorldData worlddata, DimensionManager dimensionmanager, java.util.concurrent.Executor executor, BiFunction bifunction, GameProfilerFiller gameprofilerfiller, boolean flag, org.bukkit.generator.ChunkGenerator gen, org.bukkit.World.Environment env) { // Paper - executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig( worlddata.getName() ); // Spigot @@ -1110,14 +1118,14 @@ public abstract class World implements GeneratorAccess, AutoCloseable { } diff --git a/Spigot-Server-Patches/0393-Implement-alternative-item-despawn-rate.patch b/Spigot-Server-Patches/0393-Implement-alternative-item-despawn-rate.patch index 0b1c7fb69..1479d5039 100644 --- a/Spigot-Server-Patches/0393-Implement-alternative-item-despawn-rate.patch +++ b/Spigot-Server-Patches/0393-Implement-alternative-item-despawn-rate.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Implement alternative item-despawn-rate diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 90ba51e05bbed0366b43bc9315f6dfa9e39eee03..b1d09eb457cfd1be7590f200abfa8cb2236600ef 100644 +index 7101ef0912221bdb1c32d2cafbac5d9d53e7037d..9b43b4172ae5df253479a412ec0d83fed08d70f1 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -1,10 +1,15 @@ @@ -24,7 +24,7 @@ index 90ba51e05bbed0366b43bc9315f6dfa9e39eee03..b1d09eb457cfd1be7590f200abfa8cb2 import org.bukkit.configuration.file.YamlConfiguration; import org.spigotmc.SpigotWorldConfig; -@@ -548,4 +553,52 @@ public class PaperWorldConfig { +@@ -546,4 +551,52 @@ public class PaperWorldConfig { private void disableRelativeProjectileVelocity() { disableRelativeProjectileVelocity = getBoolean("game-mechanics.disable-relative-projectile-velocity", false); } diff --git a/Spigot-Server-Patches/0396-implement-optional-per-player-mob-spawns.patch b/Spigot-Server-Patches/0396-implement-optional-per-player-mob-spawns.patch index a6e69fcda..de524d076 100644 --- a/Spigot-Server-Patches/0396-implement-optional-per-player-mob-spawns.patch +++ b/Spigot-Server-Patches/0396-implement-optional-per-player-mob-spawns.patch @@ -25,10 +25,10 @@ index 98acbfa44dd9042b26fdf719d7748f92d201c928..a94ebf7c76f167d3b66f7d243910c13d poiUnload = Timings.ofSafe(name + "Chunk unload - POI"); chunkUnload = Timings.ofSafe(name + "Chunk unload - Chunk"); diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index b1d09eb457cfd1be7590f200abfa8cb2236600ef..515673e0fec1dc5c8a188d594f5c9b698c47d0e1 100644 +index 9b43b4172ae5df253479a412ec0d83fed08d70f1..c148a57a9c3d44f2a0a2edfed4f96211745cc3e7 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -601,4 +601,9 @@ public class PaperWorldConfig { +@@ -599,4 +599,9 @@ public class PaperWorldConfig { } } } @@ -755,7 +755,7 @@ index fdac5bb3a2d4a73035e1d914979b87fc224b6b20..58bbf2f9d2ec91715051d40e108e1606 @Nullable diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 469f4e718ba123c65b9743877555f14d8d218589..1838add259a1a2919a80cc5d773ed89ed5d73c01 100644 +index 135d1211525f499198122e500626ce463c263088..80e2a15bebe93939dc7b43b17b8116965438c062 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1031,7 +1031,20 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/0400-Generator-Settings.patch b/Spigot-Server-Patches/0400-Generator-Settings.patch index 64f1d6e8b..2cbf2fe4f 100644 --- a/Spigot-Server-Patches/0400-Generator-Settings.patch +++ b/Spigot-Server-Patches/0400-Generator-Settings.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Generator Settings diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 515673e0fec1dc5c8a188d594f5c9b698c47d0e1..928fefb4195bd5d629b59b2b3c7d005b79bdf161 100644 +index c148a57a9c3d44f2a0a2edfed4f96211745cc3e7..62fe175dc4f00cc9cab6cbd828b57e25740b3793 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -606,4 +606,9 @@ public class PaperWorldConfig { +@@ -604,4 +604,9 @@ public class PaperWorldConfig { private void perPlayerMobSpawns() { perPlayerMobSpawns = getBoolean("per-player-mob-spawns", false); } diff --git a/Spigot-Server-Patches/0401-Fix-zero-tick-instant-grow-farms-MC-113809.patch b/Spigot-Server-Patches/0401-Fix-zero-tick-instant-grow-farms-MC-113809.patch index 2d1cb732f..4f8bf4281 100644 --- a/Spigot-Server-Patches/0401-Fix-zero-tick-instant-grow-farms-MC-113809.patch +++ b/Spigot-Server-Patches/0401-Fix-zero-tick-instant-grow-farms-MC-113809.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix zero-tick instant grow farms MC-113809 diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 928fefb4195bd5d629b59b2b3c7d005b79bdf161..442108555604b06c6217f4330c19b4997451126c 100644 +index 62fe175dc4f00cc9cab6cbd828b57e25740b3793..f6f5f9dea6284582e9a175c0875273ee1db76076 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -554,6 +554,11 @@ public class PaperWorldConfig { +@@ -552,6 +552,11 @@ public class PaperWorldConfig { disableRelativeProjectileVelocity = getBoolean("game-mechanics.disable-relative-projectile-velocity", false); } @@ -81,7 +81,7 @@ index 55b07444e1d769952f2a411b1b5d1032565af8a1..3bc3c5aa29f45cd2ee1c0401b1ee1b1d for (i = 1; worldserver.getType(blockposition.down(i)).getBlock() == this; ++i) { diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 1838add259a1a2919a80cc5d773ed89ed5d73c01..fe84d8b33733391cf58215d92f8f31d6ac107f0a 100644 +index 80e2a15bebe93939dc7b43b17b8116965438c062..3ecc73d021c09fbcad74dd62aced460771f86038 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -589,7 +589,9 @@ public class WorldServer extends World { diff --git a/Spigot-Server-Patches/0407-Add-option-to-disable-pillager-patrols.patch b/Spigot-Server-Patches/0407-Add-option-to-disable-pillager-patrols.patch index a70ca1aa8..2e175f197 100644 --- a/Spigot-Server-Patches/0407-Add-option-to-disable-pillager-patrols.patch +++ b/Spigot-Server-Patches/0407-Add-option-to-disable-pillager-patrols.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add option to disable pillager patrols diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 442108555604b06c6217f4330c19b4997451126c..1c703e48e99cd93be76bfeb0d9223507ba072b41 100644 +index f6f5f9dea6284582e9a175c0875273ee1db76076..19f355d00ebe7065ae2d2df8156ea4b6459a6598 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -616,4 +616,9 @@ public class PaperWorldConfig { +@@ -614,4 +614,9 @@ public class PaperWorldConfig { private void generatorSettings() { generateFlatBedrock = getBoolean("generator-settings.flat-bedrock", false); } diff --git a/Spigot-Server-Patches/0413-MC-145656-Fix-Follow-Range-Initial-Target.patch b/Spigot-Server-Patches/0413-MC-145656-Fix-Follow-Range-Initial-Target.patch index 3fb14c0a9..3494a9680 100644 --- a/Spigot-Server-Patches/0413-MC-145656-Fix-Follow-Range-Initial-Target.patch +++ b/Spigot-Server-Patches/0413-MC-145656-Fix-Follow-Range-Initial-Target.patch @@ -5,10 +5,10 @@ Subject: [PATCH] MC-145656 Fix Follow Range Initial Target diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 1c703e48e99cd93be76bfeb0d9223507ba072b41..e89ad807ed96205a7bf1110d849c3459a995188d 100644 +index 19f355d00ebe7065ae2d2df8156ea4b6459a6598..a26848df994ffb0dc02d6a6051971439613dd0ba 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -621,4 +621,9 @@ public class PaperWorldConfig { +@@ -619,4 +619,9 @@ public class PaperWorldConfig { private void pillagerSettings() { disablePillagerPatrols = getBoolean("game-mechanics.disable-pillager-patrols", disablePillagerPatrols); } diff --git a/Spigot-Server-Patches/0414-Optimize-Hoppers.patch b/Spigot-Server-Patches/0414-Optimize-Hoppers.patch index 64062d35f..ad789cfbc 100644 --- a/Spigot-Server-Patches/0414-Optimize-Hoppers.patch +++ b/Spigot-Server-Patches/0414-Optimize-Hoppers.patch @@ -13,10 +13,10 @@ Subject: [PATCH] Optimize Hoppers * Remove Streams from Item Suck In and restore restore 1.12 AABB checks which is simpler and no voxel allocations (was doing TWO Item Suck ins) diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index e89ad807ed96205a7bf1110d849c3459a995188d..fca4b6e20ab407ecaef3c5909c3d5e23a944e01b 100644 +index a26848df994ffb0dc02d6a6051971439613dd0ba..cab503bd5c34d12b38a2f5deed6d3feb9287b370 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -626,4 +626,13 @@ public class PaperWorldConfig { +@@ -624,4 +624,13 @@ public class PaperWorldConfig { private void entitiesTargetWithFollowRange() { entitiesTargetWithFollowRange = getBoolean("entities-target-with-follow-range", entitiesTargetWithFollowRange); } @@ -73,7 +73,7 @@ index d953cdef14a9b62833a35a4fe94a22b5e9b19c2d..d6e43313bf0c678cf78fe77de2f8f4b6 itemstack.d(this.C()); if (this.tag != null) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index aadc4635ecef4e5ba19ff56c37ecbdc5a1721ec6..e9c3d1507317e38272305e157e889a033c5d2803 100644 +index 9450e27e5ce9295d87b95be2797fc27984ca2b0b..8c08a542a97edd76c07ef7d64834bdbd70345876 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -1222,6 +1222,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant { + super(worlddata, dimensionmanager, executor, (world, worldprovider) -> { // Paper - pass executor down @@ -190,12 +199,22 @@ public class WorldServer extends World { this.pvpMode = minecraftserver.getPVP(); worlddata.world = this; diff --git a/Spigot-Server-Patches/0447-Pillager-patrol-spawn-settings-and-per-player-option.patch b/Spigot-Server-Patches/0447-Pillager-patrol-spawn-settings-and-per-player-option.patch index affb4b9a6..3ceb2620f 100644 --- a/Spigot-Server-Patches/0447-Pillager-patrol-spawn-settings-and-per-player-option.patch +++ b/Spigot-Server-Patches/0447-Pillager-patrol-spawn-settings-and-per-player-option.patch @@ -10,10 +10,10 @@ When not per player it will use the Vanilla mechanic of one delay per world and the world age for the start day. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index c3af4c9a9fe67b7a9c0eda5606e1c97bad778927..3f44be577e32af4122b2c8b6c2849e650f4541f5 100644 +index 0ff4475625e93d6f7a41345149e7c1fed0220bbb..598f27bc1b95132ded224dd5c7a0e2639ab2bd12 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -629,10 +629,21 @@ public class PaperWorldConfig { +@@ -627,10 +627,21 @@ public class PaperWorldConfig { } public boolean disablePillagerPatrols = false; diff --git a/Spigot-Server-Patches/0458-Increase-Light-Queue-Size.patch b/Spigot-Server-Patches/0458-Increase-Light-Queue-Size.patch index 2eca33383..7ad92c02d 100644 --- a/Spigot-Server-Patches/0458-Increase-Light-Queue-Size.patch +++ b/Spigot-Server-Patches/0458-Increase-Light-Queue-Size.patch @@ -14,10 +14,10 @@ light engine on shutdown... The queue size only puts a cap on max loss, doesn't solve that problem. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 3f44be577e32af4122b2c8b6c2849e650f4541f5..a4815f5e69c00c4471bf7354222d9cf175ceafcd 100644 +index 598f27bc1b95132ded224dd5c7a0e2639ab2bd12..ea5f306ef57fe5958a554f4bdf866a36d2b185e0 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -@@ -667,4 +667,9 @@ public class PaperWorldConfig { +@@ -665,4 +665,9 @@ public class PaperWorldConfig { private void zombieVillagerInfectionChance() { zombieVillagerInfectionChance = getDouble("zombie-villager-infection-chance", zombieVillagerInfectionChance); } @@ -28,7 +28,7 @@ index 3f44be577e32af4122b2c8b6c2849e650f4541f5..a4815f5e69c00c4471bf7354222d9cf1 + } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index dcc5781d99d760e1d1fe6194db8fd49b23091404..f9faa30ef914b1dd2dada9b7d89e80b34d2f1d0d 100644 +index 234c6f1854d4a491f6233fbd4677719a0503d3a1..508aa4866e47f3865a8c51f7c8e3b842be216923 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -637,7 +637,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant