Search in sources :

Example 1 with Moon

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

the class CelestialRegisterHelper method createMoon.

public static Moon createMoon(String name, Planet planet, float phaseShift, float distance, float orbitTime, float size, int tier, int id, Class<? extends WorldProvider> provider) {
    Moon moon = new Moon(name).setParentPlanet(planet);
    moon.setDimensionInfo(id, provider);
    moon.setPhaseShift(phaseShift);
    moon.setRelativeDistanceFromCenter(new ScalableDistance(distance, distance));
    moon.setRelativeOrbitTime(orbitTime);
    moon.setRelativeSize(size);
    moon.setTierRequired(tier);
    moon.setBodyIcon(new ResourceLocation("moreplanets:textures/gui/celestialbodies/" + name + ".png"));
    return moon;
}
Also used : ScalableDistance(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance) ResourceLocation(net.minecraft.util.ResourceLocation)

Example 2 with Moon

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

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

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

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

Aggregations

Vector3f (org.lwjgl.util.vector.Vector3f)5 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)4 CelestialBodyRenderEvent (micdoodle8.mods.galacticraft.api.event.client.CelestialBodyRenderEvent)3 ItemStack (net.minecraft.item.ItemStack)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 ScalableDistance (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance)2 SpaceStationRecipe (micdoodle8.mods.galacticraft.api.recipe.SpaceStationRecipe)2 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)2 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)2 WorldProviderMoon (micdoodle8.mods.galacticraft.core.dimension.WorldProviderMoon)2 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)2 IBlockState (net.minecraft.block.state.IBlockState)2 PotionEffect (net.minecraft.potion.PotionEffect)2 WorldProvider (net.minecraft.world.WorldProvider)2 PacketSimpleMP (stevekung.mods.moreplanets.network.PacketSimpleMP)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 FloatBuffer (java.nio.FloatBuffer)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1