From b35f1a3c3e14fcf9ee9de2fc3ce9419dc60564fc Mon Sep 17 00:00:00 2001 From: Iceee Date: Thu, 23 Jul 2015 04:24:24 -0700 Subject: [PATCH] Optimize Spigot's Anti X-Ray --- .../Optimize-Spigot-s-Anti-X-Ray.patch | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Spigot-Server-Patches/Optimize-Spigot-s-Anti-X-Ray.patch diff --git a/Spigot-Server-Patches/Optimize-Spigot-s-Anti-X-Ray.patch b/Spigot-Server-Patches/Optimize-Spigot-s-Anti-X-Ray.patch new file mode 100644 index 000000000..f0e4901ea --- /dev/null +++ b/Spigot-Server-Patches/Optimize-Spigot-s-Anti-X-Ray.patch @@ -0,0 +1,88 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Iceee +Date: Thu, 23 Jul 2015 04:23:23 -0700 +Subject: [PATCH] Optimize Spigot's Anti X-Ray + + +diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/server/WorldServer.java ++++ b/src/main/java/net/minecraft/server/WorldServer.java +@@ -0,0 +0,0 @@ public class WorldServer extends World implements IAsyncTaskHandler { + timings.doTickTiles.startTiming(); // Spigot + this.h(); + timings.doTickTiles.stopTiming(); // Spigot ++ spigotConfig.antiXrayInstance.flushUpdates(this); // PaperSpigot + this.methodProfiler.c("chunkMap"); + timings.doChunkMap.startTiming(); // Spigot + this.manager.flush(); +diff --git a/src/main/java/org/spigotmc/AntiXray.java b/src/main/java/org/spigotmc/AntiXray.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/spigotmc/AntiXray.java ++++ b/src/main/java/org/spigotmc/AntiXray.java +@@ -0,0 +0,0 @@ import net.minecraft.server.Blocks; + import net.minecraft.server.World; + import org.bukkit.craftbukkit.util.CraftMagicNumbers; + ++// PaperSpigot start ++import java.util.HashSet; ++import java.util.Set; ++// PaperSpigot end ++ + public class AntiXray + { + +@@ -0,0 +0,0 @@ public class AntiXray + private final boolean[] obfuscateBlocks = new boolean[ Short.MAX_VALUE ]; + // Used to select a random replacement ore + private final byte[] replacementOres; ++ // PaperSpigot start ++ public boolean queueUpdates = true; ++ public final Set pendingUpdates = new HashSet(); ++ // PaperSpigot end + + public AntiXray(SpigotWorldConfig config) + { +@@ -0,0 +0,0 @@ public class AntiXray + } + + /** ++ * PaperSpigot - Flush queued block updates for world. ++ */ ++ public void flushUpdates(World world) ++ { ++ if ( world.spigotConfig.antiXray && !pendingUpdates.isEmpty() ) ++ { ++ queueUpdates = false; ++ ++ for ( BlockPosition position : pendingUpdates ) ++ { ++ updateNearbyBlocks( world, position ); ++ } ++ ++ pendingUpdates.clear(); ++ queueUpdates = true; ++ } ++ } ++ ++ /** + * Starts the timings handler, then updates all blocks within the set radius + * of the given coordinate, revealing them if they are hidden ores. + */ +@@ -0,0 +0,0 @@ public class AntiXray + { + if ( world.spigotConfig.antiXray ) + { ++ // PaperSpigot start ++ if ( queueUpdates ) ++ { ++ pendingUpdates.add( position ); ++ return; ++ } ++ // PaperSpigot end + update.startTiming(); + updateNearbyBlocks( world, position, 2, false ); // 2 is the radius, we shouldn't change it as that would make it exponentially slower + update.stopTiming(); +-- +1.9.5.msysgit.1 +