Search in sources :

Example 1 with GenericGuiContainer

use of mcjty.lib.container.GenericGuiContainer in project RFTools by McJty.

the class GuiCraftingGrid method initGui.

public void initGui(final ModBase modBase, final SimpleNetworkWrapper network, final Minecraft mc, GenericGuiContainer<?> gui, BlockPos pos, CraftingGridProvider provider, int guiLeft, int guiTop, int xSize, int ySize) {
    this.mc = mc;
    this.gui = gui;
    SimpleNetworkWrapper network1 = network;
    this.provider = provider;
    this.pos = pos;
    recipeList = new WidgetList(mc, gui).setLayoutHint(new PositionalLayout.PositionalHint(5, 5, 56, 102));
    recipeList.addSelectionEvent(new DefaultSelectionEvent() {

        @Override
        public void select(Widget parent, int index) {
        }

        @Override
        public void doubleClick(Widget parent, int index) {
            selectRecipe();
        }
    });
    craft1Button = new Button(mc, gui).setText("1").setLayoutHint(new PositionalLayout.PositionalHint(29, 183, 14, 10)).setTooltips("Craft one").addButtonEvent(parent -> craft(1));
    craft4Button = new Button(mc, gui).setText("4").setLayoutHint(new PositionalLayout.PositionalHint(45, 183, 14, 10)).setTooltips("Craft four").addButtonEvent(parent -> craft(4));
    craft8Button = new Button(mc, gui).setText("8").setLayoutHint(new PositionalLayout.PositionalHint(29, 195, 14, 10)).setTooltips("Craft eight").addButtonEvent(parent -> craft(8));
    craftSButton = new Button(mc, gui).setText("*").setLayoutHint(new PositionalLayout.PositionalHint(45, 195, 14, 10)).setTooltips("Craft a stack").addButtonEvent(parent -> craft(-1));
    storeButton = new Button(mc, gui).setText("Store").setLayoutHint(new PositionalLayout.PositionalHint(5, 109, 56, 14)).setTooltips("Store the current recipe").addButtonEvent(parent -> store());
    Panel sidePanel = new Panel(mc, gui).setLayout(new PositionalLayout()).addChild(craft1Button).addChild(craft4Button).addChild(craft8Button).addChild(craftSButton).addChild(storeButton).addChild(recipeList);
    int sideLeft = guiLeft - CraftingGridInventory.GRID_WIDTH - 2;
    int sideTop = guiTop;
    sidePanel.setBounds(new Rectangle(sideLeft, sideTop, CraftingGridInventory.GRID_WIDTH, CraftingGridInventory.GRID_HEIGHT));
    sidePanel.setBackground(iconLocation);
    craftWindow = new Window(gui, sidePanel);
}
Also used : SimpleNetworkWrapper(net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper) GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) Rectangle(java.awt.Rectangle) BlockTools(mcjty.lib.varia.BlockTools) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Arguments(mcjty.lib.network.Arguments) StyleConfig(mcjty.lib.base.StyleConfig) Window(mcjty.lib.gui.Window) ItemStack(net.minecraft.item.ItemStack) Gui(net.minecraft.client.gui.Gui) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent) SimpleNetworkWrapper(net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper) Minecraft(net.minecraft.client.Minecraft) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) ModBase(mcjty.lib.base.ModBase) RFTools(mcjty.rftools.RFTools) IRecipe(net.minecraft.item.crafting.IRecipe) GlStateManager(net.minecraft.client.renderer.GlStateManager) BlockPos(net.minecraft.util.math.BlockPos) Mouse(org.lwjgl.input.Mouse) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Slot(net.minecraft.inventory.Slot) ResourceLocation(net.minecraft.util.ResourceLocation) CommandHandler(mcjty.rftools.CommandHandler) InventoryCrafting(net.minecraft.inventory.InventoryCrafting) Window(mcjty.lib.gui.Window) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Rectangle(java.awt.Rectangle) DefaultSelectionEvent(mcjty.lib.gui.events.DefaultSelectionEvent)

Example 2 with GenericGuiContainer

use of mcjty.lib.container.GenericGuiContainer in project RFToolsDimensions by McJty.

the class GenericRFToolsBlock method createClientGui.

@Override
@SideOnly(Side.CLIENT)
public GuiContainer createClientGui(EntityPlayer entityPlayer, TileEntity tileEntity) {
    T inventory = (T) tileEntity;
    C container;
    GenericGuiContainer gui;
    try {
        Constructor<? extends C> constructor = containerClass.getConstructor(EntityPlayer.class, IInventory.class);
        container = constructor.newInstance(entityPlayer, inventory instanceof IInventory ? inventory : null);
        Constructor<? extends GenericGuiContainer> guiConstructor = getGuiClass().getConstructor(tileEntityClass, containerClass);
        gui = guiConstructor.newInstance(inventory, container);
        return gui;
    } catch (Exception e) {
        Logging.logError("Severe exception during creation of gui!");
        throw new RuntimeException(e);
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)2 Rectangle (java.awt.Rectangle)1 ModBase (mcjty.lib.base.ModBase)1 StyleConfig (mcjty.lib.base.StyleConfig)1 Window (mcjty.lib.gui.Window)1 DefaultSelectionEvent (mcjty.lib.gui.events.DefaultSelectionEvent)1 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)1 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)1 Arguments (mcjty.lib.network.Arguments)1 BlockTools (mcjty.lib.varia.BlockTools)1 CommandHandler (mcjty.rftools.CommandHandler)1 RFTools (mcjty.rftools.RFTools)1 RFToolsMessages (mcjty.rftools.network.RFToolsMessages)1 Minecraft (net.minecraft.client.Minecraft)1 Gui (net.minecraft.client.gui.Gui)1 GlStateManager (net.minecraft.client.renderer.GlStateManager)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 IInventory (net.minecraft.inventory.IInventory)1 InventoryCrafting (net.minecraft.inventory.InventoryCrafting)1