Search in sources :

Example 1 with SlotType

use of mekanism.client.gui.element.slot.SlotType in project Mekanism by mekanism.

the class GuiMekanism method addSlots.

protected void addSlots() {
    int size = menu.slots.size();
    for (int i = 0; i < size; i++) {
        Slot slot = menu.slots.get(i);
        if (slot instanceof InventoryContainerSlot) {
            InventoryContainerSlot containerSlot = (InventoryContainerSlot) slot;
            ContainerSlotType slotType = containerSlot.getSlotType();
            DataType dataType = findDataType(containerSlot);
            // Shift the slots by one as the elements include the border of the slot
            SlotType type;
            if (dataType != null) {
                type = SlotType.get(dataType);
            } else if (slotType == ContainerSlotType.INPUT || slotType == ContainerSlotType.OUTPUT || slotType == ContainerSlotType.EXTRA) {
                type = SlotType.NORMAL;
            } else if (slotType == ContainerSlotType.POWER) {
                type = SlotType.POWER;
            } else if (slotType == ContainerSlotType.NORMAL || slotType == ContainerSlotType.VALIDITY) {
                type = SlotType.NORMAL;
            } else {
                // slotType == ContainerSlotType.IGNORED: don't do anything
                continue;
            }
            GuiSlot guiSlot = new GuiSlot(type, this, slot.x - 1, slot.y - 1);
            SlotOverlay slotOverlay = containerSlot.getSlotOverlay();
            if (slotOverlay != null) {
                guiSlot.with(slotOverlay);
            }
            if (slotType == ContainerSlotType.VALIDITY) {
                int index = i;
                guiSlot.validity(() -> checkValidity(index));
            }
            addButton(guiSlot);
        } else {
            addButton(new GuiSlot(SlotType.NORMAL, this, slot.x - 1, slot.y - 1));
        }
    }
}
Also used : SlotOverlay(mekanism.common.inventory.container.slot.SlotOverlay) ContainerSlotType(mekanism.common.inventory.container.slot.ContainerSlotType) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) IVirtualSlot(mekanism.common.inventory.container.slot.IVirtualSlot) Slot(net.minecraft.inventory.container.Slot) InventoryContainerSlot(mekanism.common.inventory.container.slot.InventoryContainerSlot) GuiVirtualSlot(mekanism.client.gui.element.slot.GuiVirtualSlot) DataType(mekanism.common.tile.component.config.DataType) GuiSlot(mekanism.client.gui.element.slot.GuiSlot) InventoryContainerSlot(mekanism.common.inventory.container.slot.InventoryContainerSlot) SlotType(mekanism.client.gui.element.slot.SlotType) ContainerSlotType(mekanism.common.inventory.container.slot.ContainerSlotType)

Aggregations

GuiSlot (mekanism.client.gui.element.slot.GuiSlot)1 GuiVirtualSlot (mekanism.client.gui.element.slot.GuiVirtualSlot)1 SlotType (mekanism.client.gui.element.slot.SlotType)1 ContainerSlotType (mekanism.common.inventory.container.slot.ContainerSlotType)1 IVirtualSlot (mekanism.common.inventory.container.slot.IVirtualSlot)1 InventoryContainerSlot (mekanism.common.inventory.container.slot.InventoryContainerSlot)1 SlotOverlay (mekanism.common.inventory.container.slot.SlotOverlay)1 DataType (mekanism.common.tile.component.config.DataType)1 Slot (net.minecraft.inventory.container.Slot)1