Search in sources :

Example 1 with CelestialBody

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

the class SpaceRace method saveToNBT.

public void saveToNBT(NBTTagCompound nbt) {
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Saving spacerace data for team " + this.teamName);
    }
    nbt.setString("TeamName", this.teamName);
    nbt.setInteger("SpaceRaceID", this.spaceRaceID);
    nbt.setLong("TicksSpent", this.ticksSpent);
    this.flagData.saveFlagData(nbt);
    nbt.setDouble("teamColorR", this.teamColor.x);
    nbt.setDouble("teamColorG", this.teamColor.y);
    nbt.setDouble("teamColorB", this.teamColor.z);
    NBTTagList tagList = new NBTTagList();
    for (String player : this.playerNames) {
        NBTTagCompound tagComp = new NBTTagCompound();
        tagComp.setString("PlayerName", player);
        tagList.appendTag(tagComp);
    }
    nbt.setTag("PlayerList", tagList);
    tagList = new NBTTagList();
    for (Entry<CelestialBody, Integer> celestialBody : this.celestialBodyStatusList.entrySet()) {
        NBTTagCompound tagComp = new NBTTagCompound();
        tagComp.setString("CelestialBodyName", celestialBody.getKey().getUnlocalizedName());
        tagComp.setInteger("TimeTaken", celestialBody.getValue());
        tagList.appendTag(tagComp);
    }
    nbt.setTag("CelestialBodyList", tagList);
    tagList = new NBTTagList();
    for (Entry<String, List<ItemStack>> schematic : this.schematicsToUnlock.entrySet()) {
        if (this.playerNames.contains(schematic.getKey())) {
            NBTTagCompound tagComp = new NBTTagCompound();
            tagComp.setString("Mem", schematic.getKey());
            final NBTTagList itemList = new NBTTagList();
            for (ItemStack stack : schematic.getValue()) {
                final NBTTagCompound itemTag = new NBTTagCompound();
                stack.writeToNBT(itemTag);
                itemList.appendTag(itemTag);
            }
            tagComp.setTag("Sch", itemList);
            tagList.appendTag(tagComp);
        }
    }
    nbt.setTag("SchList", tagList);
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Saved spacerace team data OK.");
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) ArrayList(java.util.ArrayList) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) ItemStack(net.minecraft.item.ItemStack)

Example 2 with CelestialBody

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

the class SpaceRace method loadFromNBT.

public void loadFromNBT(NBTTagCompound nbt) {
    this.teamName = nbt.getString("TeamName");
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Loading spacerace data for team " + this.teamName);
    }
    this.spaceRaceID = nbt.getInteger("SpaceRaceID");
    // Deal with legacy error
    this.ticksSpent = (int) nbt.getLong("TicksSpent");
    this.flagData = FlagData.readFlagData(nbt);
    this.teamColor = new Vector3(nbt.getDouble("teamColorR"), nbt.getDouble("teamColorG"), nbt.getDouble("teamColorB"));
    NBTTagList tagList = nbt.getTagList("PlayerList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        this.playerNames.add(tagAt.getString("PlayerName"));
    }
    tagList = nbt.getTagList("CelestialBodyList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        CelestialBody body = GalaxyRegistry.getCelestialBodyFromUnlocalizedName(tagAt.getString("CelestialBodyName"));
        if (body != null) {
            this.celestialBodyStatusList.put(body, tagAt.getInteger("TimeTaken"));
        }
    }
    tagList = nbt.getTagList("SchList", 10);
    for (int i = 0; i < tagList.tagCount(); i++) {
        NBTTagCompound tagAt = tagList.getCompoundTagAt(i);
        String name = tagAt.getString("Mem");
        if (name != null && this.playerNames.contains(name)) {
            final NBTTagList itemList = tagAt.getTagList("Sch", 10);
            for (int j = 0; j < itemList.tagCount(); ++j) {
                addNewSchematic(name, ItemStack.loadItemStackFromNBT(itemList.getCompoundTagAt(j)));
            }
        }
    }
    if (ConfigManagerCore.enableDebug) {
        GCLog.info("Loaded spacerace team data OK.");
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3)

Example 3 with CelestialBody

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

the class GameScreenCelestial method drawCelestialBodies.

private void drawCelestialBodies(CelestialBody body, float ticks) {
    Star star = null;
    SolarSystem solarSystem = null;
    if (body instanceof Planet) {
        solarSystem = ((Planet) body).getParentSolarSystem();
    } else if (body instanceof Moon) {
        solarSystem = ((Moon) body).getParentPlanet().getParentSolarSystem();
    } else if (body instanceof Satellite) {
        solarSystem = ((Satellite) body).getParentPlanet().getParentSolarSystem();
    }
    if (solarSystem == null) {
        solarSystem = GalacticraftCore.solarSystemSol;
    }
    star = solarSystem.getMainStar();
    if (star != null && star.getBodyIcon() != null) {
        this.drawCelestialBody(star, 0F, 0F, ticks, 6F, 1.0);
    }
    String mainSolarSystem = solarSystem.getUnlocalizedName();
    for (Planet planet : GalaxyRegistry.getRegisteredPlanets().values()) {
        if (planet.getParentSolarSystem() != null && planet.getBodyIcon() != null) {
            if (planet.getParentSolarSystem().getUnlocalizedName().equalsIgnoreCase(mainSolarSystem)) {
                Vector3f pos = this.getCelestialBodyPosition(planet, ticks);
                this.drawCircle(planet);
                this.drawCelestialBody(planet, pos.x, pos.y, ticks, (planet.getRelativeDistanceFromCenter().unScaledDistance < 1.5F) ? 2F : 2.8F, 0.75);
            }
        }
    }
}
Also used : Vector3f(org.lwjgl.util.vector.Vector3f) RenderPlanet(micdoodle8.mods.galacticraft.core.client.render.RenderPlanet)

Example 4 with CelestialBody

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

the class GameScreenCelestial method drawCircle.

private void drawCircle(CelestialBody cBody) {
    GL11.glPushMatrix();
    GL11.glTranslatef(centreX, centreY, 0.002F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    float sd = 0.002514F * scale;
    float x = this.getScale(cBody);
    float y = 0;
    float grey = 0.1F + 0.65F * Math.max(0F, (0.5F - x));
    x = x * scale / sd;
    GL11.glColor4f(grey, grey, grey, 1.0F);
    GL11.glLineWidth(0.002F);
    GL11.glScalef(sd, sd, sd);
    CelestialBodyRenderEvent.CelestialRingRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.CelestialRingRenderEvent.Pre(cBody, new Vector3f(0.0F, 0.0F, 0.0F));
    MinecraftForge.EVENT_BUS.post(preEvent);
    if (!preEvent.isCanceled()) {
        GL11.glBegin(GL11.GL_LINE_LOOP);
        float temp;
        for (int i = 0; i < lineSegments; i++) {
            GL11.glVertex2f(x, y);
            temp = x;
            x = cos * x - sin * y;
            y = sin * temp + cos * y;
        }
        GL11.glEnd();
    }
    CelestialBodyRenderEvent.CelestialRingRenderEvent.Post postEvent = new CelestialBodyRenderEvent.CelestialRingRenderEvent.Post(cBody);
    MinecraftForge.EVENT_BUS.post(postEvent);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glPopMatrix();
}
Also used : CelestialBodyRenderEvent(micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent) Vector3f(org.lwjgl.util.vector.Vector3f)

Example 5 with CelestialBody

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

the class GameScreenCelestial method render.

@Override
public void render(int type, float ticks, float scaleX, float scaleY, IScreenManager scr) {
    centreX = scaleX / 2;
    centreY = scaleY / 2;
    frameBx = scaleX - frameA;
    frameBy = scaleY - frameA;
    this.scale = Math.max(scaleX, scaleY) - 0.2F;
    drawBlackBackground(0.0F);
    planeEquation(frameA, frameA, 0, frameA, frameBy, 0, frameA, frameBy, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE0, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE0);
    planeEquation(frameBx, frameBy, 0, frameBx, frameA, 0, frameBx, frameA, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE1, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE1);
    planeEquation(frameA, frameBy, 0, frameBx, frameBy, 0, frameBx, frameBy, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE2, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE2);
    planeEquation(frameBx, frameA, 0, frameA, frameA, 0, frameA, frameA, 1);
    GL11.glClipPlane(GL11.GL_CLIP_PLANE3, planes);
    GL11.glEnable(GL11.GL_CLIP_PLANE3);
    switch(type) {
        case 2:
            WorldProvider wp = scr.getWorldProvider();
            CelestialBody body = null;
            if (wp instanceof IGalacticraftWorldProvider) {
                body = ((IGalacticraftWorldProvider) wp).getCelestialBody();
            }
            if (body == null) {
                body = GalacticraftCore.planetOverworld;
            }
            drawCelestialBodies(body, ticks);
            break;
        case 3:
            drawCelestialBodiesZ(GalacticraftCore.planetOverworld, ticks);
            break;
        case 4:
            drawPlanetsTest(ticks);
            break;
    }
    GL11.glDisable(GL11.GL_CLIP_PLANE3);
    GL11.glDisable(GL11.GL_CLIP_PLANE2);
    GL11.glDisable(GL11.GL_CLIP_PLANE1);
    GL11.glDisable(GL11.GL_CLIP_PLANE0);
}
Also used : IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider) WorldProvider(net.minecraft.world.WorldProvider) IGalacticraftWorldProvider(micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)

Aggregations

CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)5 Vector3f (org.lwjgl.util.vector.Vector3f)5 CelestialBodyRenderEvent (micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent)3 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)3 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)3 ItemStack (net.minecraft.item.ItemStack)3 GameProfile (com.mojang.authlib.GameProfile)2 Property (com.mojang.authlib.properties.Property)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2 SpaceStationRecipe (micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe)2 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)2 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)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