((WorldServer) worldOld).getPlayerManager().removePlayer(player);
} catch (Exception e) { }
}
player.closeScreen();
GCPlayerStats stats = GCPlayerStats.get(player);
stats.usingPlanetSelectionGui = false;
player.dimension = dimID;
if (ConfigManagerCore.enableDebug)
{
GCLog.info("DEBUG: Sending respawn packet to player for dim " + dimID);
}
player.playerNetServerHandler.sendPacket(new S07PacketRespawn(dimID, player.worldObj.difficultySetting, player.worldObj.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType()));
if (worldNew.provider instanceof WorldProviderOrbit)
{
if (WorldUtil.registeredSpaceStations.contains(dimID))
//TODO This has never been effective before due to the earlier bug - what does it actually do?
{
NBTTagCompound var2 = new NBTTagCompound();
SpaceStationWorldData.getStationData(worldNew, dimID, player).writeToNBT(var2);
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SPACESTATION_DATA, new Object[] { dimID, var2 }), player);
}
}
worldOld.playerEntities.remove(player);
worldOld.updateAllPlayersSleepingFlag();
if (player.addedToChunk && worldOld.getChunkProvider().chunkExists(player.chunkCoordX, player.chunkCoordZ))
{
Chunk chunkOld = worldOld.getChunkFromChunkCoords(player.chunkCoordX, player.chunkCoordZ);
chunkOld.removeEntity(player);
chunkOld.isModified = true;
}
worldOld.loadedEntityList.remove(player);
worldOld.onEntityRemoved(player);
worldNew.spawnEntityInWorld(entity);
entity.setWorld(worldNew);
spawnPos = type.getPlayerSpawnLocation((WorldServer) entity.worldObj, player);
ChunkCoordIntPair pair = worldNew.getChunkFromChunkCoords(spawnPos.intX(), spawnPos.intZ()).getChunkCoordIntPair();
if (ConfigManagerCore.enableDebug)
{
GCLog.info("DEBUG: Loading first chunk in new dimension.");
}
((WorldServer) worldNew).theChunkProviderServer.loadChunk(pair.chunkXPos, pair.chunkZPos);
//entity.setLocationAndAngles(spawnPos.x, spawnPos.y, spawnPos.z, entity.rotationYaw, entity.rotationPitch);
worldNew.updateEntityWithOptionalForce(entity, false);
entity.setLocationAndAngles(spawnPos.x, spawnPos.y, spawnPos.z, entity.rotationYaw, entity.rotationPitch);
player.mcServer.getConfigurationManager().func_72375_a(player, (WorldServer) worldNew);
player.playerNetServerHandler.setPlayerLocation(spawnPos.x, spawnPos.y, spawnPos.z, entity.rotationYaw, entity.rotationPitch);
//worldNew.updateEntityWithOptionalForce(entity, false);
GCLog.info("Server attempting to transfer player " + player.getGameProfile().getName() + " to dimension " + worldNew.provider.dimensionId);
player.theItemInWorldManager.setWorld((WorldServer) worldNew);
player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, (WorldServer) worldNew);
player.mcServer.getConfigurationManager().syncPlayerInventory(player);
for (Object o : player.getActivePotionEffects())
{
PotionEffect var10 = (PotionEffect) o;
player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), var10));
}
// player.playerNetServerHandler.sendPacketToPlayer(new Packet43Experience(player.experience, player.experienceTotal, player.experienceLevel));
}
else
//Non-player entity transfer i.e. it's an EntityCargoRocket
{
ArrayList<TileEntityTelemetry> tList = null;
if (entity instanceof EntitySpaceshipBase)
{
tList = ((EntitySpaceshipBase)entity).getTelemetry();
}
WorldUtil.removeEntityFromWorld(entity.worldObj, entity, true);
NBTTagCompound nbt = new NBTTagCompound();
entity.isDead = false;
entity.writeToNBTOptional(nbt);
entity.isDead = true;
entity = EntityList.createEntityFromNBT(nbt, worldNew);
if (entity == null)
{
return null;
}
if (entity instanceof IWorldTransferCallback)
{
((IWorldTransferCallback) entity).onWorldTransferred(worldNew);
}
worldNew.spawnEntityInWorld(entity);
entity.setWorld(worldNew);
worldNew.updateEntityWithOptionalForce(entity, false);
if (tList != null && tList.size() > 0)
{
for (TileEntityTelemetry t : tList)
{
t.addTrackedEntity(entity);
}
}
}
}
else
{
//Same dimension player transfer
if (entity instanceof EntityPlayerMP)
{
player = (EntityPlayerMP) entity;
player.closeScreen();
GCPlayerStats stats = GCPlayerStats.get(player);
stats.usingPlanetSelectionGui = false;
worldNew.updateEntityWithOptionalForce(entity, false);
spawnPos = type.getPlayerSpawnLocation((WorldServer) entity.worldObj, (EntityPlayerMP) entity);
player.playerNetServerHandler.setPlayerLocation(spawnPos.x, spawnPos.y, spawnPos.z, entity.rotationYaw, entity.rotationPitch);
entity.setLocationAndAngles(spawnPos.x, spawnPos.y, spawnPos.z, entity.rotationYaw, entity.rotationPitch);
worldNew.updateEntityWithOptionalForce(entity, false);
GCLog.info("Server attempting to transfer player " + player.getGameProfile().getName() + " within same dimension " + worldNew.provider.dimensionId);
}
//Cargo rocket does not needs its location setting here, it will do that itself
}
//Update PlayerStatsGC
if (player != null)
{
GCPlayerStats playerStats = GCPlayerStats.get(player);
if (ridingRocket == null && type.useParachute() && playerStats.extendedInventory.getStackInSlot(4) != null && playerStats.extendedInventory.getStackInSlot(4).getItem() instanceof ItemParaChute)
{
GCPlayerHandler.setUsingParachute(player, playerStats, true);
}
else