SPIGOT-5123: Snapshot tile entities can end up with a non-null world

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2019-07-03 10:22:42 +10:00
parent efa1cc7359
commit 05a4221869
3 changed files with 8 additions and 31 deletions

View File

@@ -34,7 +34,7 @@
}
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
@@ -53,12 +70,24 @@
@@ -53,6 +70,11 @@
nbttagcompound.setInt("x", this.position.getX());
nbttagcompound.setInt("y", this.position.getY());
nbttagcompound.setInt("z", this.position.getZ());
@@ -46,28 +46,7 @@
return nbttagcompound;
}
}
+ // CraftBukkit start
@Nullable
public static TileEntity create(NBTTagCompound nbttagcompound) {
+ return create(nbttagcompound, null);
+ }
+
+ @Nullable
+ public static TileEntity create(NBTTagCompound nbttagcompound, @Nullable World world) {
+ // CraftBukkit end
String s = nbttagcompound.getString("id");
return (TileEntity) IRegistry.BLOCK_ENTITY_TYPE.getOptional(new MinecraftKey(s)).map((tileentitytypes) -> {
@@ -70,6 +99,7 @@
}
}).map((tileentity) -> {
try {
+ tileentity.setWorld(world); // CraftBukkit
tileentity.load(nbttagcompound);
return tileentity;
} catch (Throwable throwable) {
@@ -168,4 +198,13 @@
@@ -168,4 +190,13 @@
}, this::getPosition});
}
}