}
boolean dimChange = entity.worldObj != worldNew;
entity.worldObj.updateEntityWithOptionalForce(entity, false);
EntityPlayerMP player = null;
Vector3 spawnPos = null;
int oldDimID = entity.worldObj.provider.dimensionId;
if (ridingRocket != null)
{
ArrayList<TileEntityTelemetry> tList = ridingRocket.getTelemetry();
NBTTagCompound nbt = new NBTTagCompound();
ridingRocket.isDead = false;
ridingRocket.riddenByEntity = null;
ridingRocket.writeToNBTOptional(nbt);
((WorldServer) ridingRocket.worldObj).getEntityTracker().removeEntityFromAllTrackingPlayers(ridingRocket);
ridingRocket.worldObj.loadedEntityList.remove(ridingRocket);
ridingRocket.worldObj.onEntityRemoved(ridingRocket);
ridingRocket = (EntityAutoRocket) EntityList.createEntityFromNBT(nbt, worldNew);
if (ridingRocket != null)
{
ridingRocket.setWaitForPlayer(true);
if (ridingRocket instanceof IWorldTransferCallback)
{
((IWorldTransferCallback) ridingRocket).onWorldTransferred(worldNew);
}
}
}
if (dimChange)
{
if (entity instanceof EntityPlayerMP)
{
player = (EntityPlayerMP) entity;
World worldOld = player.worldObj;
if (ConfigManagerCore.enableDebug)
{
try {
GCLog.info("DEBUG: Attempting to remove player from old dimension " + oldDimID);
((WorldServer) worldOld).getPlayerManager().removePlayer(player);
GCLog.info("DEBUG: Successfully removed player from old dimension " + oldDimID);
} catch (Exception e) { e.printStackTrace(); }
}
else
{
try {
((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);