Refactor Lighting Queue System

may help #284

Cleans up the lighting queue system, reducing diff and improving implementation.

We no longer stop chunk unloads due to lighting updates, and instead simply flush the lighting queue.
The cost of forcing the chunk (and its neighbors!) to stay loaded waiting for its
lighting work to finish is much greater than simply taking the hit and doing the work.

This change also helps reduce the diff and avoid bugs with missed diffs by removing
duplicated logic.

Also switches to a more effecient data structure (ArrayDeque instead of LinkedList) for the queue itself.
This commit is contained in:
Aikar 2016-05-15 18:48:39 -04:00
parent 433489ea32
commit e56bbcdcda
25 changed files with 266 additions and 260 deletions

View file

@ -1,21 +1,31 @@
From 5efa3dbdcbafbb869d80578874d617adbdbbe687 Mon Sep 17 00:00:00 2001
From dda988688e1cc0e88e958f3d2efb47a23df5cc01 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 00:52:31 -0600
Subject: [PATCH] Lighting Queue
This provides option to queue lighting updates to ensure they do not cause the server lag
diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java
index 0f8315c..5afdc2c 100644
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
@@ -17,6 +17,7 @@ public final class MinecraftTimings {
public static final Timing timeUpdateTimer = Timings.ofSafe("Time Update");
public static final Timing serverCommandTimer = Timings.ofSafe("Server Command");
public static final Timing worldSaveTimer = Timings.ofSafe("World Save");
+ public static final Timing lightingQueueTimer = Timings.ofSafe("Lighting Queue");
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
index 11dd692..da3787d 100644
--- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -35,6 +35,8 @@ public class WorldTimingsHandler {
public final Timing syncChunkLoadTileTicksTimer;
public final Timing syncChunkLoadPostTimer;
public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity");
public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity");
+ public final Timing lightingQueueTimer;
+
public WorldTimingsHandler(World server) {
String name = server.worldData.getName() +" - ";
@@ -67,5 +69,7 @@ public class WorldTimingsHandler {
tracker2 = Timings.ofSafe(name + "tracker stage 2");
doTick = Timings.ofSafe(name + "doTick");
tickEntities = Timings.ofSafe(name + "tickEntities");
+
+ lightingQueueTimer = Timings.ofSafe(name + "Lighting Queue");
}
}
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 7c0e61f..8e3a0f3 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@ -32,31 +42,22 @@ index 7c0e61f..8e3a0f3 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 5690e81..42fef0a 100644
index 5690e81..d55beb9 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -45,6 +45,7 @@ public class Chunk {
private ConcurrentLinkedQueue<BlockPosition> y;
public boolean d;
protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
+ public int lightUpdates; // Paper - Number of queued light updates for this chunk
// CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
private int neighbors = 0x1 << 12;
@@ -227,6 +228,22 @@ public class Chunk {
@@ -33,6 +33,7 @@ public class Chunk {
private boolean m;
public final Map<BlockPosition, TileEntity> tileEntities;
public final List<Entity>[] entitySlices; // Spigot
+ final PaperLightingQueue.LightingQueue lightingQueue = new PaperLightingQueue.LightingQueue(this); // Paper
private boolean done;
private boolean lit;
private boolean r;
@@ -227,6 +228,13 @@ public class Chunk {
private void h(boolean flag) {
this.world.methodProfiler.a("recheckGaps");
if (this.world.areChunksLoaded(new BlockPosition(this.locX * 16 + 8, 0, this.locZ * 16 + 8), 16)) {
+ // Paper start - Queue light update
+ if (!world.paperConfig.queueLightUpdates) {
+ recheckGaps(flag);
+ } else {
+ ++lightUpdates;
+ world.getServer().getServer().lightingQueue.add(() -> {
+ recheckGaps(flag);
+ --lightUpdates;
+ });
+ }
+ lightingQueue.add(() -> recheckGaps(flag)); // Paper - Queue light update
+ }
+ }
+
@ -66,165 +67,170 @@ index 5690e81..42fef0a 100644
for (int i = 0; i < 16; ++i) {
for (int j = 0; j < 16; ++j) {
if (this.i[i + j * 16]) {
@@ -478,7 +495,7 @@ public class Chunk {
@@ -478,7 +486,7 @@ public class Chunk {
} else {
if (flag) {
this.initLighting();
- } else {
+ } else if (!world.paperConfig.queueLightUpdates) { // Paper
+ } else { lightingQueue.add(() -> { // Paper - Queue light update
int j1 = iblockdata.c();
int k1 = iblockdata1.c();
@@ -493,6 +510,28 @@ public class Chunk {
@@ -493,6 +501,7 @@ public class Chunk {
if (j1 != k1 && (j1 < k1 || this.getBrightness(EnumSkyBlock.SKY, blockposition) > 0 || this.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 0)) {
this.d(i, k);
}
+ // Paper start - Queue light update
+ } else {
+ int j1 = iblockdata.c();
+ int k1 = iblockdata1.c();
+
+ ++lightUpdates;
+ world.getServer().getServer().lightingQueue.add(() -> {
+ if (j1 > 0) {
+ if (j >= i1) {
+ this.c(i, j + 1, k);
+ }
+ } else if (j == i1 - 1) {
+ this.c(i, j, k);
+ }
+
+ if (j1 != k1 && (j1 < k1 || this.getBrightness(EnumSkyBlock.SKY, blockposition) > 0 || this.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 0)) {
+ this.d(i, k);
+ }
+
+ --lightUpdates;
+ });
+ // Paper end
+ }); // Paper
}
TileEntity tileentity;
@@ -1318,4 +1357,29 @@ public class Chunk {
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index de85bd5..50f0345 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -275,6 +275,7 @@ public class ChunkProviderServer implements IChunkProvider {
if (event.isCancelled()) {
continue;
}
+ chunk.lightingQueue.processUnload(); // Paper
private EnumTileEntityState() {}
// Update neighbor counts
for (int x = -2; x < 3; x++) {
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ebf6c48..89a40a8 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -706,7 +706,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
protected void C() throws ExceptionWorldConflict { // CraftBukkit - added throws
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Paper
- long i = System.nanoTime();
+ long i = System.nanoTime(); long startTime = i; // Paper
++this.ticks;
if (this.S) {
@@ -766,6 +766,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.methodProfiler.b();
org.spigotmc.WatchdogThread.tick(); // Spigot
+ PaperLightingQueue.processQueue(startTime); // Paper
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
}
diff --git a/src/main/java/net/minecraft/server/PaperLightingQueue.java b/src/main/java/net/minecraft/server/PaperLightingQueue.java
new file mode 100644
index 0000000..2350fe3
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PaperLightingQueue.java
@@ -0,0 +1,98 @@
+package net.minecraft.server;
+
+ // Paper start
+ public boolean hasLightUpdates() {
+ if (world.paperConfig.queueLightUpdates) {
+ if (lightUpdates > 0) {
+ return true;
+import co.aikar.timings.Timing;
+import java.util.ArrayDeque;
+
+class PaperLightingQueue {
+ private static final long MAX_TIME = (long) (1000000000 / 20 * .95);
+ private static int updatesThisTick;
+
+
+ static void processQueue(long curTime) {
+ updatesThisTick = 0;
+
+ final long startTime = System.nanoTime();
+ final long maxTickTime = MAX_TIME - (startTime - curTime);
+
+ START:
+ for (World world : MinecraftServer.getServer().worlds) {
+ if (!world.paperConfig.queueLightUpdates) {
+ continue;
+ }
+
+ for (int x = locX - 2; x <= locX + 2; ++x) {
+ for (int z = locZ - 2; z <= locZ + 2; ++z) {
+ if ((x == 0 && z == 0) || (x == locX && z == locZ)) {
+ for (Chunk chunk : ((WorldServer) world).getChunkProviderServer().chunks.values()) {
+ if (chunk.lightingQueue.processQueue(startTime, maxTickTime)) {
+ break START;
+ }
+ }
+ }
+ }
+
+ static class LightingQueue extends ArrayDeque<Runnable> {
+ final private Chunk chunk;
+
+ LightingQueue(Chunk chunk) {
+ super();
+ this.chunk = chunk;
+ }
+
+ @Override
+ public boolean add(Runnable runnable) {
+ if (chunk.world.paperConfig.queueLightUpdates) {
+ return super.add(runnable);
+ }
+ runnable.run();
+ return true;
+ }
+
+ /**
+ * Processes the lighting queue for this chunk
+ *
+ * @param startTime If start Time is 0, we will not limit execution time
+ * @param maxTickTime Maximum time to spend processing lighting updates
+ * @return true to abort processing furthur lighting updates
+ */
+ private boolean processQueue(long startTime, long maxTickTime) {
+ if (this.isEmpty()) {
+ return false;
+ }
+ try (Timing ignored = chunk.world.timings.lightingQueueTimer.startTiming()) {
+ Runnable lightUpdate;
+ while ((lightUpdate = this.poll()) != null) {
+ lightUpdate.run();
+ if (startTime > 0 && ++PaperLightingQueue.updatesThisTick % 10 == 0 && PaperLightingQueue.updatesThisTick > 10) {
+ if (System.nanoTime() - startTime > maxTickTime) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Flushes lighting updates to unload the chunk
+ */
+ void processUnload() {
+ if (!chunk.world.paperConfig.queueLightUpdates) {
+ return;
+ }
+ processQueue(0, 0); // No timeout
+
+ final int radius = 1; // TODO: bitflip, why should this ever be 2?
+ for (int x = chunk.locX - radius; x <= chunk.locX + radius; ++x) {
+ for (int z = chunk.locZ - radius; z <= chunk.locZ + radius; ++z) {
+ if (x == chunk.locX && z == chunk.locZ) {
+ continue;
+ }
+
+ Chunk chunk = MCUtil.getLoadedChunkWithoutMarkingActive(world, x, z);
+ if (chunk != null && chunk.lightUpdates > 0) {
+ return true;
+ Chunk neighbor = MCUtil.getLoadedChunkWithoutMarkingActive(chunk.world, x, z);
+ if (neighbor != null) {
+ neighbor.lightingQueue.processQueue(0, 0); // No timeout
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index de85bd5..20dccfb 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -269,6 +269,7 @@ public class ChunkProviderServer implements IChunkProvider {
Chunk chunk = (Chunk) this.chunks.get(olong);
if (chunk != null && chunk.d) {
+ if (chunk.hasLightUpdates()) continue; // Paper - Don't unload chunks with pending light updates.
// CraftBukkit start
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
this.world.getServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ebf6c48..fcc1214 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -52,6 +52,11 @@ import org.bukkit.craftbukkit.CraftServer;
// CraftBukkit end
import co.aikar.timings.MinecraftTimings; // Paper
+// Paper start
+import java.util.LinkedList;
+import java.util.Queue;
+// Paper end
+
public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
public static final Logger LOGGER = LogManager.getLogger();
@@ -118,6 +123,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
public final Thread primaryThread;
public java.util.Queue<Runnable> processQueue = new java.util.concurrent.ConcurrentLinkedQueue<Runnable>();
public int autosavePeriod;
+ public final Queue<Runnable> lightingQueue = new LinkedList<Runnable>(); // Paper - Queued light updates
// CraftBukkit end
public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
@@ -765,6 +771,34 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
this.methodProfiler.b();
this.methodProfiler.b();
+ // Paper start - Flush light updates
+ if (!lightingQueue.isEmpty()) {
+ MinecraftTimings.lightingQueueTimer.startTiming();
+
+ int updatesThisTick = 0;
+ long cachedTime = System.currentTimeMillis();
+ long startTime = cachedTime - (this.h[this.ticks % 100] / 1000000);
+ int maxTickTimeCap = MathHelper.floor((TICK_TIME / 1000000) * 0.8);
+ int maxTickTime = Math.max(0, (int) (maxTickTimeCap - (cachedTime - startTime)));
+ Runnable lightUpdate;
+
+ while (maxTickTime > 0 && (lightUpdate = lightingQueue.poll()) != null) {
+ lightUpdate.run();
+ if (++updatesThisTick % 10 == 0) {
+ long currentTime = System.currentTimeMillis();
+ if (currentTime - cachedTime > maxTickTime) {
+ break;
+ }
+
+ cachedTime = currentTime;
+ maxTickTime = Math.max(0, (int) (maxTickTimeCap - (currentTime - startTime)));
+ }
+ }
+
+ MinecraftTimings.lightingQueueTimer.stopTiming();
+ }
+ // Paper end
+
org.spigotmc.WatchdogThread.tick(); // Spigot
co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Paper
}
+}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 362df8f..77cfd3f 100644
index 362df8f..dc51a79 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -384,7 +384,17 @@ public abstract class World implements IBlockAccess {
@@ -384,7 +384,7 @@ public abstract class World implements IBlockAccess {
} else {
if (iblockdata.c() != iblockdata1.c() || iblockdata.d() != iblockdata1.d()) {
this.methodProfiler.a("checkLight");
- this.w(blockposition);
+ // Paper start - Queue light update
+ if (!paperConfig.queueLightUpdates) {
+ this.w(blockposition);
+ } else {
+ ++chunk.lightUpdates;
+ getMinecraftServer().lightingQueue.add(() -> {
+ this.w(blockposition);
+ --chunk.lightUpdates;
+ });
+ }
+ // Paper end
+ chunk.lightingQueue.add(() -> this.w(blockposition)); // Paper - Queue light update
this.methodProfiler.b();
}

View file

@ -1,4 +1,4 @@
From f537cf6b939037c60801e039483949925bf390c5 Mon Sep 17 00:00:00 2001
From 67a035d6646e7d542e0a6c0156ec202e542e01aa Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net>
Date: Wed, 2 Mar 2016 11:59:48 -0600
Subject: [PATCH] Optimize explosions
@ -124,10 +124,10 @@ index de74fb7..8e225a5 100644
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index fcc1214..5925e2c 100644
index 89a40a8..bbdb19a 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -903,6 +903,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -870,6 +870,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
worldserver.getTracker().updatePlayers();
this.methodProfiler.b();
this.methodProfiler.b();
@ -136,7 +136,7 @@ index fcc1214..5925e2c 100644
// this.i[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 77cfd3f..71159b4 100644
index dc51a79..c8c2601 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -16,6 +16,7 @@ import javax.annotation.Nullable;

View file

@ -1,14 +1,14 @@
From be1c32e1306b4b5713bc1046bdc234f3827f7407 Mon Sep 17 00:00:00 2001
From 58ac13abf1d84ad3e446556592682eb8f077ee4a Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Wed, 2 Mar 2016 23:45:17 -0600
Subject: [PATCH] Disable spigot tick limiters
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 71159b4..5adc297 100644
index c8c2601..b7f45b6 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1428,10 +1428,10 @@ public abstract class World implements IBlockAccess {
@@ -1418,10 +1418,10 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start - Use field for loop variable
co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Paper
int entitiesThisCycle = 0;
@ -23,7 +23,7 @@ index 71159b4..5adc297 100644
tickPosition = (tickPosition < entityList.size()) ? tickPosition : 0;
entity = (Entity) this.entityList.get(this.tickPosition);
// CraftBukkit end
@@ -1496,9 +1496,7 @@ public abstract class World implements IBlockAccess {
@@ -1486,9 +1486,7 @@ public abstract class World implements IBlockAccess {
// Spigot start
// Iterator iterator = this.tileEntityListTick.iterator();
int tilesThisCycle = 0;

View file

@ -1,4 +1,4 @@
From 098cb462c9c959f5b015dd13058fbb76619829d0 Mon Sep 17 00:00:00 2001
From d867255d8c2e1b34c741e287d89375ba801c1098 Mon Sep 17 00:00:00 2001
From: DemonWav <demonwav@gmail.com>
Date: Thu, 3 Mar 2016 01:44:39 -0600
Subject: [PATCH] Add Location support to tab completers (vanilla feature
@ -20,10 +20,10 @@ index 2b7a4dd..246f3d9 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 5925e2c..f5e26df 100644
index bbdb19a..3d2e0b6 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1189,7 +1189,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -1156,7 +1156,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
return arraylist;
}
*/

View file

@ -1,4 +1,4 @@
From 7b8fd6c09c65c9bafae7bd58364797691be50cad Mon Sep 17 00:00:00 2001
From 086069acbe2c36b968bd5d853426ff8d38a8cd49 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 3 Mar 2016 02:07:55 -0600
Subject: [PATCH] Optimize getBlockData
@ -6,10 +6,10 @@ Subject: [PATCH] Optimize getBlockData
Hot method, so reduce # of instructions for the method.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 3bcbbb9..08525d6 100644
index d55beb9..3806def 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -404,8 +404,15 @@ public class Chunk {
@@ -395,8 +395,15 @@ public class Chunk {
return this.a(i, j, k).c();
}

View file

@ -1,4 +1,4 @@
From c78c930892a7b03ed80dcf843aedb632fb1a8b4d Mon Sep 17 00:00:00 2001
From 1bba159601a998917f3ebe31c6b6642951a02ef7 Mon Sep 17 00:00:00 2001
From: CullanP <cullanpage@gmail.com>
Date: Thu, 3 Mar 2016 02:13:38 -0600
Subject: [PATCH] Avoid hopper searches if there are no items
@ -14,12 +14,12 @@ And since minecart hoppers are used _very_ rarely near we can avoid alot of sear
Combined, this adds up a lot.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 08525d6..300d625 100644
index 3806def..acce7cb 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -47,6 +47,13 @@ public class Chunk {
public boolean d;
protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
public int lightUpdates; // Paper - Number of queued light updates for this chunk
+ // Paper start
+ // Track the number of minecarts and items
@ -31,7 +31,7 @@ index 08525d6..300d625 100644
// CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
private int neighbors = 0x1 << 12;
@@ -655,6 +662,13 @@ public class Chunk {
@@ -625,6 +632,13 @@ public class Chunk {
entity.ac = k;
entity.ad = this.locZ;
this.entitySlices[k].add(entity);
@ -45,7 +45,7 @@ index 08525d6..300d625 100644
// Spigot start - increment creature type count
// Keep this synced up with World.a(Class)
if (entity instanceof EntityInsentient) {
@@ -687,6 +701,13 @@ public class Chunk {
@@ -657,6 +671,13 @@ public class Chunk {
}
this.entitySlices[i].remove(entity);
@ -59,7 +59,7 @@ index 08525d6..300d625 100644
// Spigot start - decrement creature type count
// Keep this synced up with World.a(Class)
if (entity instanceof EntityInsentient) {
@@ -878,6 +899,15 @@ public class Chunk {
@@ -848,6 +869,15 @@ public class Chunk {
if (!this.entitySlices[k].isEmpty()) {
Iterator iterator = this.entitySlices[k].iterator();
@ -75,7 +75,7 @@ index 08525d6..300d625 100644
while (iterator.hasNext()) {
Entity entity1 = (Entity) iterator.next();
@@ -910,7 +940,18 @@ public class Chunk {
@@ -880,7 +910,18 @@ public class Chunk {
i = MathHelper.clamp(i, 0, this.entitySlices.length - 1);
j = MathHelper.clamp(j, 0, this.entitySlices.length - 1);

View file

@ -1,4 +1,4 @@
From 0457e6130e427aac532ba7ebae80b9e3a3350ef9 Mon Sep 17 00:00:00 2001
From acf9844949fec83fbc827beef334a584b9b28f2e Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 02:39:54 -0600
Subject: [PATCH] Change implementation of (tile)entity removal list
@ -22,7 +22,7 @@ index 751e07d..c6fe888 100644
public boolean impulse;
public int portalCooldown;
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 5adc297..159934f 100644
index b7f45b6..26352d2 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -31,6 +31,11 @@ import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
@ -51,7 +51,7 @@ index 5adc297..159934f 100644
public final List<EntityHuman> players = Lists.newArrayList();
public final List<Entity> j = Lists.newArrayList();
protected final IntHashMap<Entity> entitiesById = new IntHashMap();
@@ -1400,19 +1405,20 @@ public abstract class World implements IBlockAccess {
@@ -1390,19 +1395,20 @@ public abstract class World implements IBlockAccess {
int j;

View file

@ -1,4 +1,4 @@
From 6716cfabe2cb44666f1c9fa5d7ccf68d95224f3c Mon Sep 17 00:00:00 2001
From cc1f55cfececca4adcf18519f2b2fe2f6b2a3165 Mon Sep 17 00:00:00 2001
From: Joseph Hirschfeld <joe@ibj.io>
Date: Thu, 3 Mar 2016 03:15:41 -0600
Subject: [PATCH] Add exception reporting event
@ -50,7 +50,7 @@ index 0000000..9339718
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 300d625..eb60455 100644
index acce7cb..b39960a 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -1,5 +1,6 @@
@ -68,7 +68,7 @@ index 300d625..eb60455 100644
public class Chunk {
@@ -793,10 +795,15 @@ public class Chunk {
@@ -763,10 +765,15 @@ public class Chunk {
this.tileEntities.remove(blockposition);
// Paper end
} else {
@ -89,7 +89,7 @@ index 300d625..eb60455 100644
}
}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 20dccfb..32b71c6 100644
index 50f0345..25a2720 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -11,6 +11,7 @@ import java.util.Iterator;
@ -292,7 +292,7 @@ index 26d7d12..fcd2ddf 100644
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index e56f705..21ba235 100644
index 26352d2..ccbfda0 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1,5 +1,7 @@
@ -303,7 +303,7 @@ index e56f705..21ba235 100644
import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
@@ -1460,8 +1462,10 @@ public abstract class World implements IBlockAccess {
@@ -1450,8 +1452,10 @@ public abstract class World implements IBlockAccess {
} catch (Throwable throwable1) {
entity.tickTimer.stopTiming();
// Paper start - Prevent tile entity and entity crashes
@ -315,7 +315,7 @@ index e56f705..21ba235 100644
entity.dead = true;
continue;
// Paper end
@@ -1525,8 +1529,10 @@ public abstract class World implements IBlockAccess {
@@ -1515,8 +1519,10 @@ public abstract class World implements IBlockAccess {
this.methodProfiler.b();
} catch (Throwable throwable2) {
// Paper start - Prevent tile entity and entity crashes

View file

@ -1,4 +1,4 @@
From a9bec1c0266a2ed770f99dd1288b88a71b997aba Mon Sep 17 00:00:00 2001
From 2e5d3ab319b7c04911614a21e08c28144e9544f8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 18 Mar 2016 20:16:03 -0400
Subject: [PATCH] Add World Util Methods
@ -6,7 +6,7 @@ Subject: [PATCH] Add World Util Methods
Methods that can be used for other patches to help improve logic.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 21ba235..3bdf072 100644
index ccbfda0..133d4e2 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -153,6 +153,12 @@ public abstract class World implements IBlockAccess {
@ -22,7 +22,7 @@ index 21ba235..3bdf072 100644
public Chunk getChunkIfLoaded(int x, int z) {
return ((ChunkProviderServer) this.chunkProvider).getLoadedChunkAt(x, z);
}
@@ -640,6 +646,41 @@ public abstract class World implements IBlockAccess {
@@ -630,6 +636,41 @@ public abstract class World implements IBlockAccess {
}
}
@ -64,7 +64,7 @@ index 21ba235..3bdf072 100644
public int getLightLevel(BlockPosition blockposition) {
return this.c(blockposition, true);
}
@@ -755,6 +796,27 @@ public abstract class World implements IBlockAccess {
@@ -745,6 +786,27 @@ public abstract class World implements IBlockAccess {
return this.worldProvider.n()[this.getLightLevel(blockposition)];
}

View file

@ -1,4 +1,4 @@
From 3a02b0e6f4d2149f1be45e802a51ecfae1fa7453 Mon Sep 17 00:00:00 2001
From 00e5dc742dc2b80b9d43600cbe44b087c648c3d8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 22 Mar 2016 23:41:34 -0400
Subject: [PATCH] Optimize isValidLocation for inlining
@ -41,7 +41,7 @@ index 99fcf4c..be34dcd 100644
public MutableBlockPosition() {
this(0, 0, 0);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 3bdf072..ecf3a38 100644
index 133d4e2..718215c 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -274,8 +274,8 @@ public abstract class World implements IBlockAccess {
@ -55,7 +55,7 @@ index 3bdf072..ecf3a38 100644
}
private boolean E(BlockPosition blockposition) {
@@ -649,7 +649,7 @@ public abstract class World implements IBlockAccess {
@@ -639,7 +639,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) {
@ -64,7 +64,7 @@ index 3bdf072..ecf3a38 100644
if (this.getType(blockposition).f()) {
if (this.c(blockposition.up(), false) >= level) {
return true;
@@ -763,7 +763,7 @@ public abstract class World implements IBlockAccess {
@@ -753,7 +753,7 @@ public abstract class World implements IBlockAccess {
blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ());
}
@ -73,7 +73,7 @@ index 3bdf072..ecf3a38 100644
return enumskyblock.c;
} else if (!this.isLoaded(blockposition)) {
return enumskyblock.c;
@@ -775,7 +775,7 @@ public abstract class World implements IBlockAccess {
@@ -765,7 +765,7 @@ public abstract class World implements IBlockAccess {
}
public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) {
@ -82,7 +82,7 @@ index 3bdf072..ecf3a38 100644
if (this.isLoaded(blockposition)) {
Chunk chunk = this.getChunkAtWorldCoords(blockposition);
@@ -811,7 +811,7 @@ public abstract class World implements IBlockAccess {
@@ -801,7 +801,7 @@ public abstract class World implements IBlockAccess {
// CraftBukkit end
Chunk chunk = this.getChunkIfLoaded(blockposition);
if (chunk != null) {

View file

@ -1,4 +1,4 @@
From 53ba2d46f33926f724bff3ae45dbc377821d51dd Mon Sep 17 00:00:00 2001
From 2f625e1e83f3c8ea5a221e29dcf5b8321b9ee533 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 28 Mar 2016 19:55:45 -0400
Subject: [PATCH] Option to disable BlockPhysicsEvent for Redstone
@ -25,10 +25,10 @@ index cdb1766..f689d69 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index ecf3a38..db70868 100644
index 718215c..757ed3e 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -568,7 +568,7 @@ public abstract class World implements IBlockAccess {
@@ -558,7 +558,7 @@ public abstract class World implements IBlockAccess {
try {
// CraftBukkit start
CraftWorld world = ((WorldServer) this).getWorld();

View file

@ -1,14 +1,14 @@
From 42278206102e357936f9e7d8b7001160df905803 Mon Sep 17 00:00:00 2001
From 6a7f3beb5deb1e84b02189832d3db4bc8fbc2161 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 db70868..830494c 100644
index 757ed3e..095d4b2 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1117,6 +1117,7 @@ public abstract class World implements IBlockAccess {
@@ -1107,6 +1107,7 @@ public abstract class World implements IBlockAccess {
}
entity.valid = true; // CraftBukkit
@ -16,7 +16,7 @@ index db70868..830494c 100644
}
protected void c(Entity entity) {
@@ -1124,6 +1125,7 @@ public abstract class World implements IBlockAccess {
@@ -1114,6 +1115,7 @@ public abstract class World implements IBlockAccess {
((IWorldAccess) this.u.get(i)).b(entity);
}

View file

@ -1,4 +1,4 @@
From c1e5076fcdd19903b706e7bb19c7a4ec80edea1a Mon Sep 17 00:00:00 2001
From 6141cadba25a695101752faca997db05813c436b Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Mon, 28 Mar 2016 20:46:14 -0400
Subject: [PATCH] Configurable Chunk Inhabited Timer
@ -23,10 +23,10 @@ index f689d69..6f77cfd 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 22e4728..f7452b3 100644
index 98d9e99..7144227 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -1401,7 +1401,7 @@ public class Chunk {
@@ -1371,7 +1371,7 @@ public class Chunk {
}
public long x() {

View file

@ -1,14 +1,14 @@
From b50ffe187045367a4cadb8abf7d4990bccc58038 Mon Sep 17 00:00:00 2001
From 60d48a782502bf6c276124acfd412f18390a4ac7 Mon Sep 17 00:00:00 2001
From: DemonWav <demonwav@gmail.com>
Date: Wed, 30 Mar 2016 01:20:11 -0500
Subject: [PATCH] Add getEntity by UUID API
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index f5e26df..8d8e415 100644
index 3d2e0b6..842e364 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1626,4 +1626,20 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -1593,4 +1593,20 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
return (Bukkit.getServer() instanceof CraftServer) ? ((CraftServer) Bukkit.getServer()).getServer() : null;
}
// CraftBukkit end

View file

@ -1,4 +1,4 @@
From d4c8600623227bb4ccc74a31b66b010e2d65ed3c Mon Sep 17 00:00:00 2001
From c0da998748217fabcbbea1ae21ca614b18409710 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 830494c..f25b6e0 100644
index 095d4b2..5223785 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -717,6 +717,7 @@ public abstract class World implements IBlockAccess {
@@ -707,6 +707,7 @@ public abstract class World implements IBlockAccess {
if (blockposition.getY() >= 256) {
blockposition = new BlockPosition(blockposition.getX(), 255, blockposition.getZ());
}

View file

@ -1,4 +1,4 @@
From 4b59f933529474fa40301cad4efdfe5e59dbf849 Mon Sep 17 00:00:00 2001
From e2c01a96c6d7748d416bc8b270f513d9bd96afef Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 13 Sep 2014 23:14:43 -0400
Subject: [PATCH] Configurable Keep Spawn Loaded range per world
@ -21,10 +21,10 @@ index b2d74df..36f0087 100644
+ }
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 8d8e415..02e8551 100644
index 842e364..e1c0c0b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -359,8 +359,9 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -353,8 +353,9 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
long j = av();
i = 0;
@ -37,10 +37,10 @@ index 8d8e415..02e8551 100644
if (i1 - j > 1000L) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index f25b6e0..c19c112 100644
index 5223785..7bfb735 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -3238,7 +3238,7 @@ public abstract class World implements IBlockAccess {
@@ -3228,7 +3228,7 @@ public abstract class World implements IBlockAccess {
BlockPosition blockposition = this.getSpawn();
int k = i * 16 + 8 - blockposition.getX();
int l = j * 16 + 8 - blockposition.getZ();

View file

@ -1,14 +1,14 @@
From fceddc67b91324c40ed6247fda6d0013ffae368c Mon Sep 17 00:00:00 2001
From 0ca2c45f3293c21521e8ff3a5048cca7b53edf58 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sun, 3 Apr 2016 17:48:50 -0400
Subject: [PATCH] Fix Cancelling BlockPlaceEvent triggering physics
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index c19c112..0d0db07 100644
index 7bfb735..75b95b4 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -526,6 +526,7 @@ public abstract class World implements IBlockAccess {
@@ -516,6 +516,7 @@ public abstract class World implements IBlockAccess {
}
public void applyPhysics(BlockPosition blockposition, Block block) {

View file

@ -1,14 +1,14 @@
From f428b285b73ce11e85505b1cf9001aac34ce7ab7 Mon Sep 17 00:00:00 2001
From ec07f804a484921eea0a5440f15c2ebe95ff7469 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 5 Apr 2016 19:42:22 -0400
Subject: [PATCH] Don't spam reload spawn chunks in nether/end
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 0d0db07..8f3adc5 100644
index 75b95b4..91bbc75 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -3235,6 +3235,7 @@ public abstract class World implements IBlockAccess {
@@ -3225,6 +3225,7 @@ public abstract class World implements IBlockAccess {
return this.N;
}

View file

@ -1,4 +1,4 @@
From 6ccec30f3b3880fc79844051e9e47796d1477967 Mon Sep 17 00:00:00 2001
From 1afe6ec3716226403ae8fd91217c07d9c1342999 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Wed, 13 Apr 2016 00:25:28 -0400
Subject: [PATCH] Remove unused World Tile Entity List
@ -6,7 +6,7 @@ Subject: [PATCH] Remove unused World Tile Entity List
Massive hit to performance and it is completely unnecessary.
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 8f3adc5..0c20216 100644
index 91bbc75..b3dd456 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -69,7 +69,7 @@ public abstract class World implements IBlockAccess {
@ -18,7 +18,7 @@ index 8f3adc5..0c20216 100644
public final List<TileEntity> tileEntityListTick = Lists.newArrayList();
private final List<TileEntity> b = Lists.newArrayList();
private final Set<TileEntity> tileEntityListUnload = Sets.newHashSet(); // Paper
@@ -1564,7 +1564,7 @@ public abstract class World implements IBlockAccess {
@@ -1554,7 +1554,7 @@ public abstract class World implements IBlockAccess {
// CraftBukkit start - From below, clean up tile entities before ticking them
if (!this.tileEntityListUnload.isEmpty()) {
this.tileEntityListTick.removeAll(this.tileEntityListUnload);
@ -27,7 +27,7 @@ index 8f3adc5..0c20216 100644
this.tileEntityListUnload.clear();
}
// CraftBukkit end
@@ -1615,7 +1615,7 @@ public abstract class World implements IBlockAccess {
@@ -1605,7 +1605,7 @@ public abstract class World implements IBlockAccess {
if (tileentity.x()) {
tilesThisCycle--;
this.tileEntityListTick.remove(tileTickPosition--);
@ -36,7 +36,7 @@ index 8f3adc5..0c20216 100644
if (this.isLoaded(tileentity.getPosition())) {
this.getChunkAtWorldCoords(tileentity.getPosition()).d(tileentity.getPosition());
}
@@ -1653,7 +1653,7 @@ public abstract class World implements IBlockAccess {
@@ -1643,7 +1643,7 @@ public abstract class World implements IBlockAccess {
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
// CraftBukkit start
// From above, don't screw this up - SPIGOT-1746
@ -45,7 +45,7 @@ index 8f3adc5..0c20216 100644
this.a(tileentity1);
}
// CraftBukkit end
@@ -1673,9 +1673,9 @@ public abstract class World implements IBlockAccess {
@@ -1663,9 +1663,9 @@ public abstract class World implements IBlockAccess {
protected void l() {}
public boolean a(TileEntity tileentity) {
@ -57,7 +57,7 @@ index 8f3adc5..0c20216 100644
this.tileEntityListTick.add(tileentity);
}
@@ -2145,7 +2145,7 @@ public abstract class World implements IBlockAccess {
@@ -2135,7 +2135,7 @@ public abstract class World implements IBlockAccess {
} else {
if (tileentity != null) {
this.b.remove(tileentity);

View file

@ -1,4 +1,4 @@
From 8b6deba310ca28fe576b153349c97cb9aaab5f65 Mon Sep 17 00:00:00 2001
From 426c5a1d94eef4816e659f6384148abc4e849b26 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 14 Apr 2016 21:01:39 -0400
Subject: [PATCH] Fix Bugs with Spigot Mob Spawn Logic
@ -14,10 +14,10 @@ Specially with servers using smaller mob spawn ranges than view distance, as wel
This patch returns mob counting to use all loaded chunks, and 17x17 division.
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index f7452b3..773b153 100644
index 7144227..b94cdad 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -704,7 +704,7 @@ public class Chunk {
@@ -674,7 +674,7 @@ public class Chunk {
i = this.entitySlices.length - 1;
}

View file

@ -1,14 +1,14 @@
From f9b11fc494edca4b6c42d180fa214cac92fadcdf Mon Sep 17 00:00:00 2001
From 96f6ebe5e1b8a63789ffffb307ef1cf856c434de Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Fri, 22 Apr 2016 20:34:21 -0500
Subject: [PATCH] Check entity count additions and mark entities removed
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 773b153..4953e97 100644
index b94cdad..904141a 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -661,12 +661,36 @@ public class Chunk {
@@ -631,12 +631,36 @@ public class Chunk {
k = this.entitySlices.length - 1;
}
@ -45,7 +45,7 @@ index 773b153..4953e97 100644
if (entity instanceof EntityItem) {
itemCounts[k]++;
} else if (entity instanceof IInventory) {
@@ -711,6 +735,7 @@ public class Chunk {
@@ -681,6 +705,7 @@ public class Chunk {
} else if (entity instanceof IInventory) {
inventoryEntityCounts[i]--;
}
@ -54,10 +54,10 @@ index 773b153..4953e97 100644
// Spigot start - decrement creature type count
// Keep this synced up with World.a(Class)
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 0c20216..2e767e4 100644
index b3dd456..5c3e075 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1749,7 +1749,7 @@ public abstract class World implements IBlockAccess {
@@ -1739,7 +1739,7 @@ public abstract class World implements IBlockAccess {
}
int k = MathHelper.floor(entity.locX / 16.0D);

View file

@ -1,4 +1,4 @@
From 31e86975e071304b48ecb3c603ab1a4774e81720 Mon Sep 17 00:00:00 2001
From 3b596ccedcfa761caa54a479c5aa43c6a3b5053c Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 28 Apr 2016 00:57:27 -0400
Subject: [PATCH] remove null possibility for getServer singleton
@ -6,10 +6,10 @@ Subject: [PATCH] remove null possibility for getServer singleton
to stop IDE complaining about potential NPE
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 02e8551..3b04681 100644
index e1c0c0b..ec9f037 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -59,6 +59,7 @@ import java.util.Queue;
@@ -54,6 +54,7 @@ import co.aikar.timings.MinecraftTimings; // Paper
public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
@ -17,7 +17,7 @@ index 02e8551..3b04681 100644
public static final Logger LOGGER = LogManager.getLogger();
public static final File a = new File("usercache.json");
public Convertable convertable;
@@ -127,6 +128,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -121,6 +122,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
// CraftBukkit end
public MinecraftServer(OptionSet options, Proxy proxy, DataConverterManager dataconvertermanager, YggdrasilAuthenticationService yggdrasilauthenticationservice, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, UserCache usercache) {
@ -25,7 +25,7 @@ index 02e8551..3b04681 100644
io.netty.util.ResourceLeakDetector.setEnabled( false ); // Spigot - disable
this.e = proxy;
this.U = yggdrasilauthenticationservice;
@@ -1624,7 +1626,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
@@ -1591,7 +1593,7 @@ public abstract class MinecraftServer implements Runnable, ICommandListener, IAs
// CraftBukkit start
@Deprecated
public static MinecraftServer getServer() {

View file

@ -1,4 +1,4 @@
From 8e9e6eadd852b2360b4be33223a402533f0f1fe6 Mon Sep 17 00:00:00 2001
From d0e77b7d023cdba51d177126f4592d26da939ee1 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 29 Apr 2016 20:02:00 -0400
Subject: [PATCH] Improve Maps (in item frames) performance and bug fixes
@ -48,10 +48,10 @@ index 6c8da79..38e88d8 100644
Iterator iterator = this.trackedPlayers.iterator(); // CraftBukkit
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 2e767e4..741850e 100644
index 5c3e075..0f1ee49 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1154,6 +1154,7 @@ public abstract class World implements IBlockAccess {
@@ -1144,6 +1144,7 @@ public abstract class World implements IBlockAccess {
{
if ( iter.next().trackee == entity )
{

View file

@ -1,4 +1,4 @@
From 82bf7c14dccf3f1c88c4760a2edf709c542358fb Mon Sep 17 00:00:00 2001
From 2746640f12a29c656745e7ea06b1f2ddd9817fb8 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 12 May 2016 01:55:17 -0400
Subject: [PATCH] Do not mark chunks as active for neighbor updates
@ -6,10 +6,10 @@ Subject: [PATCH] Do not mark chunks as active for neighbor updates
Fixes chunk unload issues
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 1e172b8..90eba27 100644
index 904141a..d7b9581 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -1021,25 +1021,25 @@ public class Chunk {
@@ -991,25 +991,25 @@ public class Chunk {
public void loadNearby(IChunkProvider ichunkprovider, ChunkGenerator chunkgenerator) {
world.timings.syncChunkLoadPostTimer.startTiming(); // Spigot
@ -44,7 +44,7 @@ index 1e172b8..90eba27 100644
if (chunk4 != null) {
chunk4.a(chunkgenerator);
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 8ee8e80..1bc001d 100644
index 3cf2d8b..c2c6d3a 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -197,7 +197,7 @@ public class ChunkProviderServer implements IChunkProvider {

View file

@ -1,24 +1,24 @@
From e5bd49a93687c1a4aed20c45b62283540017f6a0 Mon Sep 17 00:00:00 2001
From 5a965808414b88283da8dc7aa36f9dcb6090311f Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 12 May 2016 02:03:56 -0400
Subject: [PATCH] Unmark chunk as unloading when unload is cancelled
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 1e172b8..f72b1f8 100644
index d7b9581..40d4c9c 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -46,7 +46,7 @@ public class Chunk {
@@ -47,7 +47,7 @@ public class Chunk {
private long w;
private int x;
private ConcurrentLinkedQueue<BlockPosition> y;
- public boolean d;
+ public boolean d;public void setShouldUnload(boolean unload) { this.d = unload; } // Paper // OBFHELPER
protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
public int lightUpdates; // Paper - Number of queued light updates for this chunk
// Paper start
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 1bc001d..7820ad9 100644
index c2c6d3a..7427e6e 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -303,6 +303,7 @@ public class ChunkProviderServer implements IChunkProvider {
@ -26,9 +26,9 @@ index 1bc001d..7820ad9 100644
if (chunk != null && chunk.d) {
+ chunk.setShouldUnload(false); // Paper
if (chunk.hasLightUpdates()) continue; // Paper - Don't unload chunks with pending light updates.
// CraftBukkit start
ChunkUnloadEvent event = new ChunkUnloadEvent(chunk.bukkitChunk);
this.world.getServer().getPluginManager().callEvent(event);
--
2.8.2