SPIGOT-3254: Check chunks are loaded before ticking entities as per previous versions.

This commit is contained in:
md_5 2017-05-20 11:27:48 +10:00
parent 4377dac138
commit cda27c992d

View File

@ -448,7 +448,21 @@
} }
} }
} }
@@ -1252,6 +1501,7 @@ @@ -1241,6 +1490,13 @@
}
public void entityJoinedWorld(Entity entity, boolean flag) {
+ // CraftBukkit start - check if chunks are loaded as done in previous versions
+ Chunk startingChunk = this.getChunkIfLoaded(MathHelper.floor(entity.locX) >> 4, MathHelper.floor(entity.locZ) >> 4);
+ if (flag && !(startingChunk != null && startingChunk.areNeighborsLoaded(2))) {
+ return;
+ }
+ // CraftBukkit end
+
entity.M = entity.locX;
entity.N = entity.locY;
entity.O = entity.locZ;
@@ -1252,6 +1508,7 @@
entity.leaveVehicle(); entity.leaveVehicle();
} else { } else {
entity.B_(); entity.B_();
@ -456,7 +470,7 @@
} }
} }
@@ -1543,11 +1793,18 @@ @@ -1543,11 +1800,18 @@
} }
} }
@ -475,7 +489,7 @@
TileEntity tileentity = null; TileEntity tileentity = null;
if (this.O) { if (this.O) {
@@ -1582,6 +1839,14 @@ @@ -1582,6 +1846,14 @@
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) { public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
if (!this.E(blockposition)) { if (!this.E(blockposition)) {
if (tileentity != null && !tileentity.y()) { if (tileentity != null && !tileentity.y()) {
@ -490,7 +504,7 @@
if (this.O) { if (this.O) {
tileentity.setPosition(blockposition); tileentity.setPosition(blockposition);
Iterator iterator = this.b.iterator(); Iterator iterator = this.b.iterator();
@@ -1741,6 +2006,14 @@ @@ -1741,6 +2013,14 @@
} }
this.o = MathHelper.a(this.o, 0.0F, 1.0F); this.o = MathHelper.a(this.o, 0.0F, 1.0F);
@ -505,7 +519,7 @@
} }
} }
} }
@@ -1878,7 +2151,10 @@ @@ -1878,7 +2158,10 @@
} }
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) { public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@ -517,7 +531,7 @@
return false; return false;
} else { } else {
int i = 0; int i = 0;
@@ -2045,7 +2321,7 @@ @@ -2045,7 +2328,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
@ -526,7 +540,7 @@
arraylist.add(entity); arraylist.add(entity);
} }
} }
@@ -2060,7 +2336,7 @@ @@ -2060,7 +2343,7 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
@ -535,7 +549,7 @@
arraylist.add(entity); arraylist.add(entity);
} }
} }
@@ -2109,7 +2385,7 @@ @@ -2109,7 +2392,7 @@
} }
} }
@ -544,7 +558,7 @@
} }
@Nullable @Nullable
@@ -2130,8 +2406,17 @@ @@ -2130,8 +2413,17 @@
while (iterator.hasNext()) { while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
@ -563,7 +577,7 @@
++i; ++i;
} }
} }
@@ -2140,12 +2425,18 @@ @@ -2140,12 +2432,18 @@
} }
public void a(Collection<Entity> collection) { public void a(Collection<Entity> collection) {
@ -583,7 +597,7 @@
this.b(entity); this.b(entity);
} }
@@ -2159,7 +2450,13 @@ @@ -2159,7 +2457,13 @@
IBlockData iblockdata = this.getType(blockposition); IBlockData iblockdata = this.getType(blockposition);
AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition); AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().d(this, blockposition);
@ -598,7 +612,7 @@
} }
public int getSeaLevel() { public int getSeaLevel() {
@@ -2269,6 +2566,11 @@ @@ -2269,6 +2573,11 @@
for (int i = 0; i < this.players.size(); ++i) { for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i); EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@ -610,7 +624,7 @@
if (predicate.apply(entityhuman1)) { if (predicate.apply(entityhuman1)) {
double d5 = entityhuman1.d(d0, d1, d2); double d5 = entityhuman1.d(d0, d1, d2);
@@ -2437,6 +2739,16 @@ @@ -2437,6 +2746,16 @@
public void everyoneSleeping() {} public void everyoneSleeping() {}
@ -627,7 +641,7 @@
public float h(float f) { public float h(float f) {
return (this.p + (this.q - this.p) * f) * this.j(f); return (this.p + (this.q - this.p) * f) * this.j(f);
} }
@@ -2654,7 +2966,7 @@ @@ -2654,7 +2973,7 @@
int l = j * 16 + 8 - blockposition.getZ(); int l = j * 16 + 8 - blockposition.getZ();
boolean flag = true; boolean flag = true;