Search in sources :

Example 11 with SpaceStationWorldData

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;
}
Also used : SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) IOrbitDimension(micdoodle8.mods.galacticraft.api.world.IOrbitDimension)

Aggregations

SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)9 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)5 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)5 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 GameProfile (com.mojang.authlib.GameProfile)2 Property (com.mojang.authlib.properties.Property)2 IOException (java.io.IOException)2 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)2 Satellite (micdoodle8.mods.galacticraft.api.galaxies.Satellite)2 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 SpaceRace (micdoodle8.mods.galacticraft.core.dimension.SpaceRace)2 EntityBuggy (micdoodle8.mods.galacticraft.core.entities.EntityBuggy)2 IControllableEntity (micdoodle8.mods.galacticraft.core.entities.IControllableEntity)2 FlagData (micdoodle8.mods.galacticraft.core.wrappers.FlagData)2 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)2 CommandException (net.minecraft.command.CommandException)2