SPIGOT-4752: Fixed inconsistency between isChunkLoaded and chunk load/unload events
By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
@@ -1,32 +1,18 @@
|
||||
--- a/net/minecraft/server/Chunk.java
|
||||
+++ b/net/minecraft/server/Chunk.java
|
||||
@@ -22,6 +22,13 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.collect.Lists;
|
||||
+import java.util.LinkedList;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Chunk implements IChunkAccess {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -95,8 +102,19 @@
|
||||
@@ -95,8 +95,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ this.bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this);
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ public org.bukkit.Chunk bukkitChunk;
|
||||
+ public org.bukkit.Chunk getBukkitChunk() {
|
||||
+ return bukkitChunk;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public boolean mustNotSave;
|
||||
+ public boolean needsDecoration;
|
||||
+ // CraftBukkit end
|
||||
@@ -34,7 +20,7 @@
|
||||
public Chunk(World world, ProtoChunk protochunk) {
|
||||
this(world, protochunk.getPos(), protochunk.getBiomeIndex(), protochunk.p(), protochunk.n(), protochunk.o(), protochunk.q(), protochunk.getSections(), (Consumer) null);
|
||||
Iterator iterator = protochunk.y().iterator();
|
||||
@@ -138,6 +156,7 @@
|
||||
@@ -138,6 +149,7 @@
|
||||
|
||||
this.b(protochunk.r());
|
||||
this.s = true;
|
||||
@@ -42,7 +28,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,9 +247,16 @@
|
||||
@@ -228,9 +240,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +45,7 @@
|
||||
int i = blockposition.getX() & 15;
|
||||
int j = blockposition.getY();
|
||||
int k = blockposition.getZ() & 15;
|
||||
@@ -282,7 +308,8 @@
|
||||
@@ -282,7 +301,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +55,7 @@
|
||||
iblockdata.onPlace(this.world, blockposition, iblockdata1, flag);
|
||||
}
|
||||
|
||||
@@ -382,7 +409,12 @@
|
||||
@@ -382,7 +402,12 @@
|
||||
|
||||
@Nullable
|
||||
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
|
||||
@@ -83,7 +69,7 @@
|
||||
|
||||
if (tileentity == null) {
|
||||
NBTTagCompound nbttagcompound = (NBTTagCompound) this.e.remove(blockposition);
|
||||
@@ -429,6 +461,13 @@
|
||||
@@ -429,6 +454,13 @@
|
||||
tileentity1.m();
|
||||
}
|
||||
|
||||
@@ -97,7 +83,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +496,41 @@
|
||||
@@ -457,6 +489,50 @@
|
||||
|
||||
}
|
||||
|
||||
@@ -113,6 +99,7 @@
|
||||
+ server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(this.bukkitChunk, this.needsDecoration));
|
||||
+
|
||||
+ if (this.needsDecoration) {
|
||||
+ this.needsDecoration = false;
|
||||
+ java.util.Random random = new java.util.Random();
|
||||
+ random.setSeed(world.getSeed());
|
||||
+ long xRand = random.nextLong() / 2L * 2L + 1L;
|
||||
@@ -134,12 +121,20 @@
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void unloadCallback() {
|
||||
+ org.bukkit.Server server = this.world.getServer();
|
||||
+ org.bukkit.event.world.ChunkUnloadEvent unloadEvent = new org.bukkit.event.world.ChunkUnloadEvent(this.bukkitChunk, this.isNeedsSaving());
|
||||
+ server.getPluginManager().callEvent(unloadEvent);
|
||||
+ // note: saving can be prevented, but not forced if no saving is actually required
|
||||
+ this.mustNotSave = !unloadEvent.isSaveChunk();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void markDirty() {
|
||||
this.s = true;
|
||||
}
|
||||
@@ -531,7 +605,7 @@
|
||||
@@ -531,7 +607,7 @@
|
||||
Iterator iterator = this.entitySlices[k].a(oclass).iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -148,7 +143,7 @@
|
||||
|
||||
if (t0.getBoundingBox().c(axisalignedbb) && (predicate == null || predicate.test(t0))) {
|
||||
list.add(t0);
|
||||
@@ -605,7 +679,7 @@
|
||||
@@ -605,7 +681,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isNeedsSaving() {
|
||||
@@ -157,7 +152,7 @@
|
||||
}
|
||||
|
||||
public void d(boolean flag) {
|
||||
@@ -746,7 +820,7 @@
|
||||
@@ -746,7 +822,7 @@
|
||||
|
||||
public void B() {
|
||||
if (this.o instanceof ProtoChunkTickList) {
|
||||
@@ -166,7 +161,7 @@
|
||||
return this.getType(blockposition).getBlock();
|
||||
});
|
||||
this.o = TickListEmpty.a();
|
||||
@@ -756,7 +830,7 @@
|
||||
@@ -756,7 +832,7 @@
|
||||
}
|
||||
|
||||
if (this.p instanceof ProtoChunkTickList) {
|
||||
@@ -175,7 +170,7 @@
|
||||
return this.getFluid(blockposition).getType();
|
||||
});
|
||||
this.p = TickListEmpty.a();
|
||||
@@ -768,12 +842,12 @@
|
||||
@@ -768,12 +844,12 @@
|
||||
}
|
||||
|
||||
public void a(WorldServer worldserver) {
|
||||
|
||||
Reference in New Issue
Block a user