Search in sources :

Example 16 with Planet

use of micdoodle8.mods.galacticraft.api.galaxies.Planet 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)

Example 17 with Planet

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

the class GuiCelestialSelection method drawCelestialBodies.

public HashMap<CelestialBody, Matrix4f> drawCelestialBodies(Matrix4f worldMatrix) {
    GL11.glColor3f(1, 1, 1);
    FloatBuffer fb = BufferUtils.createFloatBuffer(16 * Float.SIZE);
    HashMap<CelestialBody, Matrix4f> matrixMap = Maps.newHashMap();
    for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
        Star star = solarSystem.getMainStar();
        if (star != null && star.getBodyIcon() != null) {
            GL11.glPushMatrix();
            Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
            Matrix4f.translate(this.getCelestialBodyPosition(star), worldMatrix0, worldMatrix0);
            Matrix4f worldMatrix1 = new Matrix4f();
            Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix1, worldMatrix1);
            Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix1, worldMatrix1);
            worldMatrix1 = Matrix4f.mul(worldMatrix0, worldMatrix1, worldMatrix1);
            fb.rewind();
            worldMatrix1.store(fb);
            fb.flip();
            GL11.glMultMatrix(fb);
            float alpha = 1.0F;
            if (this.selectedBody != null && this.selectedBody != star && this.isZoomed()) {
                alpha = 1.0F - Math.min(this.ticksSinceSelection / 25.0F, 1.0F);
            }
            if (this.selectedBody != null && this.isZoomed()) {
                if (star != this.selectedBody) {
                    alpha = 1.0F - Math.min(this.ticksSinceSelection / 25.0F, 1.0F);
                    if (!(this.lastSelectedBody instanceof Star) && this.lastSelectedBody != null) {
                        alpha = 0.0F;
                    }
                }
            }
            if (alpha != 0) {
                CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(star, star.getBodyIcon(), 8);
                MinecraftForge.EVENT_BUS.post(preEvent);
                GL11.glColor4f(1, 1, 1, alpha);
                if (preEvent.celestialBodyTexture != null) {
                    this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
                }
                if (!preEvent.isCanceled()) {
                    int size = getWidthForCelestialBodyStatic(star);
                    if (star == this.selectedBody && this.selectionState == EnumSelection.SELECTED) {
                        size /= 2;
                        size *= 3;
                    }
                    this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, preEvent.textureSize, preEvent.textureSize);
                    matrixMap.put(star, worldMatrix1);
                }
                CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(star);
                MinecraftForge.EVENT_BUS.post(postEvent);
            }
            fb.clear();
            GL11.glPopMatrix();
        }
    }
    for (Planet planet : GalaxyRegistry.getRegisteredPlanets().values()) {
        if (planet.getBodyIcon() != null) {
            GL11.glPushMatrix();
            Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
            Matrix4f.translate(this.getCelestialBodyPosition(planet), worldMatrix0, worldMatrix0);
            Matrix4f worldMatrix1 = new Matrix4f();
            Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix1, worldMatrix1);
            Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix1, worldMatrix1);
            worldMatrix1 = Matrix4f.mul(worldMatrix0, worldMatrix1, worldMatrix1);
            fb.rewind();
            worldMatrix1.store(fb);
            fb.flip();
            GL11.glMultMatrix(fb);
            float alpha = 1.0F;
            if ((this.selectedBody instanceof IChildBody && ((IChildBody) this.selectedBody).getParentPlanet() != planet) || (this.selectedBody instanceof Planet && this.selectedBody != planet && this.isZoomed())) {
                if (this.lastSelectedBody == null && !(this.selectedBody instanceof IChildBody)) {
                    alpha = 1.0F - Math.min(this.ticksSinceSelection / 25.0F, 1.0F);
                } else {
                    alpha = 0.0F;
                }
            }
            if (alpha != 0) {
                CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(planet, planet.getBodyIcon(), 12);
                MinecraftForge.EVENT_BUS.post(preEvent);
                GL11.glColor4f(1, 1, 1, alpha);
                if (preEvent.celestialBodyTexture != null) {
                    this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
                }
                if (!preEvent.isCanceled()) {
                    int size = getWidthForCelestialBodyStatic(planet);
                    // Celestial body textures are 12x12 in a 16x16 .png
                    this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, 16, 16);
                    matrixMap.put(planet, worldMatrix1);
                }
                CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(planet);
                MinecraftForge.EVENT_BUS.post(postEvent);
            }
            fb.clear();
            GL11.glPopMatrix();
        }
    }
    if (this.selectedBody != null) {
        Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
        for (Moon moon : GalaxyRegistry.getRegisteredMoons().values()) {
            if ((moon == this.selectedBody || (moon.getParentPlanet() == this.selectedBody && this.selectionState != EnumSelection.SELECTED)) && (this.ticksSinceSelection > 35 || this.selectedBody == moon || (this.lastSelectedBody instanceof Moon && GalaxyRegistry.getMoonsForPlanet(((Moon) this.lastSelectedBody).getParentPlanet()).contains(moon))) || getSiblings(this.selectedBody).contains(moon)) {
                GL11.glPushMatrix();
                Matrix4f worldMatrix1 = new Matrix4f(worldMatrix0);
                Matrix4f.translate(this.getCelestialBodyPosition(moon), worldMatrix1, worldMatrix1);
                Matrix4f worldMatrix2 = new Matrix4f();
                Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix2, worldMatrix2);
                Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix2, worldMatrix2);
                Matrix4f.scale(new Vector3f(0.25F, 0.25F, 1.0F), worldMatrix2, worldMatrix2);
                worldMatrix2 = Matrix4f.mul(worldMatrix1, worldMatrix2, worldMatrix2);
                fb.rewind();
                worldMatrix2.store(fb);
                fb.flip();
                GL11.glMultMatrix(fb);
                CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(moon, moon.getBodyIcon(), 8);
                MinecraftForge.EVENT_BUS.post(preEvent);
                GL11.glColor4f(1, 1, 1, 1);
                if (preEvent.celestialBodyTexture != null) {
                    this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
                }
                if (!preEvent.isCanceled()) {
                    int size = getWidthForCelestialBodyStatic(moon);
                    this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, preEvent.textureSize, preEvent.textureSize);
                    matrixMap.put(moon, worldMatrix1);
                }
                CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(moon);
                MinecraftForge.EVENT_BUS.post(postEvent);
                fb.clear();
                GL11.glPopMatrix();
            }
        }
    }
    if (this.selectedBody != null) {
        Matrix4f worldMatrix0 = new Matrix4f(worldMatrix);
        for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
            if (this.possibleBodies != null && this.possibleBodies.contains(satellite)) {
                if ((satellite == this.selectedBody || (satellite.getParentPlanet() == this.selectedBody && this.selectionState != EnumSelection.SELECTED)) && (this.ticksSinceSelection > 35 || this.selectedBody == satellite || (this.lastSelectedBody instanceof Satellite && GalaxyRegistry.getSatellitesForCelestialBody(((Satellite) this.lastSelectedBody).getParentPlanet()).contains(satellite)))) {
                    GL11.glPushMatrix();
                    Matrix4f worldMatrix1 = new Matrix4f(worldMatrix0);
                    Matrix4f.translate(this.getCelestialBodyPosition(satellite), worldMatrix1, worldMatrix1);
                    Matrix4f worldMatrix2 = new Matrix4f();
                    Matrix4f.rotate((float) Math.toRadians(45), new Vector3f(0, 0, 1), worldMatrix2, worldMatrix2);
                    Matrix4f.rotate((float) Math.toRadians(-55), new Vector3f(1, 0, 0), worldMatrix2, worldMatrix2);
                    Matrix4f.scale(new Vector3f(0.25F, 0.25F, 1.0F), worldMatrix2, worldMatrix2);
                    worldMatrix2 = Matrix4f.mul(worldMatrix1, worldMatrix2, worldMatrix2);
                    fb.rewind();
                    worldMatrix2.store(fb);
                    fb.flip();
                    GL11.glMultMatrix(fb);
                    CelestialBodyRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.Pre(satellite, satellite.getBodyIcon(), 8);
                    MinecraftForge.EVENT_BUS.post(preEvent);
                    GL11.glColor4f(1, 1, 1, 1);
                    this.mc.renderEngine.bindTexture(preEvent.celestialBodyTexture);
                    if (!preEvent.isCanceled()) {
                        int size = getWidthForCelestialBodyStatic(satellite);
                        this.drawTexturedModalRect(-size / 2, -size / 2, size, size, 0, 0, preEvent.textureSize, preEvent.textureSize, false, false, preEvent.textureSize, preEvent.textureSize);
                        matrixMap.put(satellite, worldMatrix1);
                    }
                    CelestialBodyRenderEvent.Post postEvent = new CelestialBodyRenderEvent.Post(satellite);
                    MinecraftForge.EVENT_BUS.post(postEvent);
                    fb.clear();
                    GL11.glPopMatrix();
                }
            }
        }
    }
    return matrixMap;
}
Also used : FloatBuffer(java.nio.FloatBuffer) Matrix4f(org.lwjgl.util.vector.Matrix4f) CelestialBodyRenderEvent(micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent) Vector3f(org.lwjgl.util.vector.Vector3f)

Example 18 with Planet

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

the class GuiCelestialSelection method drawButtons.

public void drawButtons(int mousePosX, int mousePosY) {
    this.zLevel = 0.0F;
    boolean handledSliderPos = false;
    final int LHS = GuiCelestialSelection.BORDER_SIZE + GuiCelestialSelection.BORDER_EDGE_SIZE;
    final int RHS = width - LHS;
    final int TOP = LHS;
    final int BOT = height - LHS;
    if (this.viewState == EnumView.PROFILE) {
        this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
        GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
        this.drawTexturedModalRect(width / 2 - 43, TOP, 86, 15, 266, 0, 172, 29, false, false);
        String str = GCCoreUtil.translate("gui.message.catalog.name").toUpperCase();
        this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, TOP + this.fontRendererObj.FONT_HEIGHT / 2, WHITE);
        if (this.selectedBody != null) {
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            if (mousePosX > LHS && mousePosX < LHS + 88 && mousePosY > TOP && mousePosY < TOP + 13) {
                GL11.glColor3f(3.0F, 0.0F, 0.0F);
            } else {
                GL11.glColor3f(0.9F, 0.2F, 0.2F);
            }
            this.drawTexturedModalRect(LHS, TOP, 88, 13, 0, 392, 148, 22, false, false);
            str = GCCoreUtil.translate("gui.message.back.name").toUpperCase();
            this.fontRendererObj.drawString(str, LHS + 45 - this.fontRendererObj.getStringWidth(str) / 2, TOP + this.fontRendererObj.FONT_HEIGHT / 2 - 2, WHITE);
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            if (mousePosX > RHS - 88 && mousePosX < RHS && mousePosY > TOP && mousePosY < TOP + 13) {
                GL11.glColor3f(0.0F, 3.0F, 0.0F);
            } else {
                GL11.glColor3f(0.2F, 0.9F, 0.2F);
            }
            this.drawTexturedModalRect(RHS - 88, TOP, 88, 13, 0, 392, 148, 22, true, false);
            GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
            this.drawTexturedModalRect(LHS, BOT - 13, 88, 13, 0, 392, 148, 22, false, true);
            this.drawTexturedModalRect(RHS - 88, BOT - 13, 88, 13, 0, 392, 148, 22, true, true);
            int menuTopLeft = TOP - 115 + height / 2 - 4;
            int posX = LHS + Math.min(this.ticksSinceSelection * 10, 133) - 134;
            int posX2 = (int) (LHS + Math.min(this.ticksSinceSelection * 1.25F, 15) - 15);
            int fontPosY = menuTopLeft + GuiCelestialSelection.BORDER_EDGE_SIZE + this.fontRendererObj.FONT_HEIGHT / 2 - 2;
            this.drawTexturedModalRect(posX, menuTopLeft + 12, 133, 196, 0, 0, 266, 392, false, false);
            // str = this.selectedBody.getLocalizedName();
            // this.fontRendererObj.drawString(str, posX + 20, fontPosY, GCCoreUtil.to32BitColor(255, 255, 255, 255));
            str = GCCoreUtil.translate("gui.message.daynightcycle.name") + ":";
            this.fontRendererObj.drawString(str, posX + 5, fontPosY + 14, CYAN);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".daynightcycle.0.name");
            this.fontRendererObj.drawString(str, posX + 10, fontPosY + 25, WHITE);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".daynightcycle.1.name");
            if (!str.isEmpty()) {
                this.fontRendererObj.drawString(str, posX + 10, fontPosY + 36, WHITE);
            }
            str = GCCoreUtil.translate("gui.message.surfacegravity.name") + ":";
            this.fontRendererObj.drawString(str, posX + 5, fontPosY + 50, CYAN);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacegravity.0.name");
            this.fontRendererObj.drawString(str, posX + 10, fontPosY + 61, WHITE);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacegravity.1.name");
            if (!str.isEmpty()) {
                this.fontRendererObj.drawString(str, posX + 10, fontPosY + 72, WHITE);
            }
            str = GCCoreUtil.translate("gui.message.surfacecomposition.name") + ":";
            this.fontRendererObj.drawString(str, posX + 5, fontPosY + 88, CYAN);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacecomposition.0.name");
            this.fontRendererObj.drawString(str, posX + 10, fontPosY + 99, WHITE);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".surfacecomposition.1.name");
            if (!str.isEmpty()) {
                this.fontRendererObj.drawString(str, posX + 10, fontPosY + 110, WHITE);
            }
            str = GCCoreUtil.translate("gui.message.atmosphere.name") + ":";
            this.fontRendererObj.drawString(str, posX + 5, fontPosY + 126, CYAN);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".atmosphere.0.name");
            this.fontRendererObj.drawString(str, posX + 10, fontPosY + 137, WHITE);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".atmosphere.1.name");
            if (!str.isEmpty()) {
                this.fontRendererObj.drawString(str, posX + 10, fontPosY + 148, WHITE);
            }
            str = GCCoreUtil.translate("gui.message.meansurfacetemp.name") + ":";
            this.fontRendererObj.drawString(str, posX + 5, fontPosY + 165, CYAN);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".meansurfacetemp.0.name");
            this.fontRendererObj.drawString(str, posX + 10, fontPosY + 176, WHITE);
            str = GCCoreUtil.translate("gui.message." + this.selectedBody.getName() + ".meansurfacetemp.1.name");
            if (!str.isEmpty()) {
                this.fontRendererObj.drawString(str, posX + 10, fontPosY + 187, WHITE);
            }
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
            this.drawTexturedModalRect(posX2, menuTopLeft + 12, 17, 199, 439, 0, 32, 399, false, false);
        // this.drawRectD(posX2 + 16.5, menuTopLeft + 13, posX + 131, menuTopLeft + 14, GCCoreUtil.to32BitColor(120, 0, (int) (0.6F * 255), 255));
        }
    } else {
        String str;
        // Catalog:
        this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
        GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
        this.drawTexturedModalRect(LHS, TOP, 74, 11, 0, 392, 148, 22, false, false);
        str = GCCoreUtil.translate("gui.message.catalog.name").toUpperCase();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.fontRendererObj.drawString(str, LHS + 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 1, WHITE);
        int scale = (int) Math.min(95, this.ticksSinceMenuOpen * 12.0F);
        boolean planetZoomedNotMoon = this.isZoomed() && !(this.selectedParent instanceof Planet);
        // Parent frame:
        GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
        this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
        this.drawTexturedModalRect(LHS - 95 + scale, TOP + 12, 95, 41, 0, 436, 95, 41, false, false);
        str = planetZoomedNotMoon ? this.selectedBody.getLocalizedName() : this.getParentName();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.fontRendererObj.drawString(str, LHS + 9 - 95 + scale, TOP + 34, WHITE);
        GL11.glColor4f(1, 1, 0, 1);
        this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
        // Grandparent frame:
        this.drawTexturedModalRect(LHS + 2 - 95 + scale, TOP + 14, 93, 17, 95, 436, 93, 17, false, false);
        str = planetZoomedNotMoon ? this.getParentName() : this.getGrandparentName();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.fontRendererObj.drawString(str, LHS + 7 - 95 + scale, TOP + 16, GREY3);
        GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
        List<CelestialBody> children = this.getChildren(planetZoomedNotMoon ? this.selectedBody : this.selectedParent);
        drawChildren(children, 0, 0, true);
        if (this.mapMode) {
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            this.drawTexturedModalRect(RHS - 74, TOP, 74, 11, 0, 392, 148, 22, true, false);
            str = GCCoreUtil.translate("gui.message.exit.name").toUpperCase();
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            this.fontRendererObj.drawString(str, RHS - 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 1, WHITE);
        }
        if (this.selectedBody != null) {
            // Right-hand bar (basic selectionState info)
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
            GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
            if (this.selectedBody instanceof Satellite) {
                Satellite selectedSatellite = (Satellite) this.selectedBody;
                int stationListSize = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).size();
                this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
                int max = Math.min((this.height / 2) / 14, stationListSize);
                this.drawTexturedModalRect(RHS - 95, TOP, 95, 53, this.selectedStationOwner.length() == 0 ? 95 : 0, 186, 95, 53, false, false);
                if (this.spaceStationListOffset <= 0) {
                    GL11.glColor4f(0.65F, 0.65F, 0.65F, 1);
                } else {
                    GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
                }
                this.drawTexturedModalRect(RHS - 85, TOP + 45, 61, 4, 0, 239, 61, 4, false, false);
                if (max + spaceStationListOffset >= stationListSize) {
                    GL11.glColor4f(0.65F, 0.65F, 0.65F, 1);
                } else {
                    GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
                }
                this.drawTexturedModalRect(RHS - 85, TOP + 49 + max * 14, 61, 4, 0, 239, 61, 4, false, true);
                GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
                if (this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(this.selectedStationOwner) == null) {
                    str = GCCoreUtil.translate("gui.message.select_ss.name");
                    this.drawSplitString(str, RHS - 47, TOP + 20, 91, WHITE, false, false);
                } else {
                    str = GCCoreUtil.translate("gui.message.ss_owner.name");
                    this.fontRendererObj.drawString(str, RHS - 85, TOP + 18, WHITE);
                    str = this.selectedStationOwner;
                    this.fontRendererObj.drawString(str, RHS - 47 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 30, WHITE);
                }
                Iterator<Map.Entry<String, StationDataGUI>> it = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).entrySet().iterator();
                int i = 0;
                int j = 0;
                while (it.hasNext() && i < max) {
                    Map.Entry<String, StationDataGUI> e = it.next();
                    if (j >= this.spaceStationListOffset) {
                        this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
                        GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
                        int xOffset = 0;
                        if (e.getKey().equalsIgnoreCase(this.selectedStationOwner)) {
                            xOffset -= 5;
                        }
                        this.drawTexturedModalRect(RHS - 95 + xOffset, TOP + 50 + i * 14, 93, 12, 95, 464, 93, 12, true, false);
                        str = "";
                        String str0 = e.getValue().getStationName();
                        int point = 0;
                        while (this.fontRendererObj.getStringWidth(str) < 80 && point < str0.length()) {
                            str = str + str0.substring(point, point + 1);
                            point++;
                        }
                        if (this.fontRendererObj.getStringWidth(str) >= 80) {
                            str = str.substring(0, str.length() - 3);
                            str = str + "...";
                        }
                        this.fontRendererObj.drawString(str, RHS - 88 + xOffset, TOP + 52 + i * 14, WHITE);
                        i++;
                    }
                    j++;
                }
            } else {
                this.drawTexturedModalRect(RHS - 96, TOP, 96, 139, 63, 0, 96, 139, false, false);
            }
            if (this.canCreateSpaceStation(this.selectedBody) && (!(this.selectedBody instanceof Satellite))) {
                GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
                this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
                int canCreateLength = Math.max(0, this.drawSplitString(GCCoreUtil.translate("gui.message.can_create_space_station.name"), 0, 0, 91, 0, true, true) - 2);
                canCreateOffset = canCreateLength * this.fontRendererObj.FONT_HEIGHT;
                this.drawTexturedModalRect(RHS - 95, TOP + 134, 93, 4, 159, 102, 93, 4, false, false);
                for (int barY = 0; barY < canCreateLength; ++barY) {
                    this.drawTexturedModalRect(RHS - 95, TOP + 138 + barY * this.fontRendererObj.FONT_HEIGHT, 93, this.fontRendererObj.FONT_HEIGHT, 159, 106, 93, this.fontRendererObj.FONT_HEIGHT, false, false);
                }
                this.drawTexturedModalRect(RHS - 95, TOP + 138 + canCreateOffset, 93, 43, 159, 106, 93, 43, false, false);
                this.drawTexturedModalRect(RHS - 79, TOP + 129, 61, 4, 0, 170, 61, 4, false, false);
                SpaceStationRecipe recipe = WorldUtil.getSpaceStationRecipe(this.selectedBody.getDimensionID());
                if (recipe != null) {
                    GL11.glColor4f(0.0F, 1.0F, 0.1F, 1);
                    boolean validInputMaterials = true;
                    int i = 0;
                    for (Map.Entry<Object, Integer> e : recipe.getInput().entrySet()) {
                        Object next = e.getKey();
                        int xPos = (int) (RHS - 95 + i * 93 / (double) recipe.getInput().size() + 5);
                        int yPos = TOP + 154 + canCreateOffset;
                        if (next instanceof ItemStack) {
                            int amount = getAmountInInventory((ItemStack) next);
                            RenderHelper.enableGUIStandardItemLighting();
                            ItemStack toRender = ((ItemStack) next).copy();
                            this.itemRender.renderItemAndEffectIntoGUI(toRender, xPos, yPos);
                            this.itemRender.renderItemOverlayIntoGUI(mc.fontRendererObj, toRender, xPos, yPos, null);
                            RenderHelper.disableStandardItemLighting();
                            GL11.glEnable(GL11.GL_BLEND);
                            if (mousePosX >= xPos && mousePosX <= xPos + 16 && mousePosY >= yPos && mousePosY <= yPos + 16) {
                                GL11.glDepthMask(true);
                                GL11.glEnable(GL11.GL_DEPTH_TEST);
                                GL11.glPushMatrix();
                                GL11.glTranslatef(0, 0, 300);
                                int k = this.fontRendererObj.getStringWidth(((ItemStack) next).getDisplayName());
                                int j2 = mousePosX - k / 2;
                                int k2 = mousePosY - 12;
                                int i1 = 8;
                                if (j2 + k > this.width) {
                                    j2 -= (j2 - this.width + k);
                                }
                                if (k2 + i1 + 6 > this.height) {
                                    k2 = this.height - i1 - 6;
                                }
                                int j1 = ColorUtil.to32BitColor(190, 0, 153, 255);
                                this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);
                                this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);
                                this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);
                                this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);
                                this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);
                                int k1 = ColorUtil.to32BitColor(170, 0, 153, 255);
                                int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
                                this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);
                                this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);
                                this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);
                                this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);
                                this.fontRendererObj.drawString(((ItemStack) next).getDisplayName(), j2, k2, WHITE);
                                GL11.glPopMatrix();
                            }
                            str = "" + e.getValue();
                            boolean valid = amount >= e.getValue();
                            if (!valid && validInputMaterials) {
                                validInputMaterials = false;
                            }
                            int color = valid | this.mc.thePlayer.capabilities.isCreativeMode ? GREEN : RED;
                            this.fontRendererObj.drawString(str, xPos + 8 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 170 + canCreateOffset, color);
                        } else if (next instanceof Collection) {
                            Collection<ItemStack> items = (Collection<ItemStack>) next;
                            int amount = 0;
                            for (ItemStack stack : items) {
                                amount += getAmountInInventory(stack);
                            }
                            RenderHelper.enableGUIStandardItemLighting();
                            Iterator<ItemStack> it = items.iterator();
                            int count = 0;
                            int toRenderIndex = (this.ticksSinceMenuOpen / 20) % items.size();
                            ItemStack toRender = null;
                            while (it.hasNext()) {
                                ItemStack stack = it.next();
                                if (count == toRenderIndex) {
                                    toRender = stack;
                                    break;
                                }
                                count++;
                            }
                            if (toRender == null) {
                                continue;
                            }
                            this.itemRender.renderItemAndEffectIntoGUI(toRender, xPos, yPos);
                            this.itemRender.renderItemOverlayIntoGUI(mc.fontRendererObj, toRender, xPos, yPos, null);
                            RenderHelper.disableStandardItemLighting();
                            GL11.glEnable(GL11.GL_BLEND);
                            if (mousePosX >= xPos && mousePosX <= xPos + 16 && mousePosY >= yPos && mousePosY <= yPos + 16) {
                                GL11.glDepthMask(true);
                                GL11.glEnable(GL11.GL_DEPTH_TEST);
                                GL11.glPushMatrix();
                                GL11.glTranslatef(0, 0, 300);
                                int k = this.fontRendererObj.getStringWidth(toRender.getDisplayName());
                                int j2 = mousePosX - k / 2;
                                int k2 = mousePosY - 12;
                                int i1 = 8;
                                if (j2 + k > this.width) {
                                    j2 -= (j2 - this.width + k);
                                }
                                if (k2 + i1 + 6 > this.height) {
                                    k2 = this.height - i1 - 6;
                                }
                                int j1 = ColorUtil.to32BitColor(190, 0, 153, 255);
                                this.drawGradientRect(j2 - 3, k2 - 4, j2 + k + 3, k2 - 3, j1, j1);
                                this.drawGradientRect(j2 - 3, k2 + i1 + 3, j2 + k + 3, k2 + i1 + 4, j1, j1);
                                this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 + i1 + 3, j1, j1);
                                this.drawGradientRect(j2 - 4, k2 - 3, j2 - 3, k2 + i1 + 3, j1, j1);
                                this.drawGradientRect(j2 + k + 3, k2 - 3, j2 + k + 4, k2 + i1 + 3, j1, j1);
                                int k1 = ColorUtil.to32BitColor(170, 0, 153, 255);
                                int l1 = (k1 & 16711422) >> 1 | k1 & -16777216;
                                this.drawGradientRect(j2 - 3, k2 - 3 + 1, j2 - 3 + 1, k2 + i1 + 3 - 1, k1, l1);
                                this.drawGradientRect(j2 + k + 2, k2 - 3 + 1, j2 + k + 3, k2 + i1 + 3 - 1, k1, l1);
                                this.drawGradientRect(j2 - 3, k2 - 3, j2 + k + 3, k2 - 3 + 1, k1, k1);
                                this.drawGradientRect(j2 - 3, k2 + i1 + 2, j2 + k + 3, k2 + i1 + 3, l1, l1);
                                this.fontRendererObj.drawString(toRender.getDisplayName(), j2, k2, WHITE);
                                GL11.glPopMatrix();
                            }
                            str = "" + e.getValue();
                            boolean valid = amount >= e.getValue();
                            if (!valid && validInputMaterials) {
                                validInputMaterials = false;
                            }
                            int color = valid | this.mc.thePlayer.capabilities.isCreativeMode ? GREEN : RED;
                            this.fontRendererObj.drawString(str, xPos + 8 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 170 + canCreateOffset, color);
                        }
                        i++;
                    }
                    if (validInputMaterials || this.mc.thePlayer.capabilities.isCreativeMode) {
                        GL11.glColor4f(0.0F, 1.0F, 0.1F, 1);
                    } else {
                        GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
                    }
                    this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
                    if (!this.mapMode) {
                        if (mousePosX >= RHS - 95 && mousePosX <= RHS && mousePosY >= TOP + 182 + canCreateOffset && mousePosY <= TOP + 182 + 12 + canCreateOffset) {
                            this.drawTexturedModalRect(RHS - 95, TOP + 182 + canCreateOffset, 93, 12, 0, 174, 93, 12, false, false);
                        }
                    }
                    this.drawTexturedModalRect(RHS - 95, TOP + 182 + canCreateOffset, 93, 12, 0, 174, 93, 12, false, false);
                    int color = (int) ((Math.sin(this.ticksSinceMenuOpen / 5.0) * 0.5 + 0.5) * 255);
                    this.drawSplitString(GCCoreUtil.translate("gui.message.can_create_space_station.name"), RHS - 48, TOP + 137, 91, ColorUtil.to32BitColor(255, color, 255, color), true, false);
                    if (!mapMode) {
                        this.drawSplitString(GCCoreUtil.translate("gui.message.create_ss.name").toUpperCase(), RHS - 48, TOP + 185 + canCreateOffset, 91, WHITE, false, false);
                    }
                } else {
                    this.drawSplitString(GCCoreUtil.translate("gui.message.cannot_create_space_station.name"), RHS - 48, TOP + 138, 91, WHITE, true, false);
                }
            }
            // Catalog overlay
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.3F - Math.min(0.3F, this.ticksSinceSelection / 50.0F));
            this.drawTexturedModalRect(LHS, TOP, 74, 11, 0, 392, 148, 22, false, false);
            str = GCCoreUtil.translate("gui.message.catalog.name").toUpperCase();
            this.fontRendererObj.drawString(str, LHS + 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 1, WHITE);
            // Top bar title:
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
            if (this.selectedBody instanceof Satellite) {
                if (this.selectedStationOwner.length() == 0 || !this.selectedStationOwner.equalsIgnoreCase(PlayerUtil.getName(this.mc.thePlayer))) {
                    GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
                } else {
                    GL11.glColor4f(0.0F, 1.0F, 0.0F, 1);
                }
                this.drawTexturedModalRect(width / 2 - 47, TOP, 94, 11, 0, 414, 188, 22, false, false);
            } else {
                this.drawTexturedModalRect(width / 2 - 47, TOP, 94, 11, 0, 414, 188, 22, false, false);
            }
            if (this.selectedBody.getTierRequirement() >= 0 && (!(this.selectedBody instanceof Satellite))) {
                boolean canReach;
                if (!this.selectedBody.getReachable() || (this.possibleBodies != null && !this.possibleBodies.contains(this.selectedBody))) {
                    canReach = false;
                    GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
                } else {
                    canReach = true;
                    GL11.glColor4f(0.0F, 1.0F, 0.0F, 1);
                }
                this.drawTexturedModalRect(width / 2 - 30, TOP + 11, 30, 11, 0, 414, 60, 22, false, false);
                this.drawTexturedModalRect(width / 2, TOP + 11, 30, 11, 128, 414, 60, 22, false, false);
                str = GCCoreUtil.translateWithFormat("gui.message.tier.name", this.selectedBody.getTierRequirement() == 0 ? "?" : this.selectedBody.getTierRequirement());
                this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 13, canReach ? GREY4 : RED3);
            }
            str = this.selectedBody.getLocalizedName();
            if (this.selectedBody instanceof Satellite) {
                str = GCCoreUtil.translate("gui.message.rename.name").toUpperCase();
            }
            this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, TOP + 2, WHITE);
            // Catalog wedge:
            this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
            GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
            this.drawTexturedModalRect(LHS + 4, TOP, 83, 12, 0, 477, 83, 12, false, false);
            if (!this.mapMode) {
                if (!this.selectedBody.getReachable() || (this.possibleBodies != null && !this.possibleBodies.contains(this.selectedBody)) || (this.selectedBody instanceof Satellite && this.selectedStationOwner.equals(""))) {
                    GL11.glColor4f(1.0F, 0.0F, 0.0F, 1);
                } else {
                    GL11.glColor4f(0.0F, 1.0F, 0.0F, 1);
                }
                this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
                this.drawTexturedModalRect(RHS - 74, TOP, 74, 11, 0, 392, 148, 22, true, false);
                str = GCCoreUtil.translate("gui.message.launch.name").toUpperCase();
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                this.fontRendererObj.drawString(str, RHS - 40 - fontRendererObj.getStringWidth(str) / 2, TOP + 2, WHITE);
            }
            if (this.selectionState == EnumSelection.SELECTED && !(this.selectedBody instanceof Satellite)) {
                handledSliderPos = true;
                int sliderPos = this.zoomTooltipPos;
                if (zoomTooltipPos != 38) {
                    sliderPos = Math.min(this.ticksSinceSelection * 2, 38);
                    this.zoomTooltipPos = sliderPos;
                }
                GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
                this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
                this.drawTexturedModalRect(RHS - 182, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE - sliderPos, 83, 38, 512 - 166, 512 - 76, 166, 76, true, false);
                boolean flag0 = GalaxyRegistry.getSatellitesForCelestialBody(this.selectedBody).size() > 0;
                boolean flag1 = this.selectedBody instanceof Planet && GalaxyRegistry.getMoonsForPlanet((Planet) this.selectedBody).size() > 0;
                if (flag0 && flag1) {
                    this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.0.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 2 - sliderPos, 79, GREY5, false, false);
                } else if (!flag0 && flag1) {
                    this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.1.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 6 - sliderPos, 79, GREY5, false, false);
                } else if (flag0) {
                    this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.2.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 6 - sliderPos, 79, GREY5, false, false);
                } else {
                    this.drawSplitString(GCCoreUtil.translate("gui.message.click_again.3.name"), RHS - 182 + 41, height - GuiCelestialSelection.BORDER_SIZE - GuiCelestialSelection.BORDER_EDGE_SIZE + 11 - sliderPos, 79, GREY5, false, false);
                }
            }
            if (this.selectedBody instanceof Satellite && renamingSpaceStation) {
                this.drawDefaultBackground();
                GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
                this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain1);
                this.drawTexturedModalRect(width / 2 - 90, this.height / 2 - 38, 179, 67, 159, 0, 179, 67, false, false);
                this.drawTexturedModalRect(width / 2 - 90 + 4, this.height / 2 - 38 + 2, 171, 10, 159, 92, 171, 10, false, false);
                this.drawTexturedModalRect(width / 2 - 90 + 8, this.height / 2 - 38 + 18, 161, 13, 159, 67, 161, 13, false, false);
                this.drawTexturedModalRect(width / 2 - 90 + 17, this.height / 2 - 38 + 59, 72, 12, 159, 80, 72, 12, true, false);
                this.drawTexturedModalRect(width / 2, this.height / 2 - 38 + 59, 72, 12, 159, 80, 72, 12, false, false);
                str = GCCoreUtil.translate("gui.message.assign_name.name");
                this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, this.height / 2 - 35, WHITE);
                str = GCCoreUtil.translate("gui.message.apply.name");
                this.fontRendererObj.drawString(str, width / 2 - this.fontRendererObj.getStringWidth(str) / 2 - 36, this.height / 2 + 23, WHITE);
                str = GCCoreUtil.translate("gui.message.cancel.name");
                this.fontRendererObj.drawString(str, width / 2 + 36 - this.fontRendererObj.getStringWidth(str) / 2, this.height / 2 + 23, WHITE);
                if (this.renamingString == null) {
                    Satellite selectedSatellite = (Satellite) this.selectedBody;
                    String playerName = PlayerUtil.getName(this.mc.thePlayer);
                    this.renamingString = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(playerName).getStationName();
                    if (this.renamingString == null) {
                        this.renamingString = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(playerName.toLowerCase()).getStationName();
                    }
                    if (this.renamingString == null) {
                        this.renamingString = "";
                    }
                }
                str = this.renamingString;
                String str0 = this.renamingString;
                if ((this.ticksSinceMenuOpen / 10) % 2 == 0) {
                    str0 += "_";
                }
                this.fontRendererObj.drawString(str0, width / 2 - this.fontRendererObj.getStringWidth(str) / 2, this.height / 2 - 17, WHITE);
            }
        // this.mc.renderEngine.bindTexture(GuiCelestialSelection.guiMain0);
        // GL11.glColor4f(0.0F, 0.6F, 1.0F, 1);
        }
    }
    if (!handledSliderPos) {
        this.zoomTooltipPos = 0;
    }
}
Also used : SpaceStationRecipe(micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 19 with Planet

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

the class WorldUtil method decodePlanetsListClient.

/**
 * What's important here is that Galacticraft and the server both register
 * the same reachable Galacticraft planets (and their provider types) in the same order.
 * See WorldUtil.registerPlanet().
 *
 * Even if there are dimension conflicts or other problems, the planets must be
 * registered in the same order on both client and server.  This should happen
 * automatically if Galacticraft versions match, and if planets modules
 * match  (including Galacticraft-Planets and any other sub-mods).
 *
 * It is NOT a good idea for sub-mods to make the registration order of planets variable
 * or dependent on configs.
 */
public static void decodePlanetsListClient(List<Object> data) {
    try {
        if (ConfigManagerCore.enableDebug) {
            GCLog.info("GC connecting to server: received planets dimension ID list.");
        }
        if (WorldUtil.registeredPlanets != null) {
            for (Integer registeredID : WorldUtil.registeredPlanets) {
                DimensionManager.unregisterDimension(registeredID);
            }
        }
        WorldUtil.registeredPlanets = new ArrayList<Integer>();
        String ids = "";
        if (data.size() > 0) {
            // Start the provider index at offset 2 to skip the two Overworld Orbit dimensions
            // (this will be iterating through GalacticraftRegistry.worldProviderIDs)
            int providerIndex = GalaxyRegistry.getRegisteredSatellites().size() * 2;
            if (data.get(0) instanceof Integer) {
                for (Object o : data) {
                    WorldUtil.registerPlanetClient((Integer) o, providerIndex);
                    providerIndex++;
                    ids += ((Integer) o).toString() + " ";
                }
            } else if (data.get(0) instanceof Integer[]) {
                for (Object o : (Integer[]) data.get(0)) {
                    WorldUtil.registerPlanetClient((Integer) o, providerIndex);
                    providerIndex++;
                    ids += ((Integer) o).toString() + " ";
                }
            }
        }
        if (ConfigManagerCore.enableDebug) {
            GCLog.debug("GC clientside planet dimensions registered: " + ids);
            WorldProvider dimMoon = WorldUtil.getProviderForNameClient("moon.moon");
            if (dimMoon != null) {
                GCLog.debug("Crosscheck: Moon is " + GCCoreUtil.getDimensionID(dimMoon));
            }
            WorldProvider dimMars = WorldUtil.getProviderForNameClient("planet.mars");
            if (dimMars != null) {
                GCLog.debug("Crosscheck: Mars is " + GCCoreUtil.getDimensionID(dimMars));
            }
            WorldProvider dimAst = WorldUtil.getProviderForNameClient("planet.asteroids");
            if (dimAst != null) {
                GCLog.debug("Crosscheck: Asteroids is " + GCCoreUtil.getDimensionID(dimAst));
            }
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)

Example 20 with Planet

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

the class EntityCargoRocket method onReachAtmosphere.

@Override
public void onReachAtmosphere() {
    if (this.worldObj.isRemote) {
        // stop the sounds on the client - but do not reset, the rocket may start again
        this.stopRocketSound();
        return;
    }
    GCLog.debug("[Serverside] Cargo rocket reached space, heading to " + this.destinationFrequency);
    this.setTarget(true, this.destinationFrequency);
    if (this.targetVec != null) {
        GCLog.debug("Destination location = " + this.targetVec.toString());
        if (this.targetDimension != GCCoreUtil.getDimensionID(this.worldObj)) {
            GCLog.debug("Destination is in different dimension: " + this.targetDimension);
            WorldProvider targetDim = WorldUtil.getProviderForDimensionServer(this.targetDimension);
            if (targetDim != null && targetDim.worldObj instanceof WorldServer) {
                GCLog.debug("Loaded destination dimension " + this.targetDimension);
                this.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F);
                Entity e = WorldUtil.transferEntityToDimension(this, this.targetDimension, (WorldServer) targetDim.worldObj, false, null);
                if (e instanceof EntityCargoRocket) {
                    GCLog.debug("Cargo rocket arrived at destination dimension, going into landing mode.");
                    e.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F);
                    ((EntityCargoRocket) e).setLaunchPhase(EnumLaunchPhase.LANDING);
                // No setDead() following successful transferEntityToDimension() - see javadoc on that
                } else {
                    GCLog.info("Error: failed to recreate the cargo rocket in landing mode on target planet.");
                    e.setDead();
                    this.setDead();
                }
                return;
            }
            GCLog.info("Error: the server failed to load the dimension the cargo rocket is supposed to land in. Destroying rocket!");
            this.setDead();
            return;
        } else {
            GCLog.debug("Cargo rocket going into landing mode in same destination.");
            this.setPosition(this.targetVec.getX() + 0.5F, this.targetVec.getY() + 800, this.targetVec.getZ() + 0.5F);
            this.setLaunchPhase(EnumLaunchPhase.LANDING);
            return;
        }
    } else {
        GCLog.info("Error: the cargo rocket failed to find a valid landing spot when it reached space.");
        this.setDead();
    }
}
Also used : Entity(net.minecraft.entity.Entity) WorldProvider(net.minecraft.world.WorldProvider) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) WorldServer(net.minecraft.world.WorldServer)

Aggregations

ItemStack (net.minecraft.item.ItemStack)7 ResourceLocation (net.minecraft.util.ResourceLocation)7 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)6 Planet (micdoodle8.mods.galacticraft.api.galaxies.Planet)4 AtmosphereInfo (micdoodle8.mods.galacticraft.api.world.AtmosphereInfo)4 Vector3f (org.lwjgl.util.vector.Vector3f)4 ScalableDistance (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance)3 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 CelestialBodyRenderEvent (micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent)2 SpaceStationRecipe (micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 Entity (net.minecraft.entity.Entity)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 PotionEffect (net.minecraft.potion.PotionEffect)2 WorldProvider (net.minecraft.world.WorldProvider)2 WorldServer (net.minecraft.world.WorldServer)2 SpawnListEntry (net.minecraft.world.biome.BiomeGenBase.SpawnListEntry)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2