Search in sources :

Example 1 with ISchematicPage

use of micdoodle8.mods.galacticraft.api.recipe.ISchematicPage in project Galacticraft by micdoodle8.

the class EventHandlerGC method schematicFlipEvent.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void schematicFlipEvent(FlipPage event) {
    ISchematicPage page = null;
    switch(event.direction) {
        case 1:
            page = EventHandlerGC.getNextSchematic(event.index);
            break;
        case -1:
            page = EventHandlerGC.getLastSchematic(event.index);
            break;
    }
    if (page != null) {
        GuiScreen cs = event.currentGui;
        int benchX = (int) FMLClientHandler.instance().getClient().thePlayer.posX;
        int benchY = (int) FMLClientHandler.instance().getClient().thePlayer.posY;
        int benchZ = (int) FMLClientHandler.instance().getClient().thePlayer.posZ;
        if (cs instanceof GuiPositionedContainer) {
            benchX = ((GuiPositionedContainer) cs).getX();
            benchY = ((GuiPositionedContainer) cs).getY();
            benchZ = ((GuiPositionedContainer) cs).getZ();
        }
        GalacticraftCore.packetPipeline.sendToServer(new PacketSimple(EnumSimplePacket.S_OPEN_SCHEMATIC_PAGE, GCCoreUtil.getDimensionID(FMLClientHandler.instance().getClient().theWorld), new Object[] { page.getPageID(), benchX, benchY, benchZ }));
        FMLClientHandler.instance().getClient().thePlayer.openGui(GalacticraftCore.instance, page.getGuiID(), FMLClientHandler.instance().getClient().thePlayer.worldObj, benchX, benchY, benchZ);
    }
}
Also used : GuiPositionedContainer(micdoodle8.mods.galacticraft.core.client.gui.container.GuiPositionedContainer) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) GuiScreen(net.minecraft.client.gui.GuiScreen) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 2 with ISchematicPage

use of micdoodle8.mods.galacticraft.api.recipe.ISchematicPage in project Galacticraft by micdoodle8.

the class EventHandlerGC method schematicUnlocked.

@SubscribeEvent
public void schematicUnlocked(Unlock event) {
    GCPlayerStats stats = GCPlayerStats.get(event.player);
    if (!stats.getUnlockedSchematics().contains(event.page)) {
        stats.getUnlockedSchematics().add(event.page);
        Collections.sort(stats.getUnlockedSchematics());
        if (event.player != null && event.player.playerNetServerHandler != null) {
            Integer[] iArray = new Integer[stats.getUnlockedSchematics().size()];
            for (int i = 0; i < iArray.length; i++) {
                ISchematicPage page = stats.getUnlockedSchematics().get(i);
                iArray[i] = page == null ? -2 : page.getPageID();
            }
            List<Object> objList = new ArrayList<Object>();
            objList.add(iArray);
            GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SCHEMATIC_LIST, GCCoreUtil.getDimensionID(event.player.worldObj), objList), event.player);
        }
    }
}
Also used : GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ISchematicPage

use of micdoodle8.mods.galacticraft.api.recipe.ISchematicPage in project Galacticraft by micdoodle8.

the class EventHandlerGC method getNextSchematic.

@SideOnly(Side.CLIENT)
private static ISchematicPage getNextSchematic(int currentIndex) {
    EntityPlayerSP player = PlayerUtil.getPlayerBaseClientFromPlayer(FMLClientHandler.instance().getClient().thePlayer, false);
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    final int size = stats.getUnlockedSchematics().size();
    final HashMap<Integer, Integer> idList = new HashMap<Integer, Integer>(size, 1F);
    for (int i = 0; i < size; i++) {
        idList.put(i, stats.getUnlockedSchematics().get(i).getPageID());
    }
    final SortedSet<Integer> keys = new TreeSet<Integer>(idList.keySet());
    final Iterator<Integer> iterator = keys.iterator();
    for (int count = 0; count < keys.size(); count++) {
        final int i = iterator.next();
        final ISchematicPage page = SchematicRegistry.getMatchingRecipeForID(idList.get(i));
        if (page.getPageID() == currentIndex) {
            if (count + 1 < stats.getUnlockedSchematics().size()) {
                return stats.getUnlockedSchematics().get(count + 1);
            } else {
                return null;
            }
        }
    }
    return null;
}
Also used : GCPlayerStatsClient(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with ISchematicPage

use of micdoodle8.mods.galacticraft.api.recipe.ISchematicPage in project Galacticraft by micdoodle8.

the class StatsCapability method loadNBTData.

@Override
public void loadNBTData(NBTTagCompound nbt) {
    try {
        this.airRemaining = nbt.getInteger("playerAirRemaining");
        this.damageCounter = nbt.getInteger("damageCounter");
        this.oxygenSetupValid = this.lastOxygenSetupValid = nbt.getBoolean("OxygenSetupValid");
        this.thermalLevel = nbt.getInteger("thermalLevel");
        // Backwards compatibility
        NBTTagList nbttaglist = nbt.getTagList("Inventory", 10);
        this.extendedInventory.readFromNBTOld(nbttaglist);
        if (nbt.hasKey("ExtendedInventoryGC")) {
            this.extendedInventory.readFromNBT(nbt.getTagList("ExtendedInventoryGC", 10));
        }
        // Added for GCInv command - if tried to load an offline player's
        // inventory, load it now
        // (if there was no offline load, then the dontload flag in doLoad()
        // will make sure nothing happens)
        EntityPlayerMP p = this.player.get();
        if (p != null) {
            ItemStack[] saveinv = CommandGCInv.getSaveData(PlayerUtil.getName(p).toLowerCase());
            if (saveinv != null) {
                CommandGCInv.doLoad(p);
            }
        }
        if (nbt.hasKey("SpaceshipTier")) {
            this.spaceshipTier = nbt.getInteger("SpaceshipTier");
        }
        // New keys in version 3.0.5.220
        if (nbt.hasKey("FuelLevel")) {
            this.fuelLevel = nbt.getInteger("FuelLevel");
        }
        if (nbt.hasKey("ReturnRocket")) {
            ItemStack returnRocket = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("ReturnRocket"));
            if (returnRocket != null) {
                this.rocketItem = returnRocket.getItem();
                this.rocketType = returnRocket.getItemDamage();
            }
        }
        this.usingParachute = nbt.getBoolean("usingParachute2");
        this.usingPlanetSelectionGui = nbt.getBoolean("usingPlanetSelectionGui");
        this.teleportCooldown = nbt.getInteger("teleportCooldown");
        this.coordsTeleportedFromX = nbt.getDouble("coordsTeleportedFromX");
        this.coordsTeleportedFromZ = nbt.getDouble("coordsTeleportedFromZ");
        this.startDimension = nbt.hasKey("startDimension") ? nbt.getString("startDimension") : "";
        if (nbt.hasKey("spaceStationDimensionID")) {
            // If loading from an old save file, the home space station is always the overworld, so use 0 as home planet
            this.spaceStationDimensionData = WorldUtil.stringToSpaceStationData("0$" + nbt.getInteger("spaceStationDimensionID"));
        } else {
            this.spaceStationDimensionData = WorldUtil.stringToSpaceStationData(nbt.getString("spaceStationDimensionInfo"));
        }
        if (nbt.getBoolean("usingPlanetSelectionGui")) {
            this.openPlanetSelectionGuiCooldown = 20;
        }
        if (nbt.hasKey("RocketItems") && nbt.hasKey("rocketStacksLength")) {
            final NBTTagList var23 = nbt.getTagList("RocketItems", 10);
            int length = nbt.getInteger("rocketStacksLength");
            this.rocketStacks = new ItemStack[length];
            for (int var3 = 0; var3 < var23.tagCount(); ++var3) {
                final NBTTagCompound var4 = var23.getCompoundTagAt(var3);
                final int var5 = var4.getByte("Slot") & 255;
                if (var5 < this.rocketStacks.length) {
                    this.rocketStacks[var5] = ItemStack.loadItemStackFromNBT(var4);
                }
            }
        }
        this.unlockedSchematics = new ArrayList<ISchematicPage>();
        if (p != null) {
            for (int i = 0; i < nbt.getTagList("Schematics", 10).tagCount(); ++i) {
                final NBTTagCompound nbttagcompound = nbt.getTagList("Schematics", 10).getCompoundTagAt(i);
                final int j = nbttagcompound.getInteger("UnlockedPage");
                SchematicRegistry.addUnlockedPage(p, SchematicRegistry.getMatchingRecipeForID(j));
            }
        }
        Collections.sort(this.unlockedSchematics);
        this.cryogenicChamberCooldown = nbt.getInteger("CryogenicChamberCooldown");
        if (nbt.hasKey("ReceivedSoundWarning")) {
            this.receivedSoundWarning = nbt.getBoolean("ReceivedSoundWarning");
        }
        if (nbt.hasKey("ReceivedBedWarning")) {
            this.receivedBedWarning = nbt.getBoolean("ReceivedBedWarning");
        }
        if (nbt.hasKey("LaunchpadStack")) {
            this.launchpadStack = ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("LaunchpadStack"));
            if (this.launchpadStack != null && this.launchpadStack.stackSize == 0) {
                this.launchpadStack = null;
            }
        } else {
            // for backwards compatibility with saves which don't have this tag - players can't lose launchpads
            this.launchpadStack = new ItemStack(GCBlocks.landingPad, 9, 0);
        }
        if (nbt.hasKey("BuildFlags")) {
            this.buildFlags = nbt.getInteger("BuildFlags");
        }
        if (nbt.hasKey("ShownSpaceRace")) {
            this.openedSpaceRaceManager = nbt.getBoolean("ShownSpaceRace");
        }
        if (nbt.hasKey("AstroMinerCount")) {
            this.astroMinerCount = nbt.getInteger("AstroMinerCount");
        }
        if (nbt.hasKey("AstroData")) {
            this.activeAstroMinerChunks.clear();
            NBTTagList astroList = nbt.getTagList("AstroData", 10);
            for (int i = 0; i < astroList.tagCount(); ++i) {
                final NBTTagCompound nbttagcompound = astroList.getCompoundTagAt(i);
                BlockVec3 data = BlockVec3.readFromNBT(nbttagcompound);
                this.activeAstroMinerChunks.add(data);
            }
            if (GalacticraftCore.isPlanetsLoaded) {
                AsteroidsTickHandlerServer.loadAstroChunkList(this.activeAstroMinerChunks);
            }
        }
        if (nbt.hasKey("GlassColor1")) {
            this.glassColor1 = nbt.getInteger("GlassColor1");
            this.glassColor2 = nbt.getInteger("GlassColor2");
            this.glassColor3 = nbt.getInteger("GlassColor3");
        }
        if (nbt.hasKey("PanLi")) {
            final NBTTagList panels = nbt.getTagList("PanLi", 10);
            for (int i = 0; i < panels.tagCount(); ++i) {
                if (i == BlockPanelLighting.PANELTYPES_LENGTH)
                    break;
                final NBTTagCompound stateNBT = panels.getCompoundTagAt(i);
                IBlockState bs = TileEntityPanelLight.readBlockState(stateNBT);
                this.panelLightingBases[i] = (bs.getBlock() == Blocks.air) ? null : bs;
            }
        }
        if (nbt.hasKey("PanCo")) {
            this.panelLightingColor = nbt.getInteger("PanCo");
        }
        GCLog.debug("Loading GC player data for " + PlayerUtil.getName(player.get()) + " : " + this.buildFlags);
        this.sentFlags = false;
    } catch (Exception e) {
        GCLog.severe("Found error in saved Galacticraft player data for " + PlayerUtil.getName(player.get()) + " - this should fix itself next relog.");
        e.printStackTrace();
    }
    GCLog.debug("Finished loading GC player data for " + PlayerUtil.getName(player.get()) + " : " + this.buildFlags);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) IBlockState(net.minecraft.block.state.IBlockState) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 5 with ISchematicPage

use of micdoodle8.mods.galacticraft.api.recipe.ISchematicPage in project Galacticraft by micdoodle8.

the class GCPlayerHandler method updateSchematics.

protected void updateSchematics(EntityPlayerMP player, GCPlayerStats stats) {
    SchematicRegistry.addUnlockedPage(player, SchematicRegistry.getMatchingRecipeForID(0));
    SchematicRegistry.addUnlockedPage(player, SchematicRegistry.getMatchingRecipeForID(Integer.MAX_VALUE));
    Collections.sort(stats.getUnlockedSchematics());
    if (player.playerNetServerHandler != null && (stats.getUnlockedSchematics().size() != stats.getLastUnlockedSchematics().size() || (player.ticksExisted - 1) % 100 == 0)) {
        Integer[] iArray = new Integer[stats.getUnlockedSchematics().size()];
        for (int i = 0; i < iArray.length; i++) {
            ISchematicPage page = stats.getUnlockedSchematics().get(i);
            iArray[i] = page == null ? -2 : page.getPageID();
        }
        List<Object> objList = new ArrayList<Object>();
        objList.add(iArray);
        GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_UPDATE_SCHEMATIC_LIST, GCCoreUtil.getDimensionID(player.worldObj), objList), player);
    }
}
Also used : PacketSimple(micdoodle8.mods.galacticraft.core.network.PacketSimple) TargetPoint(net.minecraftforge.fml.common.network.NetworkRegistry.TargetPoint) Footprint(micdoodle8.mods.galacticraft.core.wrappers.Footprint) ISchematicPage(micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)

Aggregations

ISchematicPage (micdoodle8.mods.galacticraft.api.recipe.ISchematicPage)12 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)5 EntityPlayerSP (net.minecraft.client.entity.EntityPlayerSP)4 ItemStack (net.minecraft.item.ItemStack)4 TileEntity (net.minecraft.tileentity.TileEntity)4 EntityTieredRocket (micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket)3 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)3 GCPlayerStatsClient (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStatsClient)3 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)3 Footprint (micdoodle8.mods.galacticraft.core.wrappers.Footprint)3 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)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 SolarSystem (micdoodle8.mods.galacticraft.api.galaxies.SolarSystem)2 ITileClientUpdates (micdoodle8.mods.galacticraft.api.tile.ITileClientUpdates)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2