Search in sources :

Example 1 with GuiRequestTable

use of logisticspipes.gui.orderer.GuiRequestTable in project LogisticsPipes by RS485.

the class LogisticsCraftingOverlayHandler method overlayRecipe.

@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
    TileEntity tile;
    LogisticsBaseGuiScreen gui;
    if (firstGui instanceof GuiLogisticsCraftingTable) {
        tile = ((GuiLogisticsCraftingTable) firstGui)._crafter;
        gui = (GuiLogisticsCraftingTable) firstGui;
    } else if (firstGui instanceof GuiRequestTable) {
        tile = ((GuiRequestTable) firstGui)._table.container;
        gui = (GuiRequestTable) firstGui;
    } else {
        return;
    }
    ItemStack[] stack = new ItemStack[9];
    ItemStack[][] stacks = new ItemStack[9][];
    boolean hasCanidates = false;
    NEISetCraftingRecipe packet = PacketHandler.getPacket(NEISetCraftingRecipe.class);
    for (PositionedStack ps : recipe.getIngredientStacks(recipeIndex)) {
        int x = (ps.relx - 25) / 18;
        int y = (ps.rely - 6) / 18;
        int slot = x + y * 3;
        if (x < 0 || x > 2 || y < 0 || y > 2 || slot < 0 || slot > 8) {
            FMLClientHandler.instance().getClient().thePlayer.sendChatMessage("Internal Error. This button is broken.");
            return;
        }
        if (slot < 9) {
            stack[slot] = ps.items[0];
            List<ItemStack> list = new ArrayList<>(Arrays.asList(ps.items));
            Iterator<ItemStack> iter = list.iterator();
            while (iter.hasNext()) {
                ItemStack wildCardCheckStack = iter.next();
                if (wildCardCheckStack.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
                    iter.remove();
                    wildCardCheckStack.getItem().getSubItems(wildCardCheckStack.getItem(), wildCardCheckStack.getItem().getCreativeTab(), list);
                    iter = list.iterator();
                }
            }
            stacks[slot] = list.toArray(new ItemStack[0]);
            if (stacks[slot].length > 1) {
                hasCanidates = true;
            } else if (stacks[slot].length == 1) {
                stack[slot] = stacks[slot][0];
            }
        }
    }
    if (hasCanidates) {
        gui.setSubGui(new GuiRecipeImport(tile, stacks));
    } else {
        MainProxy.sendPacketToServer(packet.setContent(stack).setPosX(tile.xCoord).setPosY(tile.yCoord).setPosZ(tile.zCoord));
    }
}
Also used : GuiRecipeImport(logisticspipes.gui.popup.GuiRecipeImport) GuiLogisticsCraftingTable(logisticspipes.gui.GuiLogisticsCraftingTable) LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) PositionedStack(codechicken.nei.PositionedStack) ArrayList(java.util.ArrayList) TileEntity(net.minecraft.tileentity.TileEntity) GuiRequestTable(logisticspipes.gui.orderer.GuiRequestTable) NEISetCraftingRecipe(logisticspipes.network.packets.NEISetCraftingRecipe) ItemStack(net.minecraft.item.ItemStack)

Example 2 with GuiRequestTable

use of logisticspipes.gui.orderer.GuiRequestTable in project LogisticsPipes by RS485.

the class GuiHandler method getClientGuiElement.

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, final World world, int x, int y, int z) {
    TileEntity tile = world.getTileEntity(x, y, z);
    LogisticsTileGenericPipe pipe = null;
    if (tile instanceof LogisticsTileGenericPipe) {
        pipe = (LogisticsTileGenericPipe) tile;
    }
    if (ID == -1) {
        return getClientGuiElement(-100 * 20 + x, player, world, 0, -1, z);
    }
    if (ID < 110 && ID > 0) {
        switch(ID) {
            case GuiIDs.GUI_FluidSupplier_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsFluidSupplier)) {
                    return null;
                }
                return new GuiFluidSupplierPipe(player.inventory, ((PipeItemsFluidSupplier) pipe.pipe).getDummyInventory(), (PipeItemsFluidSupplier) pipe.pipe);
            case GuiIDs.GUI_FluidSupplier_MK2_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeFluidSupplierMk2)) {
                    return null;
                }
                return new GuiFluidSupplierMk2Pipe(player.inventory, ((PipeFluidSupplierMk2) pipe.pipe).getDummyInventory(), (PipeFluidSupplierMk2) pipe.pipe);
            case GuiIDs.GUI_ProviderPipe_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsProviderLogistics)) {
                    return null;
                }
                return new GuiProviderPipe(player.inventory, ((PipeItemsProviderLogistics) pipe.pipe).getprovidingInventory(), (PipeItemsProviderLogistics) pipe.pipe);
            case GuiIDs.GUI_SatellitePipe_ID:
                if (pipe != null && pipe.pipe != null && pipe.pipe instanceof PipeItemsSatelliteLogistics) {
                    return new GuiSatellitePipe((PipeItemsSatelliteLogistics) pipe.pipe, player);
                }
                if (pipe != null && pipe.pipe != null && pipe.pipe instanceof PipeFluidSatellite) {
                    return new GuiSatellitePipe((PipeFluidSatellite) pipe.pipe, player);
                }
                return null;
            case GuiIDs.GUI_Normal_Orderer_ID:
                return new NormalGuiOrderer(x, y, z, MainProxy.getDimensionForWorld(world), player);
            case GuiIDs.GUI_Normal_Mk2_Orderer_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsRequestLogisticsMk2)) {
                    return null;
                }
                return new NormalMk2GuiOrderer(((PipeItemsRequestLogisticsMk2) pipe.pipe), player);
            case GuiIDs.GUI_Fluid_Orderer_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeFluidRequestLogistics)) {
                    return null;
                }
                return new FluidGuiOrderer(((PipeFluidRequestLogistics) pipe.pipe), player);
            case GuiIDs.GUI_Inv_Sys_Connector_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeItemsInvSysConnector)) {
                    return null;
                }
                return new GuiInvSysConnector(player, (PipeItemsInvSysConnector) pipe.pipe);
            case GuiIDs.GUI_Freq_Card_ID:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeItemsSystemEntranceLogistics) || (pipe.pipe instanceof PipeItemsSystemDestinationLogistics))) {
                    return null;
                }
                IInventory inv = null;
                if (pipe.pipe instanceof PipeItemsSystemEntranceLogistics) {
                    inv = ((PipeItemsSystemEntranceLogistics) pipe.pipe).inv;
                } else if (pipe.pipe instanceof PipeItemsSystemDestinationLogistics) {
                    inv = ((PipeItemsSystemDestinationLogistics) pipe.pipe).inv;
                }
                return new GuiFreqCardContent(player, inv);
            case GuiIDs.GUI_HUD_Settings:
                return new GuiHUDSettings(player, x);
            case GuiIDs.GUI_Fluid_Basic_ID:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeFluidBasic))) {
                    return null;
                }
                return new GuiFluidBasic(player, ((PipeFluidBasic) pipe.pipe).filterInv);
            case GuiIDs.GUI_FIREWALL:
                if (pipe == null || pipe.pipe == null || !((pipe.pipe instanceof PipeItemsFirewall))) {
                    return null;
                }
                return new GuiFirewall((PipeItemsFirewall) pipe.pipe, player);
            case GuiIDs.GUI_Request_Table_ID:
                if (pipe == null || pipe.pipe == null || !(pipe.pipe instanceof PipeBlockRequestTable)) {
                    return null;
                }
                return new GuiRequestTable(player, ((PipeBlockRequestTable) pipe.pipe));
            default:
                break;
        }
    }
    return null;
}
Also used : GuiFreqCardContent(logisticspipes.gui.GuiFreqCardContent) GuiFluidSupplierPipe(logisticspipes.gui.GuiFluidSupplierPipe) PipeFluidBasic(logisticspipes.pipes.PipeFluidBasic) TileEntity(net.minecraft.tileentity.TileEntity) PipeFluidSupplierMk2(logisticspipes.pipes.PipeFluidSupplierMk2) PipeItemsInvSysConnector(logisticspipes.pipes.PipeItemsInvSysConnector) PipeItemsFluidSupplier(logisticspipes.pipes.PipeItemsFluidSupplier) PipeFluidRequestLogistics(logisticspipes.pipes.PipeFluidRequestLogistics) PipeItemsSystemDestinationLogistics(logisticspipes.pipes.PipeItemsSystemDestinationLogistics) NormalGuiOrderer(logisticspipes.gui.orderer.NormalGuiOrderer) NormalMk2GuiOrderer(logisticspipes.gui.orderer.NormalMk2GuiOrderer) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) PipeItemsRequestLogisticsMk2(logisticspipes.pipes.PipeItemsRequestLogisticsMk2) GuiHUDSettings(logisticspipes.gui.hud.GuiHUDSettings) FluidGuiOrderer(logisticspipes.gui.orderer.FluidGuiOrderer) IInventory(net.minecraft.inventory.IInventory) GuiSatellitePipe(logisticspipes.gui.GuiSatellitePipe) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) PipeItemsSatelliteLogistics(logisticspipes.pipes.PipeItemsSatelliteLogistics) GuiFirewall(logisticspipes.gui.GuiFirewall) PipeItemsSystemEntranceLogistics(logisticspipes.pipes.PipeItemsSystemEntranceLogistics) GuiFluidBasic(logisticspipes.gui.GuiFluidBasic) PipeFluidSatellite(logisticspipes.pipes.PipeFluidSatellite) PipeItemsProviderLogistics(logisticspipes.pipes.PipeItemsProviderLogistics) GuiRequestTable(logisticspipes.gui.orderer.GuiRequestTable) GuiInvSysConnector(logisticspipes.gui.GuiInvSysConnector) GuiFluidSupplierMk2Pipe(logisticspipes.gui.GuiFluidSupplierMk2Pipe) GuiProviderPipe(logisticspipes.gui.GuiProviderPipe)

Example 3 with GuiRequestTable

use of logisticspipes.gui.orderer.GuiRequestTable in project LogisticsPipes by RS485.

the class MostLikelyRecipeComponentsResponse method processPacket.

@Override
@ClientSideOnlyMethodContent
public void processPacket(EntityPlayer player) {
    GuiScreen firstGui = Minecraft.getMinecraft().currentScreen;
    LogisticsBaseGuiScreen gui;
    if (firstGui instanceof GuiLogisticsCraftingTable) {
        gui = (GuiLogisticsCraftingTable) firstGui;
    } else if (firstGui instanceof GuiRequestTable) {
        gui = (GuiRequestTable) firstGui;
    } else {
        return;
    }
    GuiRecipeImport importGui = null;
    SubGuiScreen sub = gui.getSubGui();
    while (sub != null) {
        if (sub instanceof GuiRecipeImport) {
            importGui = (GuiRecipeImport) sub;
            break;
        }
        sub = sub.getSubGui();
    }
    if (importGui == null)
        return;
    importGui.handleProposePacket(response);
}
Also used : GuiRecipeImport(logisticspipes.gui.popup.GuiRecipeImport) GuiRequestTable(logisticspipes.gui.orderer.GuiRequestTable) GuiLogisticsCraftingTable(logisticspipes.gui.GuiLogisticsCraftingTable) LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) LogisticsBaseGuiScreen(logisticspipes.utils.gui.LogisticsBaseGuiScreen) SubGuiScreen(logisticspipes.utils.gui.SubGuiScreen) GuiScreen(net.minecraft.client.gui.GuiScreen) SubGuiScreen(logisticspipes.utils.gui.SubGuiScreen) ClientSideOnlyMethodContent(logisticspipes.asm.ClientSideOnlyMethodContent)

Aggregations

GuiRequestTable (logisticspipes.gui.orderer.GuiRequestTable)3 GuiLogisticsCraftingTable (logisticspipes.gui.GuiLogisticsCraftingTable)2 GuiRecipeImport (logisticspipes.gui.popup.GuiRecipeImport)2 LogisticsBaseGuiScreen (logisticspipes.utils.gui.LogisticsBaseGuiScreen)2 TileEntity (net.minecraft.tileentity.TileEntity)2 PositionedStack (codechicken.nei.PositionedStack)1 ArrayList (java.util.ArrayList)1 ClientSideOnlyMethodContent (logisticspipes.asm.ClientSideOnlyMethodContent)1 GuiFirewall (logisticspipes.gui.GuiFirewall)1 GuiFluidBasic (logisticspipes.gui.GuiFluidBasic)1 GuiFluidSupplierMk2Pipe (logisticspipes.gui.GuiFluidSupplierMk2Pipe)1 GuiFluidSupplierPipe (logisticspipes.gui.GuiFluidSupplierPipe)1 GuiFreqCardContent (logisticspipes.gui.GuiFreqCardContent)1 GuiInvSysConnector (logisticspipes.gui.GuiInvSysConnector)1 GuiProviderPipe (logisticspipes.gui.GuiProviderPipe)1 GuiSatellitePipe (logisticspipes.gui.GuiSatellitePipe)1 GuiHUDSettings (logisticspipes.gui.hud.GuiHUDSettings)1 FluidGuiOrderer (logisticspipes.gui.orderer.FluidGuiOrderer)1 NormalGuiOrderer (logisticspipes.gui.orderer.NormalGuiOrderer)1 NormalMk2GuiOrderer (logisticspipes.gui.orderer.NormalMk2GuiOrderer)1