Search in sources :

Example 1 with Satellite

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

the class EntityEventHandler method onLivingUpdate.

@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
    EntityLivingBase living = event.getEntityLiving();
    World world = living.world;
    if (living.isDead) {
        int id = GCCoreUtil.getDimensionID(living.world);
        PacketSimpleMP.sendToAllAround(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_ENTITY_ID, id, String.valueOf(living.getEntityId())), living.world, id, living.getPosition(), 64);
    }
    if (living instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) living;
        if (ConfigManagerMP.enableStartedPlanet && !WorldTickEventHandler.startedDimensionData.startedDimension && !(ConfigManagerMP.startedPlanet.equals("planet.") || ConfigManagerMP.startedPlanet.equals("moon.") || ConfigManagerMP.startedPlanet.equals("satellite."))) {
            MPLog.debug("Start teleporting player to dimension {}", ConfigManagerMP.startedPlanet);
            TeleportUtil.startNewDimension(player);
            WorldTickEventHandler.startedDimensionData.startedDimension = true;
            WorldTickEventHandler.startedDimensionData.planetToBack = ConfigManagerMP.startedPlanet;
            WorldTickEventHandler.startedDimensionData.setDirty(true);
        }
        if (player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) || this.isInOxygen(world, player)) {
            player.removePotionEffect(MPPotions.INFECTED_SPORE);
        }
        if (player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
            player.removePotionEffect(MPPotions.DARK_ENERGY);
        }
        if (world.provider instanceof WorldProviderNibiru) {
            if (world.isRainingAt(player.getPosition()) && !this.isGodPlayer(player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
                player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
            }
            if (player.ticksExisted % 128 == 0 && !this.isGodPlayer(player) && !this.isInOxygen(world, player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
                player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
            }
        }
        if (world.provider instanceof IMeteorType) {
        // this.spawnMeteor(world, player, (IMeteorType)world.provider);
        }
    }
    if (world.provider instanceof WorldProviderNibiru) {
        if (!(living instanceof EntityPlayer) && !EntityEffectHelper.isGalacticraftMob(living) && !(living instanceof EntityJuicer)) {
            if (living.ticksExisted % 128 == 0 && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
            }
            if (world.isRainingAt(living.getPosition()) && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
            }
        }
    }
}
Also used : WorldProviderNibiru(stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru) PotionEffect(net.minecraft.potion.PotionEffect) EntityJuicer(micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) IMeteorType(stevekung.mods.moreplanets.world.IMeteorType) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with Satellite

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

the class GalacticraftCore method init.

@EventHandler
public void init(FMLInitializationEvent event) {
    GCBlocks.doOtherModsTorches();
    GalacticraftCore.handler.registerItemChanges();
    GalacticraftCore.galacticraftBlocksTab.setItemForTab(Item.getItemFromBlock(GCBlocks.machineBase2));
    GalacticraftCore.galacticraftItemsTab.setItemForTab(GCItems.rocketTier1);
    if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
        GCBlocks.finalizeSort();
        GCItems.finalizeSort();
    }
    GalacticraftCore.proxy.init(event);
    GalacticraftCore.packetPipeline = GalacticraftChannelHandler.init();
    GalacticraftCore.solarSystemSol = new SolarSystem("sol", "milky_way").setMapPosition(new Vector3(0.0F, 0.0F, 0.0F));
    Star starSol = (Star) new Star("sol").setParentSolarSystem(GalacticraftCore.solarSystemSol).setTierRequired(-1);
    starSol.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/sun.png"));
    GalacticraftCore.solarSystemSol.setMainStar(starSol);
    GalacticraftCore.planetOverworld = (Planet) new Planet("overworld").setParentSolarSystem(GalacticraftCore.solarSystemSol).setRingColorRGB(0.1F, 0.9F, 0.6F).setPhaseShift(0.0F);
    GalacticraftCore.planetOverworld.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/earth.png"));
    GalacticraftCore.planetOverworld.setDimensionInfo(ConfigManagerCore.idDimensionOverworld, WorldProvider.class, false).setTierRequired(1);
    GalacticraftCore.planetOverworld.atmosphereComponent(EnumAtmosphericGas.NITROGEN).atmosphereComponent(EnumAtmosphericGas.OXYGEN).atmosphereComponent(EnumAtmosphericGas.ARGON).atmosphereComponent(EnumAtmosphericGas.WATER);
    GalacticraftCore.planetOverworld.addChecklistKeys("equip_parachute");
    GalacticraftCore.moonMoon = (Moon) new Moon("moon").setParentPlanet(GalacticraftCore.planetOverworld).setRelativeSize(0.2667F).setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(13F, 13F)).setRelativeOrbitTime(1 / 0.01F);
    GalacticraftCore.moonMoon.setDimensionInfo(ConfigManagerCore.idDimensionMoon, WorldProviderMoon.class).setTierRequired(1);
    GalacticraftCore.moonMoon.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/moon.png"));
    GalacticraftCore.moonMoon.setAtmosphere(new AtmosphereInfo(false, false, false, 0.0F, 0.0F, 0.0F));
    GalacticraftCore.moonMoon.setBiomeInfo(BiomeGenBaseMoon.moonFlat);
    GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedZombie.class, 8, 2, 3));
    GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedSpider.class, 8, 2, 3));
    GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedSkeleton.class, 8, 2, 3));
    GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedCreeper.class, 8, 2, 3));
    GalacticraftCore.moonMoon.addMobInfo(new SpawnListEntry(EntityEvolvedEnderman.class, 10, 1, 4));
    GalacticraftCore.moonMoon.addChecklistKeys("equip_oxygen_suit");
    // Satellites must always have a WorldProvider implementing IOrbitDimension
    GalacticraftCore.satelliteSpaceStation = (Satellite) new Satellite("spacestation.overworld").setParentBody(GalacticraftCore.planetOverworld).setRelativeSize(0.2667F).setRelativeDistanceFromCenter(new CelestialBody.ScalableDistance(9F, 9F)).setRelativeOrbitTime(1 / 0.05F);
    GalacticraftCore.satelliteSpaceStation.setDimensionInfo(ConfigManagerCore.idDimensionOverworldOrbit, ConfigManagerCore.idDimensionOverworldOrbitStatic, WorldProviderOverworldOrbit.class).setTierRequired(1);
    GalacticraftCore.satelliteSpaceStation.setBodyIcon(new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/celestialbodies/space_station.png"));
    GalacticraftCore.satelliteSpaceStation.setAtmosphere(new AtmosphereInfo(false, false, false, 0.0F, 0.1F, 0.02F));
    GalacticraftCore.satelliteSpaceStation.addChecklistKeys("equip_oxygen_suit", "create_grapple");
    ForgeChunkManager.setForcedChunkLoadingCallback(GalacticraftCore.instance, new ChunkLoadingCallback());
    MinecraftForge.EVENT_BUS.register(new ConnectionEvents());
    SchematicRegistry.registerSchematicRecipe(new SchematicRocketT1());
    SchematicRegistry.registerSchematicRecipe(new SchematicMoonBuggy());
    SchematicRegistry.registerSchematicRecipe(new SchematicAdd());
    ChunkPowerHandler.initiate();
    EnergyConfigHandler.initGas();
    CompatibilityManager.registerMicroBlocks();
    this.registerCreatures();
    this.registerOtherEntities();
    this.registerTileEntities();
    GalaxyRegistry.registerSolarSystem(GalacticraftCore.solarSystemSol);
    GalaxyRegistry.registerPlanet(GalacticraftCore.planetOverworld);
    GalaxyRegistry.registerMoon(GalacticraftCore.moonMoon);
    GalaxyRegistry.registerSatellite(GalacticraftCore.satelliteSpaceStation);
    GalacticraftRegistry.registerProvider(ConfigManagerCore.idDimensionOverworldOrbit, WorldProviderOverworldOrbit.class, false, 0);
    GalacticraftRegistry.registerProvider(ConfigManagerCore.idDimensionOverworldOrbitStatic, WorldProviderOverworldOrbit.class, true, 0);
    GalacticraftRegistry.registerTeleportType(WorldProviderSurface.class, new TeleportTypeOverworld());
    GalacticraftRegistry.registerTeleportType(WorldProviderOverworldOrbit.class, new TeleportTypeOrbit());
    GalacticraftRegistry.registerTeleportType(WorldProviderMoon.class, new TeleportTypeMoon());
    GalacticraftRegistry.registerRocketGui(WorldProviderOverworldOrbit.class, new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/overworld_rocket_gui.png"));
    GalacticraftRegistry.registerRocketGui(WorldProviderSurface.class, new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/overworld_rocket_gui.png"));
    GalacticraftRegistry.registerRocketGui(WorldProviderMoon.class, new ResourceLocation(Constants.ASSET_PREFIX, "textures/gui/moon_rocket_gui.png"));
    GalacticraftRegistry.addDungeonLoot(1, new ItemStack(GCItems.schematic, 1, 0));
    GalacticraftRegistry.addDungeonLoot(1, new ItemStack(GCItems.schematic, 1, 1));
    if (ConfigManagerCore.enableCopperOreGen) {
        GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 5, 24, 0, 75, 7), 4);
    }
    if (ConfigManagerCore.enableTinOreGen) {
        GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 6, 22, 0, 60, 7), 4);
    }
    if (ConfigManagerCore.enableAluminumOreGen) {
        GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 7, 18, 0, 45, 7), 4);
    }
    if (ConfigManagerCore.enableSiliconOreGen) {
        GameRegistry.registerWorldGenerator(new OverworldGenerator(GCBlocks.basicBlock, 8, 3, 0, 25, 7), 4);
    }
    FMLInterModComms.sendMessage("OpenBlocks", "donateUrl", "http://www.patreon.com/micdoodle8");
    registerCoreGameScreens();
    GCFluids.registerLegacyFluids();
    GCFluids.registerDispenserBehaviours();
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_MASK, EnumExtendedInventorySlot.MASK, GCItems.oxMask);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_GEAR, EnumExtendedInventorySlot.GEAR, GCItems.oxygenGear);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_LIGHT, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxTankLight);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_LIGHT, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxTankLight);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_MEDIUM, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxTankMedium);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_MEDIUM, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxTankMedium);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_HEAVY, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxTankHeavy);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_HEAVY, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxTankHeavy);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_INFINITE, EnumExtendedInventorySlot.LEFT_TANK, GCItems.oxygenCanisterInfinite);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_OXYGEN_TANK_INFINITE, EnumExtendedInventorySlot.RIGHT_TANK, GCItems.oxygenCanisterInfinite);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_PARACHUTE, EnumExtendedInventorySlot.PARACHUTE, GCItems.parachute);
    GalacticraftRegistry.registerGear(Constants.GEAR_ID_FREQUENCY_MODULE, EnumExtendedInventorySlot.FREQUENCY_MODULE, new ItemStack(GCItems.basicItem, 1, 19));
    GalacticraftCore.proxy.registerFluidTexture(GCFluids.fluidOil, new ResourceLocation(Constants.ASSET_PREFIX, "textures/misc/underoil.png"));
    GalacticraftCore.proxy.registerFluidTexture(GCFluids.fluidFuel, new ResourceLocation(Constants.ASSET_PREFIX, "textures/misc/underfuel.png"));
// switch (this.getSlotIndex())
// {
// case 0:
// return itemstack.getItem() instanceof ItemOxygenMask;
// case 1:
// return itemstack.getItem() == GCItems.oxygenGear;
// case 2:
// case 3:
// return itemstack.getItem() instanceof ItemOxygenTank || itemstack.getItem() instanceof ItemCanisterOxygenInfinite;
// case 4:
// return itemstack.getItem() instanceof ItemParaChute;
// case 5:
// return itemstack.getItem() == GCItems.basicItem && itemstack.getItemDamage() == 19;
// case 6:
// return this.thermalArmorSlotValid(itemstack, 0);
// case 7:
// return this.thermalArmorSlotValid(itemstack, 1);
// case 8:
// return this.thermalArmorSlotValid(itemstack, 2);
// case 9:
// return this.thermalArmorSlotValid(itemstack, 3);
// case 10:
// return this.shieldControllerSlotValid(itemstack);
// }
}
Also used : BiomeGenBaseMoon(micdoodle8.mods.galacticraft.core.world.gen.BiomeGenBaseMoon) SchematicMoonBuggy(micdoodle8.mods.galacticraft.core.schematic.SchematicMoonBuggy) ChunkLoadingCallback(micdoodle8.mods.galacticraft.core.world.ChunkLoadingCallback) ResourceLocation(net.minecraft.util.ResourceLocation) SchematicAdd(micdoodle8.mods.galacticraft.core.schematic.SchematicAdd) WorldProvider(net.minecraft.world.WorldProvider) SchematicRocketT1(micdoodle8.mods.galacticraft.core.schematic.SchematicRocketT1) OverworldGenerator(micdoodle8.mods.galacticraft.core.world.gen.OverworldGenerator) AtmosphereInfo(micdoodle8.mods.galacticraft.api.world.AtmosphereInfo) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) SpawnListEntry(net.minecraft.world.biome.BiomeGenBase.SpawnListEntry) ConnectionEvents(micdoodle8.mods.galacticraft.core.network.ConnectionEvents) ItemStack(net.minecraft.item.ItemStack) EventHandler(net.minecraftforge.fml.common.Mod.EventHandler)

Example 3 with Satellite

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

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

the class GuiCelestialSelection method mouseClicked.

@Override
protected void mouseClicked(int x, int y, int button) throws IOException {
    super.mouseClicked(x, y, button);
    boolean clickHandled = false;
    final int LHS = GuiCelestialSelection.BORDER_SIZE + GuiCelestialSelection.BORDER_EDGE_SIZE;
    final int RHS = width - LHS;
    final int TOP = LHS;
    if (this.selectedBody != null && x > LHS && x < LHS + 88 && y > TOP && y < TOP + 13) {
        this.unselectCelestialBody();
        return;
    }
    if (!this.mapMode) {
        if (x >= RHS - 95 && x < RHS && y > TOP + 181 + canCreateOffset && y < TOP + 182 + 12 + canCreateOffset) {
            if (this.selectedBody != null) {
                SpaceStationRecipe recipe = WorldUtil.getSpaceStationRecipe(this.selectedBody.getDimensionID());
                if (recipe != null && this.canCreateSpaceStation(this.selectedBody)) {
                    if (recipe.matches(this.mc.thePlayer, false) || this.mc.thePlayer.capabilities.isCreativeMode) {
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_BIND_SPACE_STATION_ID, GCCoreUtil.getDimensionID(this.mc.theWorld), new Object[] { this.selectedBody.getDimensionID() }));
                        // Zoom in on Overworld to show the new SpaceStation if not already zoomed
                        if (!this.isZoomed()) {
                            this.selectionState = EnumSelection.ZOOMED;
                            this.preSelectZoom = this.zoom;
                            this.preSelectPosition = this.position;
                            this.ticksSinceSelection = 0;
                            this.doneZooming = false;
                        }
                        return;
                    }
                    clickHandled = true;
                }
            }
        }
    }
    if (this.mapMode) {
        if (x > RHS - 88 && x < RHS && y > TOP && y < TOP + 13) {
            this.mc.displayGuiScreen(null);
            this.mc.setIngameFocus();
            clickHandled = true;
        }
    }
    if (this.selectedBody != null && !this.mapMode) {
        if (x > RHS - 88 && x < RHS && y > TOP && y < TOP + 13) {
            if (!(this.selectedBody instanceof Satellite) || !this.selectedStationOwner.equals("")) {
                this.teleportToSelectedBody();
            }
            clickHandled = true;
        }
    }
    // Need unscaled mouse coords
    int mouseX = Mouse.getX();
    int mouseY = Mouse.getY() * -1 + Minecraft.getMinecraft().displayHeight - 1;
    if (this.selectedBody instanceof Satellite) {
        if (this.renamingSpaceStation) {
            if (x >= width / 2 - 90 && x <= width / 2 + 90 && y >= this.height / 2 - 38 && y <= this.height / 2 + 38) {
                // Apply
                if (x >= width / 2 - 90 + 17 && x <= width / 2 - 90 + 17 + 72 && y >= this.height / 2 - 38 + 59 && y <= this.height / 2 - 38 + 59 + 12) {
                    String strName = PlayerUtil.getName(this.mc.thePlayer);
                    // Integer spacestationID = this.spaceStationIDs.get(strName);
                    // if (spacestationID == null) spacestationID = this.spaceStationIDs.get(strName.toLowerCase());
                    Satellite selectedSatellite = (Satellite) this.selectedBody;
                    Integer spacestationID = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(strName).getStationDimensionID();
                    if (spacestationID == null) {
                        spacestationID = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(strName.toLowerCase()).getStationDimensionID();
                    }
                    if (spacestationID != null) {
                        this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).get(strName).setStationName(this.renamingString);
                        // this.spaceStationNames.put(strName, this.renamingString);
                        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_RENAME_SPACE_STATION, GCCoreUtil.getDimensionID(this.mc.theWorld), new Object[] { this.renamingString, spacestationID }));
                    }
                    this.renamingSpaceStation = false;
                }
                // Cancel
                if (x >= width / 2 && x <= width / 2 + 72 && y >= this.height / 2 - 38 + 59 && y <= this.height / 2 - 38 + 59 + 12) {
                    this.renamingSpaceStation = false;
                }
                clickHandled = true;
            }
        } else {
            this.drawTexturedModalRect(width / 2 - 47, TOP, 94, 11, 0, 414, 188, 22, false, false);
            if (x >= width / 2 - 47 && x <= width / 2 - 47 + 94 && y >= TOP && y <= TOP + 11) {
                if (this.selectedStationOwner.length() != 0 && this.selectedStationOwner.equalsIgnoreCase(PlayerUtil.getName(this.mc.thePlayer))) {
                    this.renamingSpaceStation = true;
                    this.renamingString = null;
                    clickHandled = true;
                }
            }
            Satellite selectedSatellite = (Satellite) this.selectedBody;
            int stationListSize = this.spaceStationMap.get(getSatelliteParentID(selectedSatellite)).size();
            int max = Math.min((this.height / 2) / 14, stationListSize);
            int xPos;
            int yPos;
            // Up button
            xPos = RHS - 85;
            yPos = TOP + 45;
            if (x >= xPos && x <= xPos + 61 && y >= yPos && y <= yPos + 4) {
                if (this.spaceStationListOffset > 0) {
                    this.spaceStationListOffset--;
                }
                clickHandled = true;
            }
            // Down button
            xPos = RHS - 85;
            yPos = TOP + 49 + max * 14;
            if (x >= xPos && x <= xPos + 61 && y >= yPos && y <= yPos + 4) {
                if (max + spaceStationListOffset < stationListSize) {
                    this.spaceStationListOffset++;
                }
                clickHandled = true;
            }
            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) {
                    int xOffset = 0;
                    if (e.getKey().equalsIgnoreCase(this.selectedStationOwner)) {
                        xOffset -= 5;
                    }
                    xPos = RHS - 95 + xOffset;
                    yPos = TOP + 50 + i * 14;
                    if (x >= xPos && x <= xPos + 93 && y >= yPos && y <= yPos + 12) {
                        this.selectedStationOwner = e.getKey();
                        clickHandled = true;
                    }
                    i++;
                }
                j++;
            }
        }
    }
    int xPos = LHS + 2;
    int yPos = TOP + 10;
    boolean planetZoomedMoon = this.isZoomed() && this.selectedParent instanceof Planet;
    // Top yellow button e.g. Sol
    if (x >= xPos && x <= xPos + 93 && y >= yPos && y <= yPos + 12 && this.selectedParent instanceof CelestialBody) {
        if (this.selectedBody == null) {
            this.preSelectZoom = this.zoom;
            this.preSelectPosition = this.position;
        }
        EnumSelection selectionCountOld = this.selectionState;
        if (this.isSelected()) {
            this.unselectCelestialBody();
        }
        if (selectionCountOld == EnumSelection.ZOOMED) {
            this.selectionState = EnumSelection.SELECTED;
        }
        this.selectedBody = (CelestialBody) this.selectedParent;
        this.ticksSinceSelection = 0;
        this.selectionState = EnumSelection.values()[this.selectionState.ordinal() + 1];
        if (this.isZoomed() && !planetZoomedMoon) {
            this.ticksSinceMenuOpen = 0;
        }
        clickHandled = true;
    }
    yPos += 22;
    // First blue button - normally the Selected Body (but it's the parent planet if this is a moon)
    if (x >= xPos && x <= xPos + 93 && y >= yPos && y <= yPos + 12) {
        if (planetZoomedMoon) {
            if (this.selectedBody == null) {
                this.preSelectZoom = this.zoom;
                this.preSelectPosition = this.position;
            }
            EnumSelection selectionCountOld = this.selectionState;
            if (this.isSelected()) {
                this.unselectCelestialBody();
            }
            if (selectionCountOld == EnumSelection.ZOOMED) {
                this.selectionState = EnumSelection.SELECTED;
            }
            this.selectedBody = (CelestialBody) this.selectedParent;
            this.ticksSinceSelection = 0;
            this.selectionState = EnumSelection.values()[this.selectionState.ordinal() + 1];
        }
        clickHandled = true;
    }
    if (!clickHandled) {
        List<CelestialBody> children = this.getChildren(this.isZoomed() ? this.selectedBody : this.selectedParent);
        yPos = TOP + 50;
        for (CelestialBody child : children) {
            clickHandled = this.testClicked(child, child.equals(this.selectedBody) ? 5 : 0, yPos, x, y, false);
            yPos += 14;
            if (!clickHandled && !this.isZoomed() && child.equals(this.selectedBody)) {
                List<CelestialBody> grandchildren = this.getChildren(child);
                int gOffset = 0;
                for (CelestialBody grandchild : grandchildren) {
                    if (gOffset + 14 > this.animateGrandchildren) {
                        break;
                    }
                    clickHandled = this.testClicked(grandchild, 10, yPos, x, y, true);
                    yPos += 14;
                    gOffset += 14;
                    if (clickHandled)
                        break;
                }
                yPos += this.animateGrandchildren - gOffset;
            }
            if (clickHandled)
                break;
        }
    }
    if (!clickHandled) {
        for (Map.Entry<CelestialBody, Vector3f> e : this.planetPosMap.entrySet()) {
            CelestialBody bodyClicked = e.getKey();
            if (this.selectedBody == null && bodyClicked instanceof IChildBody) {
                continue;
            }
            // Z value holds size on-screen
            float iconSize = e.getValue().z;
            if (mouseX >= e.getValue().x - iconSize && mouseX <= e.getValue().x + iconSize && mouseY >= e.getValue().y - iconSize && mouseY <= e.getValue().y + iconSize) {
                if (this.selectedBody != bodyClicked || !this.isZoomed()) {
                    if (this.isSelected() && this.selectedBody != bodyClicked) {
                        if (!(this.selectedBody instanceof IChildBody && ((IChildBody) this.selectedBody).getParentPlanet() == bodyClicked)) {
                            this.unselectCelestialBody();
                        } else if (this.isZoomed()) {
                            this.selectionState = EnumSelection.SELECTED;
                        }
                    }
                    this.doneZooming = false;
                    this.planetZoom = 0.0F;
                    if (bodyClicked != this.selectedBody) {
                        this.lastSelectedBody = this.selectedBody;
                    }
                    this.selectedBody = bodyClicked;
                    this.ticksSinceSelection = 0;
                    this.selectionState = EnumSelection.values()[this.selectionState.ordinal() + 1];
                    if (this.isZoomed()) {
                        this.ticksSinceMenuOpen = 0;
                    }
                    // Auto select if it's a spacestation and there is only a single entry
                    if (this.selectedBody instanceof Satellite && this.spaceStationMap.get(this.getSatelliteParentID((Satellite) this.selectedBody)).size() == 1) {
                        Iterator<Map.Entry<String, StationDataGUI>> it = this.spaceStationMap.get(this.getSatelliteParentID((Satellite) this.selectedBody)).entrySet().iterator();
                        this.selectedStationOwner = it.next().getKey();
                    }
                    clickHandled = true;
                    break;
                }
            }
        }
    }
    if (!clickHandled) {
        if (this.selectedBody != null) {
            this.unselectCelestialBody();
            this.planetZoom = 0.0F;
        }
        mouseDragging = true;
    }
    Object selectedParent = this.selectedParent;
    if (this.selectedBody instanceof IChildBody) {
        selectedParent = ((IChildBody) this.selectedBody).getParentPlanet();
    } else if (this.selectedBody instanceof Planet) {
        selectedParent = ((Planet) this.selectedBody).getParentSolarSystem();
    } else if (this.selectedBody == null) {
        selectedParent = GalacticraftCore.solarSystemSol;
    }
    if (this.selectedParent != selectedParent) {
        this.selectedParent = selectedParent;
    }
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) SpaceStationRecipe(micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe) Vector3f(org.lwjgl.util.vector.Vector3f)

Example 5 with Satellite

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

the class GuiCelestialSelection method drawCircles.

public void drawCircles() {
    GL11.glColor4f(1, 1, 1, 1);
    GL11.glLineWidth(3);
    int count = 0;
    final float theta = (float) (2 * Math.PI / 90);
    final float cos = (float) Math.cos(theta);
    final float sin = (float) Math.sin(theta);
    for (Planet planet : GalaxyRegistry.getRegisteredPlanets().values()) {
        if (planet.getParentSolarSystem() != null) {
            Vector3f systemOffset = this.getCelestialBodyPosition(planet.getParentSolarSystem().getMainStar());
            float x = this.getScale(planet);
            float y = 0;
            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) && !(this.selectedBody instanceof Satellite)) {
                    alpha = 1.0F - Math.min(this.ticksSinceSelection / 25.0F, 1.0F);
                } else {
                    alpha = 0.0F;
                }
            }
            if (alpha != 0) {
                switch(count % 2) {
                    case 0:
                        GL11.glColor4f(0.0F / 1.4F, 0.6F / 1.4F, 1.0F / 1.4F, alpha / 1.4F);
                        break;
                    case 1:
                        GL11.glColor4f(0.3F / 1.4F, 0.8F / 1.4F, 1.0F / 1.4F, alpha / 1.4F);
                        break;
                }
                CelestialBodyRenderEvent.CelestialRingRenderEvent.Pre preEvent = new CelestialBodyRenderEvent.CelestialRingRenderEvent.Pre(planet, systemOffset);
                MinecraftForge.EVENT_BUS.post(preEvent);
                if (!preEvent.isCanceled()) {
                    GL11.glTranslatef(systemOffset.x, systemOffset.y, systemOffset.z);
                    GL11.glBegin(GL11.GL_LINE_LOOP);
                    float temp;
                    for (int i = 0; i < 90; i++) {
                        GL11.glVertex2f(x, y);
                        temp = x;
                        x = cos * x - sin * y;
                        y = sin * temp + cos * y;
                    }
                    GL11.glEnd();
                    GL11.glTranslatef(-systemOffset.x, -systemOffset.y, -systemOffset.z);
                    count++;
                }
                CelestialBodyRenderEvent.CelestialRingRenderEvent.Post postEvent = new CelestialBodyRenderEvent.CelestialRingRenderEvent.Post(planet);
                MinecraftForge.EVENT_BUS.post(postEvent);
            }
        }
    }
    count = 0;
    if (this.selectedBody != null) {
        Vector3f planetPos = this.getCelestialBodyPosition(this.selectedBody);
        if (this.selectedBody instanceof IChildBody) {
            planetPos = this.getCelestialBodyPosition(((IChildBody) this.selectedBody).getParentPlanet());
        } else if (this.selectedBody instanceof Satellite) {
            planetPos = this.getCelestialBodyPosition(((Satellite) this.selectedBody).getParentPlanet());
        }
        GL11.glTranslatef(planetPos.x, planetPos.y, 0);
        for (Moon moon : GalaxyRegistry.getRegisteredMoons().values()) {
            if ((moon.getParentPlanet() == this.selectedBody && this.selectionState != EnumSelection.SELECTED) || moon == this.selectedBody || getSiblings(this.selectedBody).contains(moon)) {
                if (this.drawCircle(moon, count, sin, cos)) {
                    count++;
                }
            }
        }
        for (Satellite satellite : GalaxyRegistry.getRegisteredSatellites().values()) {
            if (this.possibleBodies != null && this.possibleBodies.contains(satellite)) {
                if ((satellite.getParentPlanet() == this.selectedBody && this.selectionState != EnumSelection.SELECTED) && this.ticksSinceSelection > 24 || satellite == this.selectedBody || this.lastSelectedBody instanceof IChildBody) {
                    if (this.drawCircle(satellite, count, sin, cos)) {
                        count++;
                    }
                }
            }
        }
    }
    GL11.glLineWidth(1);
}
Also used : CelestialBodyRenderEvent(micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent) Vector3f(org.lwjgl.util.vector.Vector3f)

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