Clean up async lighting patch

This commit is contained in:
Byteflux 2015-07-01 00:27:58 -07:00
parent ca8627834d
commit 6d7eed6d75
7 changed files with 179 additions and 330 deletions

View File

@ -1,11 +1,61 @@
From 95ec45d55c70af957d01dcea841bdf8d9ef02b35 Mon Sep 17 00:00:00 2001 From cc4cc3c5874b1cdd1f1a1e5488d6b729f3b303ec Mon Sep 17 00:00:00 2001
From: Roman Alexander <romanalexander@users.noreply.github.com> From: Byteflux <byte@byteflux.net>
Date: Wed, 25 Mar 2015 20:27:13 -0500 Date: Wed, 1 Jul 2015 00:18:10 -0700
Subject: [PATCH] Configurable async light updates Subject: [PATCH] Configurable async light updates
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
index 7242d45..ab4de94 100644
--- a/src/main/java/net/minecraft/server/Chunk.java
+++ b/src/main/java/net/minecraft/server/Chunk.java
@@ -11,6 +11,8 @@ import java.util.Map;
import java.util.Random;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.concurrent.atomic.AtomicInteger; // PaperSpigot
+
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -43,6 +45,10 @@ public class Chunk {
private int v;
private ConcurrentLinkedQueue<BlockPosition> w;
protected gnu.trove.map.hash.TObjectIntHashMap<Class> entityCount = new gnu.trove.map.hash.TObjectIntHashMap<Class>(); // Spigot
+ // PaperSpigot start - Asynchronous light updates
+ public AtomicInteger pendingLightUpdates = new AtomicInteger();
+ public long lightUpdateTime;
+ // PaperSpigot end
// CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
private int neighbors = 0x1 << 12;
@@ -274,7 +280,7 @@ public class Chunk {
private void a(int i, int j, int k, int l) {
if (l > k && this.world.areChunksLoaded(new BlockPosition(i, 0, j), 16)) {
for (int i1 = k; i1 < l; ++i1) {
- this.world.c(EnumSkyBlock.SKY, new BlockPosition(i, i1, j));
+ this.world.updateLight(EnumSkyBlock.SKY, new BlockPosition(i, i1, j)); // PaperSpigot - Asynchronous lighting updates
}
this.q = true;
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 975d666..ae0f276 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -53,6 +53,12 @@ public class ChunkProviderServer implements IChunkProvider {
}
public void queueUnload(int i, int j) {
+ // PaperSpigot start - Asynchronous lighting updates
+ Chunk chunk = chunks.get(LongHash.toLong(i, j));
+ if (chunk != null && chunk.world.paperSpigotConfig.useAsyncLighting && (chunk.pendingLightUpdates.get() > 0 || chunk.world.getTime() - chunk.lightUpdateTime < 20)) {
+ return;
+ }
+ // PaperSpigot end
if (this.world.worldProvider.e()) {
if (!this.world.c(i, j)) {
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index b681a9f..f507134 100644 index b681a9f..8ee0cec 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -18,6 +18,12 @@ import org.bukkit.generator.ChunkGenerator; @@ -18,6 +18,12 @@ import org.bukkit.generator.ChunkGenerator;
@ -21,317 +71,117 @@ index b681a9f..f507134 100644
// CraftBukkit start // CraftBukkit start
// CraftBukkit end // CraftBukkit end
@@ -714,22 +720,26 @@ public abstract class World implements IBlockAccess { @@ -126,6 +132,7 @@ public abstract class World implements IBlockAccess {
blockposition = new BlockPosition(blockposition.getX(), 0, blockposition.getZ()); public static boolean haveWeSilencedAPhysicsCrash;
} public static String blockLocation;
private int tileTickPosition;
+ private ExecutorService lightingExecutor; // PaperSpigot - Asynchronous lighting updates
+ // PaperSpigot start - configurable async light updates public static long chunkToKey(int x, int z)
if (!this.isValidLocation(blockposition)) { {
return enumskyblock.c; @@ -493,7 +500,7 @@ public abstract class World implements IBlockAccess {
- } else if (!this.isLoaded(blockposition)) {
+ } if (!this.worldProvider.o()) {
+ for (i1 = k; i1 <= l; ++i1) {
+ Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); - this.c(EnumSkyBlock.SKY, new BlockPosition(i, i1, j));
+ if (chunk == null) { + this.updateLight(EnumSkyBlock.SKY, new BlockPosition(i, i1, j)); // PaperSpigot - Asynchronous lighting updates
return enumskyblock.c;
} else {
- Chunk chunk = this.getChunkAtWorldCoords(blockposition);
-
+ // PaperSpigot end
return chunk.getBrightness(enumskyblock, blockposition);
} }
} }
public void a(EnumSkyBlock enumskyblock, BlockPosition blockposition, int i) { @@ -2308,10 +2315,10 @@ public abstract class World implements IBlockAccess {
if (this.isValidLocation(blockposition)) { boolean flag = false;
- if (this.isLoaded(blockposition)) {
- Chunk chunk = this.getChunkAtWorldCoords(blockposition); if (!this.worldProvider.o()) {
- - flag |= this.c(EnumSkyBlock.SKY, blockposition);
+ // PaperSpigot start - Configurable async light updates + flag |= this.updateLight(EnumSkyBlock.SKY, blockposition); // PaperSpigot - Asynchronous lighting updates
+ Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ if (chunk != null) {
+ // PaperSpigot end
chunk.a(enumskyblock, blockposition, i);
this.n(blockposition);
}
@@ -2316,10 +2326,13 @@ public abstract class World implements IBlockAccess {
} }
private int a(BlockPosition blockposition, EnumSkyBlock enumskyblock) { - flag |= this.c(EnumSkyBlock.BLOCK, blockposition);
- if (enumskyblock == EnumSkyBlock.SKY && this.i(blockposition)) { + flag |= this.updateLight(EnumSkyBlock.BLOCK, blockposition); // PaperSpigot - Asynchronous lighting updates
+ // PaperSpigot start - Configurable async light updates return flag;
+ Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); }
+ if (chunk == null || (enumskyblock == EnumSkyBlock.SKY && chunk.d(blockposition))) {
+ // PaperSpigot end
return 15;
} else {
- Block block = this.getType(blockposition).getBlock();
+ Block block = chunk.getType(blockposition); // PaperSpigot - Configurable async light updates
int i = enumskyblock == EnumSkyBlock.SKY ? 0 : block.r();
int j = block.p();
@@ -2358,131 +2371,154 @@ public abstract class World implements IBlockAccess { @@ -2358,10 +2365,10 @@ public abstract class World implements IBlockAccess {
} }
} }
- public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { - public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
- // CraftBukkit start - Use neighbor cache instead of looking up + public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition, Chunk chunk, List<Chunk> neighbors) { // PaperSpigot
// CraftBukkit start - Use neighbor cache instead of looking up
- Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); - Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
- if (chunk == null || !chunk.areNeighborsLoaded(1) /*!this.areChunksLoaded(blockposition, 17, false)*/) { - if (chunk == null || !chunk.areNeighborsLoaded(1) /*!this.areChunksLoaded(blockposition, 17, false)*/) {
- // CraftBukkit end + //Chunk chunk = this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
- return false; + if (chunk == null /*|| !chunk.areNeighborsLoaded(1)*/ /*!this.areChunksLoaded(blockposition, 17, false)*/) {
- } else { // CraftBukkit end
- int i = 0; return false;
- int j = 0; } else {
- @@ -2479,11 +2486,66 @@ public abstract class World implements IBlockAccess {
- this.methodProfiler.a("getBrightness");
- int k = this.b(enumskyblock, blockposition);
- int l = this.a(blockposition, enumskyblock);
- int i1 = blockposition.getX();
- int j1 = blockposition.getY();
- int k1 = blockposition.getZ();
- int l1;
- int i2;
- int j2;
- int k2;
- int l2;
- int i3;
- int j3;
- int k3;
-
- if (l > k) {
- this.H[j++] = 133152;
- } else if (l < k) {
- this.H[j++] = 133152 | k << 18;
-
- while (i < j) {
- l1 = this.H[i++];
- i2 = (l1 & 63) - 32 + i1;
- j2 = (l1 >> 6 & 63) - 32 + j1;
- k2 = (l1 >> 12 & 63) - 32 + k1;
- int l3 = l1 >> 18 & 15;
- BlockPosition blockposition1 = new BlockPosition(i2, j2, k2);
-
- l2 = this.b(enumskyblock, blockposition1);
- if (l2 == l3) {
- this.a(enumskyblock, blockposition1, 0);
- if (l3 > 0) {
- i3 = MathHelper.a(i2 - i1);
- j3 = MathHelper.a(j2 - j1);
- k3 = MathHelper.a(k2 - k1);
- if (i3 + j3 + k3 < 17) {
- BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
- EnumDirection[] aenumdirection = EnumDirection.values();
- int i4 = aenumdirection.length;
-
- for (int j4 = 0; j4 < i4; ++j4) {
- EnumDirection enumdirection = aenumdirection[j4];
- int k4 = i2 + enumdirection.getAdjacentX();
- int l4 = j2 + enumdirection.getAdjacentY();
- int i5 = k2 + enumdirection.getAdjacentZ();
-
- blockposition_mutableblockposition.c(k4, l4, i5);
- int j5 = Math.max(1, this.getType(blockposition_mutableblockposition).getBlock().p());
-
- l2 = this.b(enumskyblock, (BlockPosition) blockposition_mutableblockposition);
- if (l2 == l3 - j5 && j < this.H.length) {
- this.H[j++] = k4 - i1 + 32 | l4 - j1 + 32 << 6 | i5 - k1 + 32 << 12 | l3 - j5 << 18;
+ // PaperSpigot start - Configurable async light updates
+ private ExecutorService service = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("PaperSpigot - Lighting Thread").build());
+ public boolean c(final EnumSkyBlock enumskyblock, final BlockPosition blockposition) {
+ Callable<Boolean> callable = new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ // CraftBukkit start - Use neighbor cache instead of looking up
+ Chunk chunk = World.this.getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4);
+ if (chunk == null || !chunk.areNeighborsLoaded(1) /*!this.areChunksLoaded(blockposition, 17, false)*/) {
+ // CraftBukkit end
+ return false;
+ } else {
+ int i = 0;
+ int j = 0;
+
+ World.this.methodProfiler.a("getBrightness");
+ int k = World.this.b(enumskyblock, blockposition);
+ int l = World.this.a(blockposition, enumskyblock);
+ int i1 = blockposition.getX();
+ int j1 = blockposition.getY();
+ int k1 = blockposition.getZ();
+ int l1;
+ int i2;
+ int j2;
+ int k2;
+ int l2;
+ int i3;
+ int j3;
+ int k3;
+
+ if (l > k) {
+ World.this.H[j++] = 133152;
+ } else if (l < k) {
+ World.this.H[j++] = 133152 | k << 18;
+
+ while (i < j) {
+ l1 = World.this.H[i++];
+ i2 = (l1 & 63) - 32 + i1;
+ j2 = (l1 >> 6 & 63) - 32 + j1;
+ k2 = (l1 >> 12 & 63) - 32 + k1;
+ int l3 = l1 >> 18 & 15;
+ BlockPosition blockposition1 = new BlockPosition(i2, j2, k2);
+
+ l2 = World.this.b(enumskyblock, blockposition1);
+ if (l2 == l3) {
+ World.this.a(enumskyblock, blockposition1, 0);
+ if (l3 > 0) {
+ i3 = MathHelper.a(i2 - i1);
+ j3 = MathHelper.a(j2 - j1);
+ k3 = MathHelper.a(k2 - k1);
+ if (i3 + j3 + k3 < 17) {
+ BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
+ EnumDirection[] aenumdirection = EnumDirection.values();
+ int i4 = aenumdirection.length;
+
+ for (int j4 = 0; j4 < i4; ++j4) {
+ EnumDirection enumdirection = aenumdirection[j4];
+ int k4 = i2 + enumdirection.getAdjacentX();
+ int l4 = j2 + enumdirection.getAdjacentY();
+ int i5 = k2 + enumdirection.getAdjacentZ();
+
+ blockposition_mutableblockposition.c(k4, l4, i5);
+ Chunk lightChunk = World.this.getChunkIfLoaded(blockposition_mutableblockposition.getX() >> 4, blockposition_mutableblockposition.getZ() >> 4);
+ int j5;
+ if (lightChunk != null) {
+ j5 = Math.max(1, lightChunk.getType(blockposition_mutableblockposition).p());
+ } else {
+ j5 = 255;
+ }
+
+ l2 = World.this.b(enumskyblock, (BlockPosition) blockposition_mutableblockposition);
+ if (l2 == l3 - j5 && j < World.this.H.length) {
+ World.this.H[j++] = k4 - i1 + 32 | l4 - j1 + 32 << 6 | i5 - k1 + 32 << 12 | l3 - j5 << 18;
+ }
+ }
} }
} }
}
}
- }
- }
- i = 0; + // PaperSpigot start - Asynchronous light updates
- } + if (chunk.world.paperSpigotConfig.useAsyncLighting) {
+ i = 0; + chunk.pendingLightUpdates.decrementAndGet();
+ } + if (neighbors != null) {
+ for (Chunk neighbor : neighbors) {
- this.methodProfiler.b(); + neighbor.pendingLightUpdates.decrementAndGet();
- this.methodProfiler.a("checkedPosition < toCheckCount");
-
- while (i < j) {
- l1 = this.H[i++];
- i2 = (l1 & 63) - 32 + i1;
- j2 = (l1 >> 6 & 63) - 32 + j1;
- k2 = (l1 >> 12 & 63) - 32 + k1;
- BlockPosition blockposition2 = new BlockPosition(i2, j2, k2);
- int k5 = this.b(enumskyblock, blockposition2);
-
- l2 = this.a(blockposition2, enumskyblock);
- if (l2 != k5) {
- this.a(enumskyblock, blockposition2, l2);
- if (l2 > k5) {
- i3 = Math.abs(i2 - i1);
- j3 = Math.abs(j2 - j1);
- k3 = Math.abs(k2 - k1);
- boolean flag = j < this.H.length - 6;
-
- if (i3 + j3 + k3 < 17 && flag) {
- if (this.b(enumskyblock, blockposition2.west()) < l2) {
- this.H[j++] = i2 - 1 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
- }
+ World.this.methodProfiler.b();
+ World.this.methodProfiler.a("checkedPosition < toCheckCount");
+
+ while (i < j) {
+ l1 = World.this.H[i++];
+ i2 = (l1 & 63) - 32 + i1;
+ j2 = (l1 >> 6 & 63) - 32 + j1;
+ k2 = (l1 >> 12 & 63) - 32 + k1;
+ BlockPosition blockposition2 = new BlockPosition(i2, j2, k2);
+ int k5 = World.this.b(enumskyblock, blockposition2);
+
+ l2 = World.this.a(blockposition2, enumskyblock);
+ if (l2 != k5) {
+ World.this.a(enumskyblock, blockposition2, l2);
+ if (l2 > k5) {
+ i3 = Math.abs(i2 - i1);
+ j3 = Math.abs(j2 - j1);
+ k3 = Math.abs(k2 - k1);
+ boolean flag = j < World.this.H.length - 6;
+
+ if (i3 + j3 + k3 < 17 && flag) {
+ if (World.this.b(enumskyblock, blockposition2.west()) < l2) {
+ World.this.H[j++] = i2 - 1 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
+ }
- if (this.b(enumskyblock, blockposition2.east()) < l2) {
- this.H[j++] = i2 + 1 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
- }
+ if (World.this.b(enumskyblock, blockposition2.east()) < l2) {
+ World.this.H[j++] = i2 + 1 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
+ }
- if (this.b(enumskyblock, blockposition2.down()) < l2) {
- this.H[j++] = i2 - i1 + 32 + (j2 - 1 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
- }
+ if (World.this.b(enumskyblock, blockposition2.down()) < l2) {
+ World.this.H[j++] = i2 - i1 + 32 + (j2 - 1 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
+ }
- if (this.b(enumskyblock, blockposition2.up()) < l2) {
- this.H[j++] = i2 - i1 + 32 + (j2 + 1 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
- }
+ if (World.this.b(enumskyblock, blockposition2.up()) < l2) {
+ World.this.H[j++] = i2 - i1 + 32 + (j2 + 1 - j1 + 32 << 6) + (k2 - k1 + 32 << 12);
+ }
- if (this.b(enumskyblock, blockposition2.north()) < l2) {
- this.H[j++] = i2 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 - 1 - k1 + 32 << 12);
- }
+ if (World.this.b(enumskyblock, blockposition2.north()) < l2) {
+ World.this.H[j++] = i2 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 - 1 - k1 + 32 << 12);
+ }
- if (this.b(enumskyblock, blockposition2.south()) < l2) {
- this.H[j++] = i2 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 + 1 - k1 + 32 << 12);
+ if (World.this.b(enumskyblock, blockposition2.south()) < l2) {
+ World.this.H[j++] = i2 - i1 + 32 + (j2 - j1 + 32 << 6) + (k2 + 1 - k1 + 32 << 12);
+ } + }
+ } + }
}
}
}
+
+ World.this.methodProfiler.b();
+ return true;
}
}
-
- this.methodProfiler.b();
- return true;
+ };
+ if (paperSpigotConfig.useAsyncLighting) {
+ service.submit(callable);
+ } else {
+ try {
+ return callable.call();
+ } catch(Exception ignore) {
+ } + }
}
+ return true;
}
+ // PaperSpigot end + // PaperSpigot end
this.methodProfiler.b();
return true;
}
}
+ /**
+ * PaperSpigot - Asynchronous lighting updates
+ */
+ public boolean updateLight(final EnumSkyBlock enumskyblock, final BlockPosition position) {
+ int x = position.getX();
+ int z = position.getZ();
+ final Chunk chunk = this.getChunkIfLoaded(x >> 4, z >> 4);
+ if (chunk == null || (!chunk.world.paperSpigotConfig.useAsyncLighting && !chunk.areNeighborsLoaded(1))) {
+ return false;
+ }
+
+ if (!chunk.world.paperSpigotConfig.useAsyncLighting) {
+ return this.c(enumskyblock, position, chunk, null);
+ }
+
+ if (lightingExecutor == null) {
+ lightingExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("PaperSpigot - Lighting Thread").build());
+ }
+
+ chunk.pendingLightUpdates.incrementAndGet();
+ chunk.lightUpdateTime = chunk.world.getTime();
+
+ final List<Chunk> neighbors = new ArrayList<Chunk>();
+ for (int cx = (x >> 4) - 1; cx < (x >> 4) + 1; ++cx) {
+ for (int cz = (z >> 4) - 1; cz < (z >> 4) + 1; ++cz) {
+ if (this.chunkProvider.isChunkLoaded(cx, cz)) {
+ Chunk neighbor = this.getChunkAt(cx, cz);
+ if (neighbor != chunk) {
+ neighbor.pendingLightUpdates.incrementAndGet();
+ neighbor.lightUpdateTime = chunk.world.getTime();
+ neighbors.add(neighbor);
+ }
+ }
+ }
+ }
+
+ lightingExecutor.submit(new Runnable() {
+ @Override
+ public void run() {
+ World.this.c(enumskyblock, position, chunk, neighbors);
+ }
+ });
+ return true;
+ }
+
public boolean a(boolean flag) { public boolean a(boolean flag) {
return false; return false;
}
diff --git a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java diff --git a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java b/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java
index bcd8b65..fa9ae6c 100644 index bcd8b65..fa9ae6c 100644
--- a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java --- a/src/main/java/org/github/paperspigot/PaperSpigotWorldConfig.java

View File

@ -1,19 +1,18 @@
From 5044c22415ac2f084b90a5c0e5cdad1ffa7cec63 Mon Sep 17 00:00:00 2001 From bd0b3dc6c20a561d4ad962f80153766bcca49032 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net> From: Byteflux <byte@byteflux.net>
Date: Tue, 30 Jun 2015 20:45:24 -0700 Date: Tue, 30 Jun 2015 20:45:24 -0700
Subject: [PATCH] Force load chunks for specific entities that fly through Subject: [PATCH] Force load chunks for specific entities that fly through
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index 975d666..f2e13ad 100644 index ae0f276..0e6a37f 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java --- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java +++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -53,6 +53,18 @@ public class ChunkProviderServer implements IChunkProvider { @@ -59,6 +59,17 @@ public class ChunkProviderServer implements IChunkProvider {
return;
} }
// PaperSpigot end
public void queueUnload(int i, int j) {
+ // PaperSpigot start - Don't unload chunk if it contains an entity that loads chunks + // PaperSpigot start - Don't unload chunk if it contains an entity that loads chunks
+ Chunk chunk = chunks.get(LongHash.toLong(i, j));
+ if (chunk != null) { + if (chunk != null) {
+ for (List<Entity> entities : chunk.entitySlices) { + for (List<Entity> entities : chunk.entitySlices) {
+ for (Entity entity : entities) { + for (Entity entity : entities) {
@ -138,10 +137,10 @@ index 1daba4e..3e16472 100644
protected void b(NBTTagCompound nbttagcompound) { protected void b(NBTTagCompound nbttagcompound) {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index f507134..a7b5062 100644 index 8ee0cec..6712fbf 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -1634,6 +1634,7 @@ public abstract class World implements IBlockAccess { @@ -1631,6 +1631,7 @@ public abstract class World implements IBlockAccess {
int i1 = MathHelper.floor(entity.locZ / 16.0D); int i1 = MathHelper.floor(entity.locZ / 16.0D);
if (!entity.ad || entity.ae != k || entity.af != l || entity.ag != i1) { if (!entity.ad || entity.ae != k || entity.af != l || entity.ag != i1) {

View File

@ -1,11 +1,11 @@
From 92fdbc3acf9242e72da544a63dcd1b7efb93f6ff Mon Sep 17 00:00:00 2001 From f5631af64117c643683738ea863b7ccadd89313c Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Sun, 31 May 2015 01:44:02 -0500 Date: Sun, 31 May 2015 01:44:02 -0500
Subject: [PATCH] Teleport passenger/vehicle with player Subject: [PATCH] Teleport passenger/vehicle with player
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 2611007..16dbc20 100644 index f76c67d..70ac612 100644
--- a/src/main/java/net/minecraft/server/Entity.java --- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java
@@ -41,6 +41,15 @@ public abstract class Entity implements ICommandListener { @@ -41,6 +41,15 @@ public abstract class Entity implements ICommandListener {
@ -24,7 +24,7 @@ index 2611007..16dbc20 100644
private static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D); private static final AxisAlignedBB a = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
private static int entityCount; private static int entityCount;
private int id; private int id;
@@ -1953,7 +1962,7 @@ public abstract class Entity implements ICommandListener { @@ -1966,7 +1975,7 @@ public abstract class Entity implements ICommandListener {
// minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1); // minecraftserver.getPlayerList().changeWorld(this, j, worldserver, worldserver1);
boolean before = worldserver1.chunkProviderServer.forceChunkLoad; boolean before = worldserver1.chunkProviderServer.forceChunkLoad;
worldserver1.chunkProviderServer.forceChunkLoad = true; worldserver1.chunkProviderServer.forceChunkLoad = true;
@ -33,7 +33,7 @@ index 2611007..16dbc20 100644
worldserver1.chunkProviderServer.forceChunkLoad = before; worldserver1.chunkProviderServer.forceChunkLoad = before;
// CraftBukkit end // CraftBukkit end
this.world.methodProfiler.c("reloading"); this.world.methodProfiler.c("reloading");
@@ -1961,6 +1970,12 @@ public abstract class Entity implements ICommandListener { @@ -1974,6 +1983,12 @@ public abstract class Entity implements ICommandListener {
if (entity != null) { if (entity != null) {
entity.n(this); entity.n(this);
@ -47,7 +47,7 @@ index 2611007..16dbc20 100644
if (j == 1 && i == 1) { if (j == 1 && i == 1) {
BlockPosition blockposition = this.world.r(worldserver1.getSpawn()); BlockPosition blockposition = this.world.r(worldserver1.getSpawn());
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 68f18d1..269a891 100644 index 5b99842..23753bb 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -449,7 +449,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -449,7 +449,27 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -97,5 +97,5 @@ index 68f18d1..269a891 100644
} }
-- --
2.4.2.windows.1 1.9.5.msysgit.1

View File

@ -1,4 +1,4 @@
From 972c16bba62bcb2570fadb20544d2335fe082276 Mon Sep 17 00:00:00 2001 From c88d7ecef2b00d2f2c9f649eba69cc58eba8c628 Mon Sep 17 00:00:00 2001
From: Iceee <andrew@opticgaming.tv> From: Iceee <andrew@opticgaming.tv>
Date: Thu, 4 Jun 2015 13:55:02 -0700 Date: Thu, 4 Jun 2015 13:55:02 -0700
Subject: [PATCH] Configurable TNT cannon fix Subject: [PATCH] Configurable TNT cannon fix
@ -172,10 +172,10 @@ index 950db4d..8700ab1 100644
world.getServer().getPluginManager().callEvent(event); world.getServer().getPluginManager().callEvent(event);
} }
diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java diff --git a/src/main/java/net/minecraft/server/EntityFallingBlock.java b/src/main/java/net/minecraft/server/EntityFallingBlock.java
index a0452ac..8a3fd44 100644 index 34627c6..cf02997 100644
--- a/src/main/java/net/minecraft/server/EntityFallingBlock.java --- a/src/main/java/net/minecraft/server/EntityFallingBlock.java
+++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java +++ b/src/main/java/net/minecraft/server/EntityFallingBlock.java
@@ -291,4 +291,22 @@ public class EntityFallingBlock extends Entity { @@ -278,4 +278,22 @@ public class EntityFallingBlock extends Entity {
public IBlockData getBlock() { public IBlockData getBlock() {
return this.block; return this.block;
} }
@ -199,10 +199,10 @@ index a0452ac..8a3fd44 100644
+ // PaperSpigot end + // PaperSpigot end
} }
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index db33c98..5290767 100644 index 3e16472..2df3921 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java --- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java +++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -36,6 +36,7 @@ public class EntityTNTPrimed extends Entity { @@ -37,6 +37,7 @@ public class EntityTNTPrimed extends Entity {
this.lastY = d1; this.lastY = d1;
this.lastZ = d2; this.lastZ = d2;
this.source = entityliving; this.source = entityliving;
@ -210,7 +210,7 @@ index db33c98..5290767 100644
} }
protected void h() {} protected void h() {}
@@ -156,7 +157,64 @@ public class EntityTNTPrimed extends Entity { @@ -141,7 +142,64 @@ public class EntityTNTPrimed extends Entity {
return this.source; return this.source;
} }

View File

@ -1,14 +1,14 @@
From f1793ad4101a53ae77153a2bd31594d457222b6a Mon Sep 17 00:00:00 2001 From c3b9b48c6c9c8580777de737a78f621ef7b3cd60 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net> From: Byteflux <byte@byteflux.net>
Date: Fri, 5 Jun 2015 00:43:17 -0700 Date: Fri, 5 Jun 2015 00:43:17 -0700
Subject: [PATCH] FallingBlock and TNT entities collide with specific blocks Subject: [PATCH] FallingBlock and TNT entities collide with specific blocks
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index aec39a8..8258c25 100644 index 6712fbf..04bc301 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -1200,7 +1200,16 @@ public abstract class World implements IBlockAccess { @@ -1197,7 +1197,16 @@ public abstract class World implements IBlockAccess {
} }
if ( block != null ) if ( block != null )
{ {

View File

@ -1,14 +1,14 @@
From 7779fb3770e1782d9a81243e025eb085ad168ff5 Mon Sep 17 00:00:00 2001 From 37e0a3b799d2042d620798f658a4b1d073b528d4 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net> From: Byteflux <byte@byteflux.net>
Date: Tue, 16 Jun 2015 05:30:44 -0700 Date: Tue, 16 Jun 2015 05:30:44 -0700
Subject: [PATCH] Do not filter out large getEntities call Subject: [PATCH] Do not filter out large getEntities call
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 8258c25..480a6d8 100644 index 04bc301..3ece597 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -2563,13 +2563,6 @@ public abstract class World implements IBlockAccess { @@ -2579,13 +2579,6 @@ public abstract class World implements IBlockAccess {
int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D); int k = MathHelper.floor((axisalignedbb.c - 2.0D) / 16.0D);
int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D); int l = MathHelper.floor((axisalignedbb.f + 2.0D) / 16.0D);

View File

@ -1,4 +1,4 @@
From a33575012a7e963a20618af399f8b60e0d4c4dc0 Mon Sep 17 00:00:00 2001 From 5e1ec44c0676857eedf38547f4750d98cdb700e8 Mon Sep 17 00:00:00 2001
From: Byteflux <byte@byteflux.net> From: Byteflux <byte@byteflux.net>
Date: Tue, 16 Jun 2015 05:52:58 -0700 Date: Tue, 16 Jun 2015 05:52:58 -0700
Subject: [PATCH] Optimize explosions Subject: [PATCH] Optimize explosions
@ -122,13 +122,13 @@ index 77fe950..a3fb54b 100644
// this.i[i][this.ticks % 100] = System.nanoTime() - j; // CraftBukkit // 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 diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index 480a6d8..26091b1 100644 index 3ece597..c306035 100644
--- a/src/main/java/net/minecraft/server/World.java --- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java +++ b/src/main/java/net/minecraft/server/World.java
@@ -132,6 +132,7 @@ public abstract class World implements IBlockAccess { @@ -133,6 +133,7 @@ public abstract class World implements IBlockAccess {
public static boolean haveWeSilencedAPhysicsCrash;
public static String blockLocation; public static String blockLocation;
private int tileTickPosition; private int tileTickPosition;
private ExecutorService lightingExecutor; // PaperSpigot - Asynchronous lighting updates
+ public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<Explosion.CacheKey, Float>(); // PaperSpigot - Optimize explosions + public final Map<Explosion.CacheKey, Float> explosionDensityCache = new HashMap<Explosion.CacheKey, Float>(); // PaperSpigot - Optimize explosions
public static long chunkToKey(int x, int z) public static long chunkToKey(int x, int z)