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();
}
}
}
}
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);
}
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;
}
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;
}
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;
}
}
Aggregations