use of micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData in project Galacticraft by micdoodle8.
the class WorldUtil method getArrayOfPossibleDimensions.
/**
* This will *load* all the GC dimensions which the player has access to (taking account of space station permissions).
* Loading the dimensions through Forge activates any chunk loaders or forced chunks in that dimension,
* if the dimension was not previously loaded. This may place load on the server.
*
* @param tier - the rocket tier to test
* @param playerBase - the player who will be riding the rocket (needed for checking space station permissions)
* @return a Map of the names of the dimension vs. the dimension IDs
*/
public static HashMap<String, Integer> getArrayOfPossibleDimensions(int tier, EntityPlayerMP playerBase) {
List<Integer> ids = WorldUtil.getPossibleDimensionsForSpaceshipTier(tier, playerBase);
final HashMap<String, Integer> map = new HashMap<String, Integer>(ids.size(), 1F);
for (Integer id : ids) {
CelestialBody celestialBody = getReachableCelestialBodiesForDimensionID(id);
// It's a space station
if (id > 0 && celestialBody == null) {
celestialBody = GalacticraftCore.satelliteSpaceStation;
// This no longer checks whether a WorldProvider can be created, for performance reasons (that causes the dimension to load unnecessarily at map building stage)
if (playerBase != null) {
final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.worldObj, id, null);
map.put(celestialBody.getName() + "$" + data.getOwner() + "$" + data.getSpaceStationName() + "$" + id + "$" + data.getHomePlanet(), id);
}
} else // It's a planet or moon
{
if (celestialBody == GalacticraftCore.planetOverworld) {
map.put(celestialBody.getName(), id);
} else {
WorldProvider provider = WorldUtil.getProviderForDimensionServer(id);
if (celestialBody != null && provider != null) {
if (provider instanceof IGalacticraftWorldProvider && !(provider instanceof IOrbitDimension) || GCCoreUtil.getDimensionID(provider) == 0) {
map.put(celestialBody.getName(), GCCoreUtil.getDimensionID(provider));
}
}
}
}
}
ArrayList<CelestialBody> cBodyList = new ArrayList<CelestialBody>();
cBodyList.addAll(GalaxyRegistry.getRegisteredPlanets().values());
cBodyList.addAll(GalaxyRegistry.getRegisteredMoons().values());
for (CelestialBody body : cBodyList) {
if (!body.getReachable()) {
map.put(body.getLocalizedName() + "*", body.getDimensionID());
}
}
WorldUtil.celestialMapCache.put(playerBase, map);
return map;
}
Aggregations