From e2b233206297e40b6f14310856c2d35023f8537e Mon Sep 17 00:00:00 2001 From: stonar96 Date: Sun, 22 Apr 2018 16:45:56 +0200 Subject: [PATCH] Make Anti-Xray Update Radius configurable (#1094) --- Spigot-Server-Patches/Anti-Xray.patch | 73 +++++++++++-------- ...urable-Chunks-Sends-per-Tick-setting.patch | 2 +- ...Configurable-Max-Chunk-Gens-per-Tick.patch | 2 +- ...urable-sprint-interruption-on-attack.patch | 4 +- ...-max-squid-spawn-height-configurable.patch | 2 +- Spigot-Server-Patches/Optimize-Hoppers.patch | 2 +- ...-maximum-exp-value-when-merging-orbs.patch | 6 +- ...GOT-3894-to-restore-vanilla-behavior.patch | 26 +++++++ ...r-reloading-of-pending-unload-chunks.patch | 23 ++++++ 9 files changed, 102 insertions(+), 38 deletions(-) create mode 100644 Spigot-Server-Patches/Revert-SPIGOT-3894-to-restore-vanilla-behavior.patch create mode 100644 Spigot-Server-Patches/revert-Better-reloading-of-pending-unload-chunks.patch diff --git a/Spigot-Server-Patches/Anti-Xray.patch b/Spigot-Server-Patches/Anti-Xray.patch index 3b986178ab..97e5cb4bfb 100644 --- a/Spigot-Server-Patches/Anti-Xray.patch +++ b/Spigot-Server-Patches/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 7802cc1f..69fd8189 100644 +index 7802cc1f..30307da0 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ @@ -29,6 +29,7 @@ index 7802cc1f..69fd8189 100644 + public EngineMode engineMode; + public ChunkEdgeMode chunkEdgeMode; + public int maxChunkSectionIndex; ++ public int updateRadius; + public List hiddenBlocks; + public List replacementBlocks; + private void antiXray() { @@ -40,9 +41,10 @@ index 7802cc1f..69fd8189 100644 + chunkEdgeMode = chunkEdgeMode == null ? ChunkEdgeMode.DEFAULT : chunkEdgeMode; + maxChunkSectionIndex = getInt("anti-xray.max-chunk-section-index", 3); + maxChunkSectionIndex = maxChunkSectionIndex > 15 ? 15 : maxChunkSectionIndex; ++ updateRadius = getInt("anti-xray.update-radius", 2); + hiddenBlocks = getList("anti-xray.hidden-blocks", Arrays.asList((Object) "gold_ore", "iron_ore", "coal_ore", "lapis_ore", "mossy_cobblestone", "obsidian", "chest", "diamond_ore", "redstone_ore", "lit_redstone_ore", "clay", "emerald_ore", "ender_chest")); + replacementBlocks = getList("anti-xray.replacement-blocks", Arrays.asList((Object) "stone", "planks")); -+ log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Chunk Edge Mode: " + chunkEdgeMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks"); ++ log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Chunk Edge Mode: " + chunkEdgeMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks / Update Radius: " + updateRadius); + } } diff --git a/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockController.java @@ -89,7 +91,7 @@ index 00000000..6833cfad +} 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 00000000..91fa945f +index 00000000..2dc0655a --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/antixray/ChunkPacketBlockControllerAntiXray.java @@ -0,0 +0,0 @@ @@ -124,6 +126,7 @@ index 00000000..91fa945f + private final EngineMode engineMode; + private final ChunkEdgeMode chunkEdgeMode; + private final int maxChunkSectionIndex; ++ private final int updateRadius; + private final IBlockData[] predefinedBlockData; + private final IBlockData[] predefinedBlockDataStone; + private final IBlockData[] predefinedBlockDataNetherrack; @@ -142,6 +145,7 @@ index 00000000..91fa945f + engineMode = paperWorldConfig.engineMode; + chunkEdgeMode = paperWorldConfig.chunkEdgeMode; + maxChunkSectionIndex = paperWorldConfig.maxChunkSectionIndex; ++ updateRadius = paperWorldConfig.updateRadius; + + if (asynchronous) { + executorService = getExecutorServiceInstance(); @@ -618,31 +622,42 @@ index 00000000..91fa945f + + @Override + public void updateNearbyBlocks(World world, BlockPosition blockPosition) { -+ BlockPosition temp = blockPosition.west(); -+ updateBlock(world, temp); -+ updateBlock(world, temp.west()); -+ updateBlock(world, temp.down()); -+ updateBlock(world, temp.up()); -+ updateBlock(world, temp.north()); -+ updateBlock(world, temp.south()); -+ updateBlock(world, temp = blockPosition.east()); -+ updateBlock(world, temp.east()); -+ updateBlock(world, temp.down()); -+ updateBlock(world, temp.up()); -+ updateBlock(world, temp.north()); -+ updateBlock(world, temp.south()); -+ updateBlock(world, temp = blockPosition.down()); -+ updateBlock(world, temp.down()); -+ updateBlock(world, temp.north()); -+ updateBlock(world, temp.south()); -+ updateBlock(world, temp = blockPosition.up()); -+ updateBlock(world, temp.up()); -+ updateBlock(world, temp.north()); -+ updateBlock(world, temp.south()); -+ updateBlock(world, temp = blockPosition.north()); -+ updateBlock(world, temp.north()); -+ updateBlock(world, temp = blockPosition.south()); -+ updateBlock(world, temp.south()); ++ if (updateRadius >= 2) { ++ BlockPosition temp = blockPosition.west(); ++ updateBlock(world, temp); ++ updateBlock(world, temp.west()); ++ updateBlock(world, temp.down()); ++ updateBlock(world, temp.up()); ++ updateBlock(world, temp.north()); ++ updateBlock(world, temp.south()); ++ updateBlock(world, temp = blockPosition.east()); ++ updateBlock(world, temp.east()); ++ updateBlock(world, temp.down()); ++ updateBlock(world, temp.up()); ++ updateBlock(world, temp.north()); ++ updateBlock(world, temp.south()); ++ updateBlock(world, temp = blockPosition.down()); ++ updateBlock(world, temp.down()); ++ updateBlock(world, temp.north()); ++ updateBlock(world, temp.south()); ++ updateBlock(world, temp = blockPosition.up()); ++ updateBlock(world, temp.up()); ++ updateBlock(world, temp.north()); ++ updateBlock(world, temp.south()); ++ updateBlock(world, temp = blockPosition.north()); ++ updateBlock(world, temp.north()); ++ updateBlock(world, temp = blockPosition.south()); ++ updateBlock(world, temp.south()); ++ } else if (updateRadius == 1) { ++ updateBlock(world, blockPosition.west()); ++ updateBlock(world, blockPosition.east()); ++ updateBlock(world, blockPosition.down()); ++ updateBlock(world, blockPosition.up()); ++ updateBlock(world, blockPosition.north()); ++ updateBlock(world, blockPosition.south()); ++ } else { ++ //Do nothing if updateRadius <= 0 (test mode) ++ } + } + + private void updateBlock(World world, BlockPosition blockPosition) { @@ -1502,7 +1517,7 @@ index 8860a012..fa0d66d6 100644 return this.a.size(); } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 00513d02..592e5b3b 100644 +index 137c2555..75d5451c 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ import org.bukkit.generator.ChunkGenerator; diff --git a/Spigot-Server-Patches/Configurable-Chunks-Sends-per-Tick-setting.patch b/Spigot-Server-Patches/Configurable-Chunks-Sends-per-Tick-setting.patch index fafb1971a0..1e0992ea53 100644 --- a/Spigot-Server-Patches/Configurable-Chunks-Sends-per-Tick-setting.patch +++ b/Spigot-Server-Patches/Configurable-Chunks-Sends-per-Tick-setting.patch @@ -8,7 +8,7 @@ Vanilla already had this limited, make it configurable. Limit how much exploration lags the server diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index e6ee13ee..8949b029 100644 +index a3119cd1..259f5c70 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { diff --git a/Spigot-Server-Patches/Configurable-Max-Chunk-Gens-per-Tick.patch b/Spigot-Server-Patches/Configurable-Max-Chunk-Gens-per-Tick.patch index a9cd9cc923..e31402fd5c 100644 --- a/Spigot-Server-Patches/Configurable-Max-Chunk-Gens-per-Tick.patch +++ b/Spigot-Server-Patches/Configurable-Max-Chunk-Gens-per-Tick.patch @@ -13,7 +13,7 @@ This should result in no noticeable speed reduction in generation for servers no lagging, and let larger servers reduce this value according to their own desires. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 8949b029..cd036b44 100644 +index 259f5c70..3df3b433 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { diff --git a/Spigot-Server-Patches/Configurable-sprint-interruption-on-attack.patch b/Spigot-Server-Patches/Configurable-sprint-interruption-on-attack.patch index 3a7a02a615..db3561f64c 100644 --- a/Spigot-Server-Patches/Configurable-sprint-interruption-on-attack.patch +++ b/Spigot-Server-Patches/Configurable-sprint-interruption-on-attack.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Configurable sprint interruption on attack If the sprint interruption is disabled players continue sprinting when they attack entities. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 038f874b3..c903c89cf 100644 +index 7a03f885..9ef2b163 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -20,7 +20,7 @@ index 038f874b3..c903c89cf 100644 + } } diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java -index 35fde8b23..0b51903e2 100644 +index 35fde8b2..0b51903e 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving { diff --git a/Spigot-Server-Patches/Make-max-squid-spawn-height-configurable.patch b/Spigot-Server-Patches/Make-max-squid-spawn-height-configurable.patch index 5862fd3a49..ed4f3133c9 100644 --- a/Spigot-Server-Patches/Make-max-squid-spawn-height-configurable.patch +++ b/Spigot-Server-Patches/Make-max-squid-spawn-height-configurable.patch @@ -7,7 +7,7 @@ I don't know why upstream made only the minimum height configurable but whatever diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index cd036b44..1947f246 100644 +index 3df3b433..be4431c1 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { diff --git a/Spigot-Server-Patches/Optimize-Hoppers.patch b/Spigot-Server-Patches/Optimize-Hoppers.patch index aaf17866e8..949c2f072c 100644 --- a/Spigot-Server-Patches/Optimize-Hoppers.patch +++ b/Spigot-Server-Patches/Optimize-Hoppers.patch @@ -11,7 +11,7 @@ Subject: [PATCH] Optimize Hoppers * Skip subsequent InventoryMoveItemEvents if a plugin does not use the item after first event fire for an iteration diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 1947f246..61cc1d4e 100644 +index be4431c1..9d2fe4a8 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { diff --git a/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch b/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch index 0080622215..e27719d43a 100644 --- a/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch +++ b/Spigot-Server-Patches/Option-for-maximum-exp-value-when-merging-orbs.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Option for maximum exp value when merging orbs diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 69fd8189..e6ee13ee 100644 +index 30307da0..a3119cd1 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { replacementBlocks = getList("anti-xray.replacement-blocks", Arrays.asList((Object) "stone", "planks")); - log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Chunk Edge Mode: " + chunkEdgeMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks"); + log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Chunk Edge Mode: " + chunkEdgeMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks / Update Radius: " + updateRadius); } + + public int expMergeMaxValue; @@ -20,7 +20,7 @@ index 69fd8189..e6ee13ee 100644 + } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index d45cbf2f..0193364d 100644 +index a4bdaa71..362f0545 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java @@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { diff --git a/Spigot-Server-Patches/Revert-SPIGOT-3894-to-restore-vanilla-behavior.patch b/Spigot-Server-Patches/Revert-SPIGOT-3894-to-restore-vanilla-behavior.patch new file mode 100644 index 0000000000..944f53b004 --- /dev/null +++ b/Spigot-Server-Patches/Revert-SPIGOT-3894-to-restore-vanilla-behavior.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Wed, 18 Apr 2018 01:42:42 -0400 +Subject: [PATCH] Revert SPIGOT-3894 to restore vanilla behavior + +reporter of this issue was incorrect and did not verify vanilla logic + +vanilla logic only skips ticks if the flag is set + +spigots change causes bugs as it now skips ticking and processing +chunk teleportation, which was a bug I fixed many many years ago... + +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java +index 4ce846b5..6c92f93a 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess { + // CraftBukkit end + + // Spigot start +- if (!org.spigotmc.ActivationRange.checkIfActive(entity)) { ++ if (flag && !org.spigotmc.ActivationRange.checkIfActive(entity)) { // Paper - Revert spigot change back to vanilla + entity.ticksLived++; + entity.inactiveTick(); + return; +-- \ No newline at end of file diff --git a/Spigot-Server-Patches/revert-Better-reloading-of-pending-unload-chunks.patch b/Spigot-Server-Patches/revert-Better-reloading-of-pending-unload-chunks.patch new file mode 100644 index 0000000000..d7dbcd336a --- /dev/null +++ b/Spigot-Server-Patches/revert-Better-reloading-of-pending-unload-chunks.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Shane Freeder +Date: Sun, 8 Apr 2018 01:21:23 +0100 +Subject: [PATCH] revert "Better reloading of pending unload chunks" + +many areas of NMS calls through to this method which means that +the server can easilly keep chunks loaded in certain conditions +even when they're no longer needed. + +diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java +index 55dada66..2ed3fc40 100644 +--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java ++++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +@@ -0,0 +0,0 @@ public class ChunkProviderServer implements IChunkProvider { + } + + public Chunk getChunkAt(int i, int j, Runnable runnable, boolean generate) { +- Chunk chunk = getLoadedChunkAt(i, j); ++ Chunk chunk = getChunkIfLoaded(i, j); // Paper - revert "Better reloading of pending unload chunks" (see patch) + ChunkRegionLoader loader = null; + + if (this.chunkLoader instanceof ChunkRegionLoader) { +-- \ No newline at end of file