// If not enabled, only do the post-load logic
postLoad(player);
return;
}
try {
CommonPlayer commonPlayer = CommonEntity.get(player);
Object playerHandle = Conversion.toEntityHandle.convert(player);
File source = getSaveFile(player);
CommonTagCompound data = read(source, player);
// First, clear previous player information when loading involves adding new elements
clearEffects(player);
// Refresh attributes
if (data.containsKey("Attributes")) {
NBTUtil.loadAttributes(player, data.get("Attributes", CommonTagList.class));
}
// Load the data
NBTUtil.loadInventory(player.getInventory(), data.createList("Inventory"));
EntityHumanRef.exp.set(playerHandle, data.getValue("XpP", 0.0f));
EntityHumanRef.expLevel.set(playerHandle, data.getValue("XpLevel", 0));
EntityHumanRef.expTotal.set(playerHandle, data.getValue("XpTotal", 0));
if (Common.MC_VERSION.equals("1.5.2")) {
commonPlayer.setHealth(data.getValue("Health", (int) commonPlayer.getMaxHealth()));
} else {
commonPlayer.setHealth(data.getValue("HealF", (float) commonPlayer.getMaxHealth()));
}
// Respawn position
String spawnWorld = data.getValue("SpawnWorld", "");
IntVector3 spawn = null;