Implements a World UID.

This commit is contained in:
Rigby
2011-07-05 04:48:27 +01:00
committed by EvilSeph
parent 5515ce1ff6
commit 9ced39421f
4 changed files with 42 additions and 3 deletions

View File

@@ -910,7 +910,7 @@ public abstract class Entity {
nbttagcompound.a("Air", (short) this.airTicks);
nbttagcompound.a("OnGround", this.onGround);
// CraftBukkit start
nbttagcompound.setString("World", this.world.worldData.name);
nbttagcompound.setLong("WorldUID", this.world.worldData.getWorldUID());
nbttagcompound.setLong("UUIDLeast", this.uniqueId.getLeastSignificantBits());
nbttagcompound.setLong("UUIDMost", this.uniqueId.getMostSignificantBits());
// CraftBukkit end
@@ -982,17 +982,24 @@ public abstract class Entity {
org.bukkit.Server server = Bukkit.getServer();
org.bukkit.World bworld = null;
// TODO: Remove World related checks, replaced with WorldUID.
if (this instanceof EntityPlayer) {
EntityPlayer entityPlayer = (EntityPlayer) this;
String worldName = nbttagcompound.getString("World");
if (worldName == "") {
if (nbttagcompound.hasKey("WorldUID")) {
bworld = server.getWorld(nbttagcompound.getLong("WorldUID"));
} else if ("".equals(worldName)) {
bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(entityPlayer.dimension).getWorld();
} else {
bworld = server.getWorld(worldName);
}
} else {
bworld = server.getWorld(nbttagcompound.getString("World"));
if (nbttagcompound.hasKey("WorldUID")) {
bworld = server.getWorld(nbttagcompound.getLong("WorldUID"));
} else {
bworld = server.getWorld(nbttagcompound.getString("World"));
}
}
this.spawnIn(bworld == null ? null : ((org.bukkit.craftbukkit.CraftWorld) bworld).getHandle());