From 081420d738fffe256fd18aa57dfe762be356493d Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 1 Apr 2016 00:35:44 -0400 Subject: [PATCH] improve implementation of chunk access patch --- .../0105-Optimize-Chunk-Access.patch | 71 +++---------------- ...le-spawn-chances-for-skeleton-horses.patch | 8 +-- ...ptimize-isValidLocation-for-inlining.patch | 24 +++---- ...sable-BlockPhysicsEvent-for-Redstone.patch | 14 ++-- ...Entity-AddTo-RemoveFrom-World-Events.patch | 8 +-- ...-Do-not-load-chunks-for-light-checks.patch | 6 +- 6 files changed, 41 insertions(+), 90 deletions(-) diff --git a/Spigot-Server-Patches/0105-Optimize-Chunk-Access.patch b/Spigot-Server-Patches/0105-Optimize-Chunk-Access.patch index 6dcd3fd02a..fa70b9c457 100644 --- a/Spigot-Server-Patches/0105-Optimize-Chunk-Access.patch +++ b/Spigot-Server-Patches/0105-Optimize-Chunk-Access.patch @@ -1,4 +1,4 @@ -From 90e134ecf1742e7882e0b1d9a0fea51236fd0317 Mon Sep 17 00:00:00 2001 +From 2abc0d00312f85e3dcef3520fc9cb106ae4bad3b Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 27 Aug 2015 01:15:02 -0400 Subject: [PATCH] Optimize Chunk Access @@ -29,10 +29,10 @@ index ac35cf4..6e3d17b 100644 for (int k = 0; k < this.entitySlices.length; ++k) { diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java -index f5a2580..f31ffe2 100644 +index f5a2580..5ec5bf6 100644 --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java -@@ -24,7 +24,18 @@ public class ChunkProviderServer implements IChunkProvider { +@@ -24,7 +24,26 @@ public class ChunkProviderServer implements IChunkProvider { public final ChunkUnloadQueue unloadQueue = new ChunkUnloadQueue(); // CraftBukkit - LongHashSet // Paper -> ChunkUnloadQueue public final ChunkGenerator chunkGenerator; // CraftBukkit - public private final IChunkLoader chunkLoader; @@ -47,68 +47,19 @@ index f5a2580..f31ffe2 100644 + } + return lastChunkByPos = super.get(key); + } ++ ++ @Override ++ public Chunk remove(long key) { ++ if (lastChunkByPos != null && key == lastChunkByPos.chunkKey) { ++ lastChunkByPos = null; ++ } ++ return super.remove(key); ++ } + }; // CraftBukkit + // Paper end // private final LongHashMap chunks = new LongHashMap(); // private final List chunkList = Lists.newArrayList(); public final WorldServer world; -@@ -53,6 +64,7 @@ public class ChunkProviderServer implements IChunkProvider { - - Chunk c = chunks.get(LongHash.toLong(i, j)); - if (c != null) { -+ world.testResetChunkCache(c); // Paper - c.mustSave = true; - } - // CraftBukkit end -@@ -328,6 +340,7 @@ public class ChunkProviderServer implements IChunkProvider { - chunk.removeEntities(); - this.saveChunk(chunk); - this.saveChunkNOP(chunk); -+ world.testResetChunkCache(chunk); // Paper - this.chunks.remove(chunkcoordinates); // CraftBukkit - } - -diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 0a3cfbc..825e931 100644 ---- a/src/main/java/net/minecraft/server/World.java -+++ b/src/main/java/net/minecraft/server/World.java -@@ -156,6 +156,12 @@ public abstract class World implements IBlockAccess { - public Chunk getChunkIfLoaded(BlockPosition blockposition) { - return this.chunkProvider.getLoadedChunkAt(blockposition.getX() >> 4, blockposition.getZ() >> 4); - } -+ -+ public void testResetChunkCache(Chunk chunk) { -+ if (chunk == ((ChunkProviderServer) chunkProvider).lastChunkByPos) { -+ ((ChunkProviderServer) chunkProvider).lastChunkByPos = null; -+ } -+ } - // Paper end - - public Chunk getChunkIfLoaded(int x, int z) { -diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index 47dbea8..b859c51 100644 ---- a/src/main/java/net/minecraft/server/WorldServer.java -+++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -203,6 +203,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { - // CraftBukkit end - - public void doTick() { -+ ((ChunkProviderServer) chunkProvider).lastChunkByPos = null; // Paper - super.doTick(); - if (this.getWorldData().isHardcore() && this.getDifficulty() != EnumDifficulty.HARD) { - this.getWorldData().setDifficulty(EnumDifficulty.HARD); -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index c81dfee..ec62b1f 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -224,6 +224,7 @@ public class CraftWorld implements World { - - world.getChunkProviderServer().unloadQueue.remove(x, z); - world.getChunkProviderServer().chunks.remove(LongHash.toLong(x, z)); -+ world.testResetChunkCache(chunk); // Paper - - // Update neighbor counts - for (int xx = -2; xx < 3; xx++) { -- 2.8.0 diff --git a/Spigot-Server-Patches/0106-Configurable-spawn-chances-for-skeleton-horses.patch b/Spigot-Server-Patches/0106-Configurable-spawn-chances-for-skeleton-horses.patch index 6c5900406a..6bc48f6e7d 100644 --- a/Spigot-Server-Patches/0106-Configurable-spawn-chances-for-skeleton-horses.patch +++ b/Spigot-Server-Patches/0106-Configurable-spawn-chances-for-skeleton-horses.patch @@ -1,4 +1,4 @@ -From d5b3a0eaf851f658b423b98f759603d1c8ed763f Mon Sep 17 00:00:00 2001 +From b42d5a8bb9526ec8f77411eea0076b7e30e2c8b7 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Tue, 22 Mar 2016 12:04:28 -0500 Subject: [PATCH] Configurable spawn chances for skeleton horses @@ -19,10 +19,10 @@ index 26c1b72..55b211e 100644 + } } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index b859c51..fd1150b 100644 +index 47dbea8..0acce3e 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java -@@ -429,7 +429,10 @@ public class WorldServer extends World implements IAsyncTaskHandler { +@@ -428,7 +428,10 @@ public class WorldServer extends World implements IAsyncTaskHandler { if (this.isRainingAt(blockposition)) { DifficultyDamageScaler difficultydamagescaler = this.D(blockposition); @@ -35,5 +35,5 @@ index b859c51..fd1150b 100644 entityhorse.setType(EnumHorseType.SKELETON); -- -2.7.4 +2.8.0 diff --git a/Spigot-Server-Patches/0107-Optimize-isValidLocation-for-inlining.patch b/Spigot-Server-Patches/0107-Optimize-isValidLocation-for-inlining.patch index af03512edd..d57a2e648d 100644 --- a/Spigot-Server-Patches/0107-Optimize-isValidLocation-for-inlining.patch +++ b/Spigot-Server-Patches/0107-Optimize-isValidLocation-for-inlining.patch @@ -1,4 +1,4 @@ -From 551294f564c0fa74d282ee54ad8efea388161f38 Mon Sep 17 00:00:00 2001 +From 3adef9813ff8d283b34b7c5ec9a2b47e8f72cc79 Mon Sep 17 00:00:00 2001 From: Aikar Date: Tue, 22 Mar 2016 23:41:34 -0400 Subject: [PATCH] Optimize isValidLocation for inlining @@ -22,10 +22,10 @@ index c5b6a34..17bbfb0 100644 public BaseBlockPosition(int i, int j, int k) { diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index 825e931..b5406e9 100644 +index c1cb133..1a9a847 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -284,8 +284,8 @@ public abstract class World implements IBlockAccess { +@@ -278,8 +278,8 @@ public abstract class World implements IBlockAccess { return this.getType(blockposition1); } @@ -36,7 +36,7 @@ index 825e931..b5406e9 100644 } public boolean isEmpty(BlockPosition blockposition) { -@@ -297,7 +297,7 @@ public abstract class World implements IBlockAccess { +@@ -291,7 +291,7 @@ public abstract class World implements IBlockAccess { } public boolean a(BlockPosition blockposition, boolean flag) { @@ -45,7 +45,7 @@ index 825e931..b5406e9 100644 } public boolean areChunksLoaded(BlockPosition blockposition, int i) { -@@ -377,7 +377,7 @@ public abstract class World implements IBlockAccess { +@@ -371,7 +371,7 @@ public abstract class World implements IBlockAccess { return true; } // CraftBukkit end @@ -54,7 +54,7 @@ index 825e931..b5406e9 100644 return false; } else if (!this.isClientSide && this.worldData.getType() == WorldType.DEBUG_ALL_BLOCK_STATES) { return false; -@@ -655,7 +655,7 @@ public abstract class World implements IBlockAccess { +@@ -649,7 +649,7 @@ public abstract class World implements IBlockAccess { // Paper start - test if meets light level, return faster // logic copied from below public boolean isLightLevel(BlockPosition blockposition, int level) { @@ -63,7 +63,7 @@ index 825e931..b5406e9 100644 if (this.getType(blockposition).f()) { if (this.c(blockposition.up(), false) >= level) { return true; -@@ -768,7 +768,7 @@ public abstract class World implements IBlockAccess { +@@ -762,7 +762,7 @@ public abstract class World implements IBlockAccess { blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ()); } @@ -72,7 +72,7 @@ index 825e931..b5406e9 100644 return enumskyblock.c; } else if (!this.isLoaded(blockposition)) { return enumskyblock.c; -@@ -780,7 +780,7 @@ public abstract class World implements IBlockAccess { +@@ -774,7 +774,7 @@ public abstract class World implements IBlockAccess { } public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) { @@ -81,7 +81,7 @@ index 825e931..b5406e9 100644 if (this.isLoaded(blockposition)) { Chunk chunk = this.getChunkAtWorldCoords(blockposition); -@@ -816,7 +816,7 @@ public abstract class World implements IBlockAccess { +@@ -810,7 +810,7 @@ public abstract class World implements IBlockAccess { // CraftBukkit end Chunk chunk = this.getChunkIfLoaded(blockposition); if (chunk != null) { @@ -90,7 +90,7 @@ index 825e931..b5406e9 100644 } return null; } -@@ -834,7 +834,7 @@ public abstract class World implements IBlockAccess { +@@ -828,7 +828,7 @@ public abstract class World implements IBlockAccess { } } // CraftBukkit end @@ -99,7 +99,7 @@ index 825e931..b5406e9 100644 return Blocks.AIR.getBlockData(); } else { Chunk chunk = this.getChunkAtWorldCoords(blockposition); -@@ -2063,7 +2063,7 @@ public abstract class World implements IBlockAccess { +@@ -2057,7 +2057,7 @@ public abstract class World implements IBlockAccess { public Map capturedTileEntities = Maps.newHashMap(); public TileEntity getTileEntity(BlockPosition blockposition) { @@ -108,7 +108,7 @@ index 825e931..b5406e9 100644 return null; } else { // CraftBukkit start -@@ -2166,7 +2166,7 @@ public abstract class World implements IBlockAccess { +@@ -2160,7 +2160,7 @@ public abstract class World implements IBlockAccess { } public boolean d(BlockPosition blockposition, boolean flag) { diff --git a/Spigot-Server-Patches/0114-Option-to-disable-BlockPhysicsEvent-for-Redstone.patch b/Spigot-Server-Patches/0114-Option-to-disable-BlockPhysicsEvent-for-Redstone.patch index a6568c6622..67af66bfd5 100644 --- a/Spigot-Server-Patches/0114-Option-to-disable-BlockPhysicsEvent-for-Redstone.patch +++ b/Spigot-Server-Patches/0114-Option-to-disable-BlockPhysicsEvent-for-Redstone.patch @@ -1,4 +1,4 @@ -From 7624eaca661b3e694061922c8117852adae8f5be Mon Sep 17 00:00:00 2001 +From 89d4f6537a88b323c9072af629b4a54d6fe54db6 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 19:55:45 -0400 Subject: [PATCH] Option to disable BlockPhysicsEvent for Redstone @@ -25,10 +25,10 @@ index 55b211e..d6b8f72 100644 + } } diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index b5406e9..fcd7cd6 100644 +index 1a9a847..c6463b2 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -574,7 +574,7 @@ public abstract class World implements IBlockAccess { +@@ -568,7 +568,7 @@ public abstract class World implements IBlockAccess { try { // CraftBukkit start CraftWorld world = ((WorldServer) this).getWorld(); @@ -38,7 +38,7 @@ index b5406e9..fcd7cd6 100644 this.getServer().getPluginManager().callEvent(event); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java -index fd1150b..f170d7a 100644 +index 0acce3e..c8e536c 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -32,6 +32,7 @@ import org.bukkit.event.weather.LightningStrikeEvent; @@ -49,7 +49,7 @@ index fd1150b..f170d7a 100644 private final MinecraftServer server; public EntityTracker tracker; private final PlayerChunkMap manager; -@@ -742,6 +743,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { +@@ -741,6 +742,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { if (iblockdata.getMaterial() != Material.AIR && Block.a(iblockdata.getBlock(), nextticklistentry.a())) { try { @@ -57,7 +57,7 @@ index fd1150b..f170d7a 100644 iblockdata.getBlock().b((World) this, nextticklistentry.a, iblockdata, this.random); } catch (Throwable throwable) { CrashReport crashreport = CrashReport.a(throwable, "Exception while ticking a block"); -@@ -749,7 +751,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { +@@ -748,7 +750,7 @@ public class WorldServer extends World implements IAsyncTaskHandler { CrashReportSystemDetails.a(crashreportsystemdetails, nextticklistentry.a, iblockdata); throw new ReportedException(crashreport); @@ -67,5 +67,5 @@ index fd1150b..f170d7a 100644 timing.stopTiming(); // Paper } else { -- -2.7.4 +2.8.0 diff --git a/Spigot-Server-Patches/0115-Entity-AddTo-RemoveFrom-World-Events.patch b/Spigot-Server-Patches/0115-Entity-AddTo-RemoveFrom-World-Events.patch index 103fa005a1..2e321bf4af 100644 --- a/Spigot-Server-Patches/0115-Entity-AddTo-RemoveFrom-World-Events.patch +++ b/Spigot-Server-Patches/0115-Entity-AddTo-RemoveFrom-World-Events.patch @@ -1,14 +1,14 @@ -From 9cfb72beaff0ebaa90f24e86e409410a268d565c Mon Sep 17 00:00:00 2001 +From 86c09e0420200254be71440c724732e4af463d59 Mon Sep 17 00:00:00 2001 From: Aikar Date: Mon, 28 Mar 2016 20:32:58 -0400 Subject: [PATCH] Entity AddTo/RemoveFrom World Events diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index fcd7cd6..fa84bad 100644 +index c6463b2..d5ba601 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -1119,6 +1119,7 @@ public abstract class World implements IBlockAccess { +@@ -1113,6 +1113,7 @@ public abstract class World implements IBlockAccess { } entity.valid = true; // CraftBukkit @@ -16,7 +16,7 @@ index fcd7cd6..fa84bad 100644 } protected void c(Entity entity) { -@@ -1126,6 +1127,7 @@ public abstract class World implements IBlockAccess { +@@ -1120,6 +1121,7 @@ public abstract class World implements IBlockAccess { ((IWorldAccess) this.u.get(i)).b(entity); } diff --git a/Spigot-Server-Patches/0124-Do-not-load-chunks-for-light-checks.patch b/Spigot-Server-Patches/0124-Do-not-load-chunks-for-light-checks.patch index 5d8327afc1..4e9e74093c 100644 --- a/Spigot-Server-Patches/0124-Do-not-load-chunks-for-light-checks.patch +++ b/Spigot-Server-Patches/0124-Do-not-load-chunks-for-light-checks.patch @@ -1,4 +1,4 @@ -From 26605472c71f3844ee15539ee80f49d6234ce140 Mon Sep 17 00:00:00 2001 +From c56be574082969f54bed8a2553ebb2ff7d5ce052 Mon Sep 17 00:00:00 2001 From: Aikar Date: Thu, 31 Mar 2016 19:17:58 -0400 Subject: [PATCH] Do not load chunks for light checks @@ -7,10 +7,10 @@ Should only happen for blocks on the edge that uses neighbors light level (certain blocks). In that case, there will be 3-4 other neighbors to get a light level from. diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java -index fa84bad..89103d6 100644 +index d5ba601..ea187f9 100644 --- a/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java -@@ -723,6 +723,7 @@ public abstract class World implements IBlockAccess { +@@ -717,6 +717,7 @@ public abstract class World implements IBlockAccess { if (blockposition.getY() >= 256) { blockposition = new BlockPosition(blockposition.getX(), 255, blockposition.getZ()); }