Search in sources :

Example 1 with CraftingGridProvider

use of mcjty.rftools.craftinggrid.CraftingGridProvider in project RFTools by McJty.

the class GuiModularStorage method initGui.

@Override
public void initGui() {
    super.initGui();
    itemList = new WidgetList(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(5, 3, 235, ySize - 89)).setNoSelectionMode(true).setUserObject(new Integer(-1)).setLeftMargin(0).setRowheight(-1);
    Slider slider = new Slider(mc, this).setLayoutHint(new PositionalLayout.PositionalHint(241, 3, 11, ySize - 89)).setDesiredWidth(11).setVertical().setScrollable(itemList);
    Panel modePanel = setupModePanel();
    cycleButton = new Button(mc, this).setText("C").setTooltips("Cycle to the next storage module").setLayoutHint(new PositionalLayout.PositionalHint(5, ySize - 23, 16, 16)).addButtonEvent(parent -> cycleStorage());
    Panel toplevel = new Panel(mc, this).setLayout(new PositionalLayout()).addChild(itemList).addChild(slider).addChild(modePanel).addChild(cycleButton);
    toplevel.setBackgrounds(iconLocationTop, iconLocation);
    toplevel.setBackgroundLayout(false, ySize - STORAGE_HEIGHT0 + 2);
    if (tileEntity == null) {
        // We must hide three slots.
        ImageLabel hideLabel = new ImageLabel(mc, this);
        hideLabel.setLayoutHint(new PositionalLayout.PositionalHint(4, ySize - 26 - 3 * 18, 20, 55));
        hideLabel.setImage(guiElements, 32, 32);
        toplevel.addChild(hideLabel);
    }
    toplevel.setBounds(new Rectangle(guiLeft, guiTop, xSize, ySize));
    window = new Window(this, toplevel);
    if (ModularStorageConfiguration.autofocusSearch) {
        window.setTextFocus(filter);
    }
    CraftingGridProvider provider;
    BlockPos pos = null;
    if (tileEntity != null) {
        provider = tileEntity;
        pos = tileEntity.getPos();
    } else if (inventorySlots instanceof ModularStorageItemContainer) {
        ModularStorageItemContainer storageItemContainer = (ModularStorageItemContainer) inventorySlots;
        provider = storageItemContainer.getCraftingGridProvider();
    } else if (inventorySlots instanceof RemoteStorageItemContainer) {
        RemoteStorageItemContainer storageItemContainer = (RemoteStorageItemContainer) inventorySlots;
        provider = storageItemContainer.getCraftingGridProvider();
    } else {
        throw new RuntimeException("Should not happen!");
    }
    craftingGrid.initGui(modBase, network, mc, this, pos, provider, guiLeft, guiTop, xSize, ySize);
    sendServerCommand(RFTools.MODID, CommandHandler.CMD_REQUEST_GRID_SYNC, Arguments.builder().value(pos).build());
}
Also used : GenericGuiContainer(mcjty.lib.container.GenericGuiContainer) RFToolsMessages(mcjty.rftools.network.RFToolsMessages) Rectangle(java.awt.Rectangle) mcjty.lib.gui.widgets(mcjty.lib.gui.widgets) HorizontalAlignment(mcjty.lib.gui.layout.HorizontalAlignment) Item(net.minecraft.item.Item) CraftingGridProvider(mcjty.rftools.craftinggrid.CraftingGridProvider) EnumHand(net.minecraft.util.EnumHand) Keyboard(org.lwjgl.input.Keyboard) CONTAINER_GRID(mcjty.rftools.blocks.storage.ModularStorageContainer.CONTAINER_GRID) Arguments(mcjty.lib.network.Arguments) ArrayList(java.util.ArrayList) StyleConfig(mcjty.lib.base.StyleConfig) Window(mcjty.lib.gui.Window) ItemStack(net.minecraft.item.ItemStack) HorizontalLayout(mcjty.lib.gui.layout.HorizontalLayout) Block(net.minecraft.block.Block) MutablePair(org.apache.commons.lang3.tuple.MutablePair) Pair(org.apache.commons.lang3.tuple.Pair) DefaultTypeModule(mcjty.rftools.blocks.storage.modules.DefaultTypeModule) Minecraft(net.minecraft.client.Minecraft) Logging(mcjty.lib.varia.Logging) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) RFTools(mcjty.rftools.RFTools) GenericContainer(mcjty.lib.container.GenericContainer) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ScaledResolution(net.minecraft.client.gui.ScaledResolution) GhostOutputSlot(mcjty.lib.container.GhostOutputSlot) StorageModuleItem(mcjty.rftools.items.storage.StorageModuleItem) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException) Mouse(org.lwjgl.input.Mouse) Argument(mcjty.lib.network.Argument) List(java.util.List) Type(java.lang.reflect.Type) IInventory(net.minecraft.inventory.IInventory) Slot(net.minecraft.inventory.Slot) ResourceLocation(net.minecraft.util.ResourceLocation) ItemBlock(net.minecraft.item.ItemBlock) CommandHandler(mcjty.rftools.CommandHandler) GuiCraftingGrid(mcjty.rftools.craftinggrid.GuiCraftingGrid) Collections(java.util.Collections) TypeModule(mcjty.rftools.blocks.storage.modules.TypeModule) ItemSorter(mcjty.rftools.blocks.storage.sorters.ItemSorter) Container(net.minecraft.inventory.Container) Window(mcjty.lib.gui.Window) PositionalLayout(mcjty.lib.gui.layout.PositionalLayout) Rectangle(java.awt.Rectangle) CraftingGridProvider(mcjty.rftools.craftinggrid.CraftingGridProvider) BlockPos(net.minecraft.util.math.BlockPos)

Example 2 with CraftingGridProvider

use of mcjty.rftools.craftinggrid.CraftingGridProvider in project RFTools by McJty.

the class StorageTerminalBlock method createClientGui.

@SideOnly(Side.CLIENT)
@Override
public GuiContainer createClientGui(EntityPlayer entityPlayer, TileEntity tileEntity) {
    if (!entityPlayer.isSneaking()) {
        ItemStack module = getModule(tileEntity);
        if (!module.isEmpty()) {
            int monitordim = RFToolsTools.getDimensionFromModule(module);
            BlockPos pos = RFToolsTools.getPositionFromModule(module);
            StorageScannerTileEntity te = new StorageScannerTileEntity(entityPlayer, monitordim) {

                @Override
                public BlockPos getCraftingGridContainerPos() {
                    // for this terminal itself.
                    return tileEntity.getPos();
                }

                @Override
                public CraftingGridProvider getCraftingGridProvider() {
                    return (CraftingGridProvider) tileEntity;
                }

                @Override
                public boolean isOpenWideView() {
                    TileEntity realTe = RFTools.proxy.getClientWorld().getTileEntity(pos);
                    if (realTe instanceof StorageScannerTileEntity) {
                        return ((StorageScannerTileEntity) realTe).isOpenWideView();
                    }
                    return true;
                }

                @Override
                public BlockPos getStorageScannerPos() {
                    return pos;
                }
            };
            // The position of the actual storage scanner is set on the dummy te
            te.setPos(pos);
            return new GuiStorageScanner(te, new StorageScannerContainer(entityPlayer, te, (CraftingGridProvider) tileEntity));
        }
    }
    return super.createClientGui(entityPlayer, tileEntity);
}
Also used : StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) GuiStorageScanner(mcjty.rftools.blocks.storagemonitor.GuiStorageScanner) StorageScannerContainer(mcjty.rftools.blocks.storagemonitor.StorageScannerContainer) CraftingGridProvider(mcjty.rftools.craftinggrid.CraftingGridProvider) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

CraftingGridProvider (mcjty.rftools.craftinggrid.CraftingGridProvider)2 ItemStack (net.minecraft.item.ItemStack)2 Rectangle (java.awt.Rectangle)1 IOException (java.io.IOException)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 List (java.util.List)1 StyleConfig (mcjty.lib.base.StyleConfig)1 GenericContainer (mcjty.lib.container.GenericContainer)1 GenericGuiContainer (mcjty.lib.container.GenericGuiContainer)1 GhostOutputSlot (mcjty.lib.container.GhostOutputSlot)1 Window (mcjty.lib.gui.Window)1 HorizontalAlignment (mcjty.lib.gui.layout.HorizontalAlignment)1 HorizontalLayout (mcjty.lib.gui.layout.HorizontalLayout)1 PositionalLayout (mcjty.lib.gui.layout.PositionalLayout)1 mcjty.lib.gui.widgets (mcjty.lib.gui.widgets)1 Argument (mcjty.lib.network.Argument)1 Arguments (mcjty.lib.network.Arguments)1 Logging (mcjty.lib.varia.Logging)1