Search in sources :

Example 1 with SolarSystem

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

the class CelestialRegisterHelper method createPlanet.

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

Example 2 with SolarSystem

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

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

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

the class CelestialRegistryUtils method createPlanet.

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

Example 5 with SolarSystem

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

the class PacketSimple method handleServerSide.

@Override
public void handleServerSide(EntityPlayer player) {
    final EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
    if (playerBase == null) {
        return;
    }
    final MinecraftServer server = playerBase.mcServer;
    final GCPlayerStats stats = GCPlayerStats.get(playerBase);
    switch(this.type) {
        case S_RESPAWN_PLAYER:
            playerBase.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.getDifficulty(), player.worldObj.getWorldInfo().getTerrainType(), playerBase.theItemInWorldManager.getGameType()));
            break;
        case S_TELEPORT_ENTITY:
            TickHandlerServer.scheduleNewDimensionChange(new ScheduledDimensionChange(playerBase, (String) PacketSimple.this.data.get(0)));
            break;
        case S_IGNITE_ROCKET:
            if (!player.worldObj.isRemote && !player.isDead && player.ridingEntity != null && !player.ridingEntity.isDead && player.ridingEntity instanceof EntityTieredRocket) {
                final EntityTieredRocket ship = (EntityTieredRocket) player.ridingEntity;
                if (ship.launchPhase != EnumLaunchPhase.LANDING.ordinal()) {
                    if (ship.hasValidFuel()) {
                        ItemStack stack2 = stats.getExtendedInventory().getStackInSlot(4);
                        if (stack2 != null && stack2.getItem() instanceof ItemParaChute || stats.getLaunchAttempts() > 0) {
                            ship.igniteCheckingCooldown();
                            stats.setLaunchAttempts(0);
                        } else if (stats.getChatCooldown() == 0 && stats.getLaunchAttempts() == 0) {
                            player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.noparachute")));
                            stats.setChatCooldown(250);
                            stats.setLaunchAttempts(1);
                        }
                    } else if (stats.getChatCooldown() == 0) {
                        player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.rocket.warning.nofuel")));
                        stats.setChatCooldown(250);
                    }
                }
            }
            break;
        case S_OPEN_SCHEMATIC_PAGE:
            if (player != null) {
                final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID((Integer) this.data.get(0));
                player.openGui(GalacticraftCore.instance, page.getGuiID(), player.worldObj, (Integer) this.data.get(1), (Integer) this.data.get(2), (Integer) this.data.get(3));
            }
            break;
        case S_OPEN_FUEL_GUI:
            if (player.ridingEntity instanceof EntityBuggy) {
                GCCoreUtil.openBuggyInv(playerBase, (EntityBuggy) player.ridingEntity, ((EntityBuggy) player.ridingEntity).getType());
            } else if (player.ridingEntity instanceof EntitySpaceshipBase) {
                player.openGui(GalacticraftCore.instance, GuiIdsCore.ROCKET_INVENTORY, player.worldObj, (int) player.posX, (int) player.posY, (int) player.posZ);
            }
            break;
        case S_UPDATE_SHIP_YAW:
            if (player.ridingEntity instanceof EntitySpaceshipBase) {
                final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
                if (ship != null) {
                    ship.rotationYaw = (Float) this.data.get(0);
                }
            }
            break;
        case S_UPDATE_SHIP_PITCH:
            if (player.ridingEntity instanceof EntitySpaceshipBase) {
                final EntitySpaceshipBase ship = (EntitySpaceshipBase) player.ridingEntity;
                if (ship != null) {
                    ship.rotationPitch = (Float) this.data.get(0);
                }
            }
            break;
        case S_SET_ENTITY_FIRE:
            Entity entity = player.worldObj.getEntityByID((Integer) this.data.get(0));
            if (entity instanceof EntityLivingBase) {
                ((EntityLivingBase) entity).setFire(3);
            }
            break;
        case S_BIND_SPACE_STATION_ID:
            int homeID = (Integer) this.data.get(0);
            if ((!stats.getSpaceStationDimensionData().containsKey(homeID) || stats.getSpaceStationDimensionData().get(homeID) == -1 || stats.getSpaceStationDimensionData().get(homeID) == 0) && !ConfigManagerCore.disableSpaceStationCreation) {
                if (playerBase.capabilities.isCreativeMode || WorldUtil.getSpaceStationRecipe(homeID).matches(playerBase, true)) {
                    WorldUtil.bindSpaceStationToNewDimension(playerBase.worldObj, playerBase, homeID);
                }
            }
            break;
        case S_UNLOCK_NEW_SCHEMATIC:
            final Container container = player.openContainer;
            if (container instanceof ContainerSchematic) {
                final ContainerSchematic schematicContainer = (ContainerSchematic) container;
                ItemStack stack = schematicContainer.craftMatrix.getStackInSlot(0);
                if (stack != null) {
                    final ISchematicPage page = SchematicRegistry.getMatchingRecipeForItemStack(stack);
                    if (page != null) {
                        SchematicRegistry.unlockNewPage(playerBase, stack);
                        SpaceRaceManager.teamUnlockSchematic(playerBase, stack);
                        if (--stack.stackSize <= 0) {
                            stack = null;
                        }
                        schematicContainer.craftMatrix.setInventorySlotContents(0, stack);
                        schematicContainer.craftMatrix.markDirty();
                        GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_ADD_NEW_SCHEMATIC, getDimensionID(), new Object[] { page.getPageID() }), playerBase);
                    }
                }
            }
            break;
        case S_UPDATE_DISABLEABLE_BUTTON:
            final TileEntity tileAt = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tileAt instanceof IDisableableMachine) {
                final IDisableableMachine machine = (IDisableableMachine) tileAt;
                machine.setDisabled((Integer) this.data.get(1), !machine.getDisabled((Integer) this.data.get(1)));
            }
            break;
        case S_ON_FAILED_CHEST_UNLOCK:
            if (stats.getChatCooldown() == 0) {
                player.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.chest.warning.wrongkey", this.data.get(0))));
                stats.setChatCooldown(100);
            }
            break;
        case S_RENAME_SPACE_STATION:
            final SpaceStationWorldData ssdata = SpaceStationWorldData.getStationData(playerBase.worldObj, (Integer) this.data.get(1), playerBase);
            if (ssdata != null && ssdata.getOwner().equalsIgnoreCase(PlayerUtil.getName(player))) {
                ssdata.setSpaceStationName((String) this.data.get(0));
                ssdata.setDirty(true);
            }
            break;
        case S_OPEN_EXTENDED_INVENTORY:
            player.openGui(GalacticraftCore.instance, GuiIdsCore.EXTENDED_INVENTORY, player.worldObj, 0, 0, 0);
            break;
        case S_ON_ADVANCED_GUI_CLICKED_INT:
            TileEntity tile1 = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
            switch((Integer) this.data.get(0)) {
                case 0:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.redstoneActivation = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 1:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.playerDistanceActivation = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 2:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.playerDistanceSelection = (Integer) this.data.get(2);
                    }
                    break;
                case 3:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.playerNameMatches = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 4:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.invertSelection = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 5:
                    if (tile1 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile1;
                        airlockController.lastHorizontalModeEnabled = airlockController.horizontalModeEnabled;
                        airlockController.horizontalModeEnabled = (Integer) this.data.get(2) == 1;
                    }
                    break;
                case 6:
                    if (tile1 instanceof IBubbleProvider) {
                        IBubbleProvider distributor = (IBubbleProvider) tile1;
                        distributor.setBubbleVisible((Integer) this.data.get(2) == 1);
                    }
                    break;
                default:
                    break;
            }
            break;
        case S_ON_ADVANCED_GUI_CLICKED_STRING:
            TileEntity tile2 = player.worldObj.getTileEntity((BlockPos) this.data.get(1));
            switch((Integer) this.data.get(0)) {
                case 0:
                    if (tile2 instanceof TileEntityAirLockController) {
                        TileEntityAirLockController airlockController = (TileEntityAirLockController) tile2;
                        airlockController.playerToOpenFor = (String) this.data.get(2);
                    }
                    break;
                default:
                    break;
            }
            break;
        case S_UPDATE_SHIP_MOTION_Y:
            int entityID = (Integer) this.data.get(0);
            boolean up = (Boolean) this.data.get(1);
            Entity entity2 = player.worldObj.getEntityByID(entityID);
            if (entity2 instanceof EntityAutoRocket) {
                EntityAutoRocket autoRocket = (EntityAutoRocket) entity2;
                autoRocket.motionY += up ? 0.02F : -0.02F;
            }
            break;
        case S_START_NEW_SPACE_RACE:
            Integer teamID = (Integer) this.data.get(0);
            String teamName = (String) this.data.get(1);
            FlagData flagData = (FlagData) this.data.get(2);
            Vector3 teamColor = (Vector3) this.data.get(3);
            List<String> playerList = new ArrayList<String>();
            for (int i = 4; i < this.data.size(); i++) {
                playerList.add((String) this.data.get(i));
            }
            boolean previousData = SpaceRaceManager.getSpaceRaceFromID(teamID) != null;
            SpaceRace newRace = new SpaceRace(playerList, teamName, flagData, teamColor);
            if (teamID > 0) {
                newRace.setSpaceRaceID(teamID);
            }
            SpaceRaceManager.addSpaceRace(newRace);
            if (previousData) {
                SpaceRaceManager.sendSpaceRaceData(server, null, SpaceRaceManager.getSpaceRaceFromPlayer(PlayerUtil.getName(playerBase)));
            }
            break;
        case S_REQUEST_FLAG_DATA:
            SpaceRaceManager.sendSpaceRaceData(server, playerBase, SpaceRaceManager.getSpaceRaceFromPlayer((String) this.data.get(0)));
            break;
        case S_INVITE_RACE_PLAYER:
            EntityPlayerMP playerInvited = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, (String) this.data.get(0), true);
            if (playerInvited != null) {
                Integer teamInvitedTo = (Integer) this.data.get(1);
                SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo);
                if (race != null) {
                    GCPlayerStats.get(playerInvited).setSpaceRaceInviteTeamID(teamInvitedTo);
                    String dA = EnumColor.DARK_AQUA.getCode();
                    String bG = EnumColor.BRIGHT_GREEN.getCode();
                    String dB = EnumColor.PURPLE.getCode();
                    String teamNameTotal = "";
                    String[] teamNameSplit = race.getTeamName().split(" ");
                    for (String teamNamePart : teamNameSplit) {
                        teamNameTotal = teamNameTotal.concat(dB + teamNamePart + " ");
                    }
                    playerInvited.addChatMessage(new ChatComponentText(dA + GCCoreUtil.translateWithFormat("gui.space_race.chat.invite_received", bG + PlayerUtil.getName(player) + dA) + "  " + GCCoreUtil.translateWithFormat("gui.space_race.chat.to_join", teamNameTotal, EnumColor.AQUA + "/joinrace" + dA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
                }
            }
            break;
        case S_REMOVE_RACE_PLAYER:
            Integer teamInvitedTo = (Integer) this.data.get(1);
            SpaceRace race = SpaceRaceManager.getSpaceRaceFromID(teamInvitedTo);
            if (race != null) {
                String playerToRemove = (String) this.data.get(0);
                if (!race.getPlayerNames().remove(playerToRemove)) {
                    player.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("gui.space_race.chat.not_found", playerToRemove)));
                } else {
                    SpaceRaceManager.onPlayerRemoval(server, playerToRemove, race);
                }
            }
            break;
        case S_ADD_RACE_PLAYER:
            Integer teamToAddPlayer = (Integer) this.data.get(1);
            SpaceRace spaceRaceToAddPlayer = SpaceRaceManager.getSpaceRaceFromID(teamToAddPlayer);
            if (spaceRaceToAddPlayer != null) {
                String playerToAdd = (String) this.data.get(0);
                if (!spaceRaceToAddPlayer.getPlayerNames().contains(playerToAdd)) {
                    SpaceRace oldRace = null;
                    while ((oldRace = SpaceRaceManager.getSpaceRaceFromPlayer(playerToAdd)) != null) {
                        SpaceRaceManager.removeSpaceRace(oldRace);
                    }
                    spaceRaceToAddPlayer.getPlayerNames().add(playerToAdd);
                    SpaceRaceManager.sendSpaceRaceData(server, null, spaceRaceToAddPlayer);
                    for (String member : spaceRaceToAddPlayer.getPlayerNames()) {
                        EntityPlayerMP memberObj = PlayerUtil.getPlayerForUsernameVanilla(server, member);
                        if (memberObj != null) {
                            memberObj.addChatMessage(new ChatComponentText(EnumColor.DARK_AQUA + GCCoreUtil.translateWithFormat("gui.space_race.chat.add_success", EnumColor.BRIGHT_GREEN + playerToAdd + EnumColor.DARK_AQUA)).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_AQUA)));
                        }
                    }
                } else {
                    player.addChatMessage(new ChatComponentText(GCCoreUtil.translate("gui.space_race.chat.already_part")).setChatStyle(new ChatStyle().setColor(EnumChatFormatting.DARK_RED)));
                }
            }
            break;
        case S_COMPLETE_CBODY_HANDSHAKE:
            String completeList = (String) this.data.get(0);
            List<String> clientObjects = Arrays.asList(completeList.split(";"));
            List<String> serverObjects = Lists.newArrayList();
            String missingObjects = "";
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredPlanets().values()) {
                serverObjects.add(cBody.getUnlocalizedName());
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredMoons().values()) {
                serverObjects.add(cBody.getUnlocalizedName());
            }
            for (CelestialBody cBody : GalaxyRegistry.getRegisteredSatellites().values()) {
                serverObjects.add(cBody.getUnlocalizedName());
            }
            for (SolarSystem solarSystem : GalaxyRegistry.getRegisteredSolarSystems().values()) {
                serverObjects.add(solarSystem.getUnlocalizedName());
            }
            for (String str : serverObjects) {
                if (!clientObjects.contains(str)) {
                    missingObjects = missingObjects.concat(str + "\n");
                }
            }
            if (missingObjects.length() > 0) {
                playerBase.playerNetServerHandler.kickPlayerFromServer("Missing Galacticraft Celestial Objects:\n\n " + missingObjects);
            }
            break;
        case S_REQUEST_GEAR_DATA:
            String name = (String) this.data.get(0);
            EntityPlayerMP e = PlayerUtil.getPlayerBaseServerFromPlayerUsername(name, true);
            if (e != null) {
                GCPlayerHandler.checkGear(e, GCPlayerStats.get(e), true);
            }
            break;
        case S_BUILDFLAGS_UPDATE:
            stats.setBuildFlags((Integer) this.data.get(0));
            break;
        case S_REQUEST_OVERWORLD_IMAGE:
            MapUtil.sendOverworldToClient(playerBase);
            break;
        case S_REQUEST_MAP_IMAGE:
            int dim = (Integer) this.data.get(0);
            int cx = (Integer) this.data.get(1);
            int cz = (Integer) this.data.get(2);
            MapUtil.sendOrCreateMap(WorldUtil.getProviderForDimensionServer(dim).worldObj, cx, cz, playerBase);
            break;
        case S_REQUEST_PLAYERSKIN:
            String strName = (String) this.data.get(0);
            EntityPlayerMP playerRequested = server.getConfigurationManager().getPlayerByUsername(strName);
            // Player not online
            if (playerRequested == null) {
                return;
            }
            GameProfile gp = playerRequested.getGameProfile();
            if (gp == null) {
                return;
            }
            Property property = (Property) Iterables.getFirst(gp.getProperties().get("textures"), (Object) null);
            if (property == null) {
                return;
            }
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_SEND_PLAYERSKIN, getDimensionID(), new Object[] { strName, property.getValue(), property.getSignature(), playerRequested.getUniqueID().toString() }), playerBase);
            break;
        case S_CONTROL_ENTITY:
            if (player.ridingEntity != null && player.ridingEntity instanceof IControllableEntity) {
                ((IControllableEntity) player.ridingEntity).pressKey((Integer) this.data.get(0));
            }
            break;
        case S_NOCLIP_PLAYER:
            boolean noClip = (Boolean) this.data.get(0);
            if (player instanceof GCEntityPlayerMP) {
                GalacticraftCore.proxy.player.setNoClip((EntityPlayerMP) player, noClip);
                if (noClip == false) {
                    player.fallDistance = 0.0F;
                    ((EntityPlayerMP) player).playerNetServerHandler.floatingTickCount = 0;
                }
            } else if (player instanceof EntityPlayerMP) {
                EntityPlayerMP emp = ((EntityPlayerMP) player);
                try {
                    Field f = emp.theItemInWorldManager.getClass().getDeclaredField(GCCoreUtil.isDeobfuscated() ? "gameType" : "field_73091_c");
                    f.setAccessible(true);
                    if (noClip == false) {
                        emp.fallDistance = 0.0F;
                        emp.playerNetServerHandler.floatingTickCount = 0;
                        WorldSettings.GameType gt = savedSettings.get(emp);
                        if (gt != null) {
                            savedSettings.remove(emp);
                            f.set(emp.theItemInWorldManager, gt);
                        }
                    } else {
                        savedSettings.put(emp, emp.theItemInWorldManager.getGameType());
                        f.set(emp.theItemInWorldManager, WorldSettings.GameType.SPECTATOR);
                    }
                } catch (Exception ee) {
                    ee.printStackTrace();
                }
            }
            break;
        case S_REQUEST_DATA:
            WorldServer worldServer = server.worldServerForDimension((Integer) this.data.get(0));
            if (worldServer != null) {
                TileEntity requestedTile = worldServer.getTileEntity((BlockPos) this.data.get(1));
                if (requestedTile instanceof INetworkProvider) {
                    if (((INetworkProvider) requestedTile).getNetwork() instanceof FluidNetwork) {
                        FluidNetwork network = (FluidNetwork) ((INetworkProvider) requestedTile).getNetwork();
                        network.addUpdate(playerBase);
                    }
                }
            }
            break;
        case S_UPDATE_CHECKLIST:
            ItemStack stack = player.getHeldItem();
            if (stack != null && stack.getItem() == GCItems.prelaunchChecklist) {
                NBTTagCompound tagCompound = stack.getTagCompound();
                if (tagCompound == null) {
                    tagCompound = new NBTTagCompound();
                }
                NBTTagCompound tagCompoundRead = (NBTTagCompound) this.data.get(0);
                tagCompound.setTag("checklistData", tagCompoundRead);
                stack.setTagCompound(tagCompound);
            }
            break;
        case S_REQUEST_MACHINE_DATA:
            TileEntity tile3 = player.worldObj.getTileEntity((BlockPos) this.data.get(0));
            if (tile3 instanceof ITileClientUpdates) {
                ((ITileClientUpdates) tile3).sendUpdateToClient(playerBase);
            }
            break;
        default:
            break;
    }
}
Also used : IControllableEntity(micdoodle8.mods.galacticraft.core.entities.IControllableEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) EntityTieredRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket) SolarSystem(micdoodle8.mods.galacticraft.api.galaxies.SolarSystem) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) WorldServer(net.minecraft.world.WorldServer) Container(net.minecraft.inventory.Container) EntityBuggy(micdoodle8.mods.galacticraft.core.entities.EntityBuggy) IControllableEntity(micdoodle8.mods.galacticraft.core.entities.IControllableEntity) IDisableableMachine(micdoodle8.mods.galacticraft.api.tile.IDisableableMachine) ContainerSchematic(micdoodle8.mods.galacticraft.core.inventory.ContainerSchematic) S07PacketRespawn(net.minecraft.network.play.server.S07PacketRespawn) EntityAutoRocket(micdoodle8.mods.galacticraft.api.prefab.entity.EntityAutoRocket) GameProfile(com.mojang.authlib.GameProfile) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) SpaceRace(micdoodle8.mods.galacticraft.core.dimension.SpaceRace) ITileClientUpdates(micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates) TileEntity(net.minecraft.tileentity.TileEntity) Field(java.lang.reflect.Field) ItemParaChute(micdoodle8.mods.galacticraft.core.items.ItemParaChute) FlagData(micdoodle8.mods.galacticraft.core.wrappers.FlagData) ScheduledDimensionChange(micdoodle8.mods.galacticraft.core.wrappers.ScheduledDimensionChange) CelestialBody(micdoodle8.mods.galacticraft.api.galaxies.CelestialBody) Property(com.mojang.authlib.properties.Property) EntitySpaceshipBase(micdoodle8.mods.galacticraft.api.prefab.entity.EntitySpaceshipBase) SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) Vector3(micdoodle8.mods.galacticraft.api.vector.Vector3) INetworkProvider(micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) IBubbleProvider(micdoodle8.mods.galacticraft.core.entities.IBubbleProvider) IOException(java.io.IOException) MinecraftServer(net.minecraft.server.MinecraftServer) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) EntityLivingBase(net.minecraft.entity.EntityLivingBase)

Aggregations

Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 GameProfile (com.mojang.authlib.GameProfile)2 Property (com.mojang.authlib.properties.Property)2 IOException (java.io.IOException)2 CelestialBody (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody)2 ScalableDistance (micdoodle8.mods.galacticraft.api.galaxies.CelestialBody.ScalableDistance)2 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)2 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)2 SpaceRace (micdoodle8.mods.galacticraft.core.dimension.SpaceRace)2 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)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 Entity (net.minecraft.entity.Entity)2 TileEntity (net.minecraft.tileentity.TileEntity)2 Field (java.lang.reflect.Field)1 FloatBuffer (java.nio.FloatBuffer)1