Search in sources :

Example 1 with GuiStructure

use of com.wuest.prefab.structures.gui.GuiStructure in project MC-Prefab by Brian-Wuest.

the class StructureItem method RegisterGui.

protected void RegisterGui(Class<?> classToRegister) {
    try {
        GuiStructure userInterface = (GuiStructure) classToRegister.newInstance();
        ClientProxy.ModGuis.put(this, userInterface);
    } catch (InstantiationException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
Also used : GuiStructure(com.wuest.prefab.structures.gui.GuiStructure)

Example 2 with GuiStructure

use of com.wuest.prefab.structures.gui.GuiStructure in project MC-Prefab by Brian-Wuest.

the class ClientEventHandler method checkIfStackIsCorrectGui.

public static boolean checkIfStackIsCorrectGui(StructureTagMessage.EnumStructureConfiguration currentConfiguration, ItemStack stack) {
    GuiStructure mainHandGui = ClientProxy.ModGuis.get(stack.getItem());
    mainHandGui.init();
    if (currentConfiguration == mainHandGui.configurationEnum) {
        if (currentConfiguration == StructureTagMessage.EnumStructureConfiguration.Basic) {
            ItemBasicStructure item = (ItemBasicStructure) stack.getItem();
            BasicStructureConfiguration.EnumBasicStructureName basicStructureName = ((BasicStructureConfiguration) StructureRenderHandler.currentConfiguration).basicStructureName;
            return item.structureType == basicStructureName;
        } else {
            return true;
        }
    }
    return false;
}
Also used : GuiStructure(com.wuest.prefab.structures.gui.GuiStructure) BasicStructureConfiguration(com.wuest.prefab.structures.config.BasicStructureConfiguration) ItemBasicStructure(com.wuest.prefab.structures.items.ItemBasicStructure)

Example 3 with GuiStructure

use of com.wuest.prefab.structures.gui.GuiStructure in project MC-Prefab by Brian-Wuest.

the class ClientProxy method openGuiForItem.

@Override
public void openGuiForItem(UseOnContext itemUseContext) {
    for (Map.Entry<StructureItem, GuiStructure> entry : ClientProxy.ModGuis.entrySet()) {
        if (entry.getKey() == itemUseContext.getItemInHand().getItem()) {
            GuiStructure screen = entry.getValue();
            screen.pos = itemUseContext.getClickedPos();
            Minecraft.getInstance().setScreen(screen);
        }
    }
}
Also used : GuiStructure(com.wuest.prefab.structures.gui.GuiStructure) StructureItem(com.wuest.prefab.structures.items.StructureItem) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

GuiStructure (com.wuest.prefab.structures.gui.GuiStructure)3 BasicStructureConfiguration (com.wuest.prefab.structures.config.BasicStructureConfiguration)1 ItemBasicStructure (com.wuest.prefab.structures.items.ItemBasicStructure)1 StructureItem (com.wuest.prefab.structures.items.StructureItem)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1