From 0c56bfb62fb465cfe5c8b61d3584ff04893cd310 Mon Sep 17 00:00:00 2001 From: Rigby Date: Thu, 16 Jun 2011 04:24:31 +0100 Subject: [PATCH] Possible Player.dat fixes to address issues with switching between Vanilla and Bukkit or vice versa. --- src/main/java/net/minecraft/server/Entity.java | 12 +++++++++++- src/main/java/net/minecraft/server/EntityHuman.java | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java index d11786c931..0937d2eb1a 100644 --- a/src/main/java/net/minecraft/server/Entity.java +++ b/src/main/java/net/minecraft/server/Entity.java @@ -980,7 +980,17 @@ public abstract class Entity { // CraftBukkit end // CraftBukkit Start - reset world - org.bukkit.World world = Bukkit.getServer().getWorld(nbttagcompound.getString("World")); + org.bukkit.World world = null; + if (this instanceof EntityPlayer) { + EntityPlayer entityPlayer = (EntityPlayer) this; + String worldName = nbttagcompound.getString("World"); + if (worldName == "") { + world = (org.bukkit.World) ((CraftServer) Bukkit.getServer()).getServer().a(entityPlayer.dimension); + } else { + world = Bukkit.getServer().getWorld(worldName); + } + } + a(world == null ? null : ((CraftWorld) world).getHandle()); // CraftBukkit End } diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java index 9d43ae5c2c..5b01faaedd 100644 --- a/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java @@ -341,7 +341,13 @@ public abstract class EntityHuman extends EntityLiving { this.a(true, true, false); } - this.spawnWorld = nbttagcompound.getString("SpawnWorld"); // CraftBukkit + // CraftBukkit - Start + this.spawnWorld = nbttagcompound.getString("SpawnWorld"); + if (this.spawnWorld == "") { + CraftServer server = ((WorldServer) world).getServer(); + this.spawnWorld = server.getWorlds().get(0).getName(); + } + // CraftBukkit - End if (nbttagcompound.hasKey("SpawnX") && nbttagcompound.hasKey("SpawnY") && nbttagcompound.hasKey("SpawnZ")) { this.b = new ChunkCoordinates(nbttagcompound.e("SpawnX"), nbttagcompound.e("SpawnY"), nbttagcompound.e("SpawnZ"));