Search in sources :

Example 6 with Satellite

use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.

the class GuiCelestialSelection method teleportToSelectedBody.

protected void teleportToSelectedBody() {
    if (this.selectedBody != null) {
        if (this.selectedBody.getReachable() && this.possibleBodies != null && this.possibleBodies.contains(this.selectedBody)) {
            try {
                String dimension;
                int dimensionID;
                if (this.selectedBody instanceof Satellite) {
                    if (this.spaceStationMap == null) {
                        GCLog.severe("Please report as a BUG: spaceStationIDs was null.");
                        return;
                    }
                    Satellite selectedSatellite = (Satellite) this.selectedBody;
                    Integer mapping = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(this.selectedStationOwner).getStationDimensionID();
                    // No need to check lowercase as selectedStationOwner is taken from keys.
                    if (mapping == null) {
                        GCLog.severe("Problem matching player name in space station check: " + this.selectedStationOwner);
                        return;
                    }
                    dimensionID = mapping;
                    WorldProvider spacestation = WorldUtil.getProviderForDimensionClient(dimensionID);
                    if (spacestation != null) {
                        dimension = WorldUtil.getDimensionName(spacestation);
                    } else {
                        GCLog.severe("Failed to find a spacestation with dimension " + dimensionID);
                        return;
                    }
                } else {
                    dimensionID = this.selectedBody.getDimensionID();
                    dimension = WorldUtil.getDimensionName(WorldUtil.getProviderForDimensionClient(dimensionID));
                }
                if (dimension.contains("$")) {
                    this.mc.gameSettings.thirdPersonView = 0;
                }
                GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(PacketSimple.EnumSimplePacket.S_TELEPORT_ENTITY, GCCoreUtil.getDimensionID(mc.theWorld), new Object[] { dimension }));
                mc.displayGuiScreen(new GuiTeleporting(dimensionID));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : WorldProvider(net.minecraft.world.WorldProvider) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) ArabicShapingException(com.ibm.icu.text.ArabicShapingException) IOException(java.io.IOException)

Example 7 with Satellite

use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.

the class GuiCelestialSelection method canCreateSpaceStation.

protected boolean canCreateSpaceStation(CelestialBody atBody) {
    if (this.mapMode || ConfigManagerCore.disableSpaceStationCreation) {
        return false;
    }
    if (!atBody.getReachable() || (this.possibleBodies != null && !this.possibleBodies.contains(atBody))) {
        // If parent body is unreachable, the satellite is also unreachable
        return false;
    }
    boolean foundRecipe = false;
    for (SpaceStationType type : GalacticraftRegistry.getSpaceStationData()) {
        if (type.getWorldToOrbitID() == atBody.getDimensionID()) {
            foundRecipe = true;
        }
    }
    if (!foundRecipe) {
        return false;
    }
    if (!ClientProxyCore.clientSpaceStationID.containsKey(atBody.getDimensionID())) {
        return true;
    }
    int resultID = ClientProxyCore.clientSpaceStationID.get(atBody.getDimensionID());
    return !(resultID != 0 && resultID != -1);
}
Also used : SpaceStationType(micdoodle8.mods.galacticraft.api.world.SpaceStationType)

Example 8 with Satellite

use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.

the class WorldUtil method bindSpaceStationToNewDimension.

public static SpaceStationWorldData bindSpaceStationToNewDimension(World world, EntityPlayerMP player, int homePlanetID) {
    int dynamicProviderID = -1;
    int staticProviderID = -1;
    for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
        if (satellite.getParentPlanet().getDimensionID() == homePlanetID) {
            dynamicProviderID = satellite.getDimensionID();
            staticProviderID = satellite.getDimensionIdStatic();
        }
    }
    if (dynamicProviderID == -1 || staticProviderID == -1) {
        throw new RuntimeException("Space station being bound on bad provider IDs!");
    }
    int newID = DimensionManager.getNextFreeDimId();
    SpaceStationWorldData data = WorldUtil.createSpaceStation(world, newID, homePlanetID, dynamicProviderID, staticProviderID, player);
    dimNames.put(newID, "Space Station " + newID);
    GCPlayerStats stats = GCPlayerStats.get(player);
    stats.getSpaceStationDimensionData().put(homePlanetID, newID);
    GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SPACESTATION_CLIENT_ID, GCCoreUtil.getDimensionID(player.worldObj), new Object[] { WorldUtil.spaceStationDataToString(stats.getSpaceStationDimensionData()) }), player);
    return data;
}
Also used : SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple)

Example 9 with Satellite

use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project MorePlanets by SteveKunG.

the class CelestialRegisterHelper method createSpaceStation.

public static Satellite createSpaceStation(String name, Planet planet, float phaseShift, float distance, float orbitTime, float size, int tier) {
    Satellite satellite = new Satellite(name).setParentBody(planet);
    satellite.setPhaseShift(phaseShift);
    satellite.setRelativeDistanceFromCenter(new ScalableDistance(distance, distance));
    satellite.setRelativeOrbitTime(orbitTime);
    satellite.setRelativeSize(size);
    satellite.setTierRequired(tier);
    satellite.setBodyIcon(new ResourceLocation("moreplanets:textures/gui/celestialbodies/" + name + ".png"));
    return satellite;
}
Also used : ScalableDistance(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 10 with Satellite

use of micdoodle8.mods.galacticraft.api.galaxies.Satellite in project Galacticraft by micdoodle8.

the class SpaceStationWorldData method getStationData.

/**
 * Retrieve a space station data entry, creating if necessary (with provided data)
 */
public static SpaceStationWorldData getStationData(World world, int stationID, int homeID, int providerIdDynamic, int providerIdStatic, EntityPlayer owner) {
    int providerType = DimensionManager.getProviderType(stationID);
    boolean foundMatch = false;
    // being called on an incorrect
    for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
        if (satellite.getDimensionIdStatic() == providerType || satellite.getDimensionID() == providerType) {
            foundMatch = true;
            break;
        }
    }
    if (!foundMatch) {
        return null;
    } else {
        final String stationIdentifier = SpaceStationWorldData.getSpaceStationID(stationID);
        SpaceStationWorldData stationData = (SpaceStationWorldData) world.loadItemData(SpaceStationWorldData.class, Constants.GCDATAFOLDER + stationIdentifier);
        if (stationData == null) {
            stationData = new SpaceStationWorldData(stationIdentifier);
            world.setItemData(Constants.GCDATAFOLDER + stationIdentifier, stationData);
            stationData.dataCompound = new NBTTagCompound();
            if (owner != null) {
                stationData.owner = PlayerUtil.getName(owner).replace(".", "");
            }
            stationData.spaceStationName = "Station: " + stationData.owner;
            if (owner != null) {
                stationData.allowedPlayers.add(PlayerUtil.getName(owner));
            }
            if (homeID == -1) {
                throw new RuntimeException("Space station being created on bad home planet ID!");
            } else {
                stationData.homePlanet = homeID;
            }
            if (providerIdDynamic == -1 || providerIdStatic == -1) {
                throw new RuntimeException("Space station being created on bad provider IDs!");
            } else {
                stationData.dimensionIdDynamic = providerIdDynamic;
                stationData.dimensionIdStatic = providerIdStatic;
            }
            stationData.markDirty();
        }
        if (stationData.getSpaceStationName().replace(" ", "").isEmpty()) {
            stationData.setSpaceStationName("Station: " + stationData.owner);
            stationData.markDirty();
        }
        return stationData;
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Satellite(micdoodle8.mods.galacticraft.api.galaxies.Satellite)

Aggregations

Vector3f (org.lwjgl.util.vector.Vector3f)5 CelestialBodyRenderEvent (micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent)3 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)3 IOException (java.io.IOException)2 Satellite (micdoodle8.mods.galacticraft.api.galaxies.Satellite)2 SpaceStationRecipe (micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)2 WorldProvider (net.minecraft.world.WorldProvider)2 ArabicShapingException (com.ibm.icu.text.ArabicShapingException)1 GameProfile (com.mojang.authlib.GameProfile)1 Property (com.mojang.authlib.properties.Property)1 FloatBuffer (java.nio.FloatBuffer)1 IGameScreen (micdoodle8.mods.galacticraft.api.client.IGameScreen)1 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)1 ScalableDistance (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance)1 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)1 EnumExtendedInventorySlot (micdoodle8.mods.galacticraft.api.item.EnumExtendedInventorySlot)1 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)1 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)1