Example usage for net.minecraftforge.client.event GuiScreenEvent.InitGuiEvent.Post getGui

List of usage examples for net.minecraftforge.client.event GuiScreenEvent.InitGuiEvent.Post getGui

Introduction

In this page you can find the example usage for net.minecraftforge.client.event GuiScreenEvent.InitGuiEvent.Post getGui.

Prototype

public Screen getGui() 

Source Link

Document

The GuiScreen object generating this event.

Usage

From source file:com.lothrazar.cyclicmagic.playerupgrade.EventExtendedInventory.java

License:Open Source License

@SideOnly(value = Side.CLIENT)
@SubscribeEvent/*from w  w  w.j  a v a  2s  . co  m*/
public void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
    GuiScreen gui = event.getGui();
    boolean showInvToggle = false;
    boolean showCraftToggle = false;
    if (gui instanceof GuiInventory || gui instanceof GuiPlayerExtended || gui instanceof GuiPlayerExtWorkbench
            || gui instanceof GuiScreenHorseInventory || gui.getClass().getName()
                    .equals("com.lothrazar.cyclicmagic.compat.fastbench.GuiFastPlayerBench")) {
        // gui left and top are private, so are the sizes
        int xSize = 176;
        int ySize = 166;
        int guiLeft = (gui.width - xSize) / 2;
        int guiTop = (gui.height - ySize) / 2;
        int x = 44 + guiLeft;
        int y = guiTop;
        EntityPlayer player = ModCyclic.proxy.getClientPlayer();
        final IPlayerExtendedProperties data = CapabilityRegistry.getPlayerProperties(player);
        showInvToggle = data.hasInventoryExtended();// && !(gui instanceof GuiPlayerExtWorkbench);
        showCraftToggle = data.hasInventoryCrafting();// && !(gui instanceof GuiPlayerExtended);
        if (event.getButtonList() == null) {
            event.setButtonList(new ArrayList<GuiButton>());
        }
        if (showInvToggle) {
            event.getButtonList().add(new ButtonTabToggleInventory(gui, x, y));
            //   event.getButtonList().add(new ButtonTabToolbeltInventory(gui, x + 17, y));
        }
        if (showCraftToggle) {
            event.getButtonList().add(new ButtonTabToggleCrafting(gui, x - 17, y));//the 17 is width + 2
        }
    }
}

From source file:de.canitzp.rarmor.event.ClientEvents.java

@SubscribeEvent
public static void onInitGui(GuiScreenEvent.InitGuiEvent.Post event) {
    if (Config.showInventoryButton) {
        GuiScreen gui = event.getGui();
        if (gui instanceof GuiInventory) {
            int guiLeft = (gui.width - 176) / 2;
            int guiTop = (gui.height - 166) / 2;

            invButton = new TexturedButton(178223, guiLeft - 20, guiTop + 24, 20, 20, GuiModuleMain.RES_LOC, 0,
                    176);//w ww. j  av  a 2  s  . c o m
            event.getButtonList().add(invButton);

            IRarmorData data = RarmorAPI.methodHandler.getDataForChestplate(Minecraft.getMinecraft().player,
                    true);
            invButton.visible = data != null;
        }
    }
}

From source file:robmart.rpgmode.client.handlers.GuiEventHandler.java

License:Open Source License

@SubscribeEvent
public static void guiPostInit(GuiScreenEvent.InitGuiEvent.Post event) {
    if (event.getGui() instanceof GuiInventory) {
        GuiContainer gui = (GuiContainer) event.getGui();
        event.getButtonList().add(new GuiCharacterButton(event.getButtonList().size() + 1, gui, 132,
                gui.height / 2 - 22, 20, 18));
    }//w  w  w  .  j  av  a  2 s  .c  om
}

From source file:uk.kihira.tails.client.ClientEventHandler.java

License:Open Source License

@SubscribeEvent
@SuppressWarnings("unchecked")
public void onScreenInitPost(GuiScreenEvent.InitGuiEvent.Post event) {
    if (event.getGui() instanceof GuiIngameMenu) {
        event.getButtonList().add(new GuiButton(1234, (event.getGui().width / 2) - 35,
                event.getGui().height - 25, 70, 20, I18n.format("gui.button.editor")));
    }/*from   w  w w .  ja  v  a  2s  .c  om*/
}

From source file:vazkii.quark.management.feature.ChestButtons.java

License:Creative Commons License

@SubscribeEvent
@SideOnly(Side.CLIENT)/*from w  w  w. java  2  s  .c o  m*/
public void initGui(GuiScreenEvent.InitGuiEvent.Post event) {
    if (event.getGui() instanceof GuiContainer) {
        GuiContainer guiInv = (GuiContainer) event.getGui();
        Container container = guiInv.inventorySlots;
        EntityPlayer player = Minecraft.getMinecraft().player;

        if (debugClassnames)
            FMLLog.log(Level.INFO, "[Quark] Opening GUI %s", guiInv.getClass().getName());

        boolean accept = guiInv instanceof IChestButtonCallback || guiInv instanceof GuiChest
                || guiInv instanceof GuiShulkerBox || classnames.contains(guiInv.getClass().getName());

        if (!accept)
            for (Slot s : container.inventorySlots) {
                if (s instanceof SlotItemHandler
                        && DropoffHandler.isValidChest(player, ((SlotItemHandler) s).getItemHandler())) {
                    accept = true;
                    break;
                }

                IInventory inv = s.inventory;
                if (inv != null && DropoffHandler.isValidChest(player, inv)) {
                    accept = true;
                    break;
                }
            }

        if (!accept)
            return;

        chestButtons.clear();

        int guiLeft = guiInv.getGuiLeft();
        int guiTop = guiInv.getGuiTop();

        for (Slot s : container.inventorySlots)
            if (s.inventory == player.inventory && s.getSlotIndex() == 9) {
                addButtonAndKeybind(event, extract, Action.EXTRACT, guiInv, 13210, guiLeft, guiTop, s,
                        ModKeybinds.chestExtractKey);
                addButtonAndKeybind(event, restock, Action.RESTOCK, guiInv, 13211, guiLeft, guiTop, s,
                        ModKeybinds.chestRestockKey);
                addButtonAndKeybind(event, deposit, Action.DEPOSIT, guiInv, 13212, guiLeft, guiTop, s,
                        ModKeybinds.chestDropoffKey);
                addButtonAndKeybind(event, smartDeposit, Action.SMART_DEPOSIT, guiInv, 13213, guiLeft, guiTop,
                        s, ModKeybinds.chestMergeKey);

                if (ModuleLoader.isFeatureEnabled(InventorySorting.class)) {
                    addButtonAndKeybind(event, sort, Action.SORT, guiInv, 13214, guiLeft, guiTop, s,
                            ModKeybinds.chestSortKey);
                    addButtonAndKeybind(event, sortPlayer, Action.SORT_PLAYER, guiInv, 13215, guiLeft, guiTop,
                            s, ModKeybinds.playerSortKey);
                }

                break;
            }
    }
}

From source file:vazkii.quark.management.feature.StoreToChests.java

License:Creative Commons License

@SubscribeEvent
@SideOnly(Side.CLIENT)/*  www  . j a va  2s.c om*/
public void initGui(GuiScreenEvent.InitGuiEvent.Post event) {
    if (Minecraft.getMinecraft().world == null)
        clientDisabled = false;

    if (event.getGui() instanceof GuiInventory || event.getGui() instanceof GuiContainerCreative
            || classnames.contains(event.getGui().getClass().getName())) {
        if (clientDisabled)
            return;

        GuiContainer guiInv = (GuiContainer) event.getGui();
        GuiContainerCreative creativeInv = null;
        if (guiInv instanceof GuiContainerCreative)
            creativeInv = (GuiContainerCreative) guiInv;

        if (creativeInv == null && Minecraft.getMinecraft().player.capabilities.isCreativeMode)
            return;

        ChestButtons.chestButtons.clear();

        int left = guiInv.getGuiLeft();
        int top = guiInv.getGuiTop();

        Container container = guiInv.inventorySlots;
        for (Slot s : container.inventorySlots)
            if (creativeInv != null || s instanceof SlotCrafting) {
                if (creativeInv == null)
                    ChestButtons.addButtonAndKeybind(event, Action.DROPOFF, guiInv, 13211, s.xPos + xPos,
                            s.yPos + yPos, s, ModKeybinds.dropoffKey);
                else {
                    if (s.getSlotIndex() != 15)
                        continue;

                    ChestButtons.<GuiContainerCreative>addButtonAndKeybind(event, Action.DROPOFF, guiInv, 13211,
                            s.xPos + xPosC, s.yPos + yPosC, s, ModKeybinds.dropoffKey,
                            (gui) -> gui.getSelectedTabIndex() == CreativeTabs.INVENTORY.getTabIndex());
                }

                break;
            }
    }
}

From source file:vazkii.quark.tweaks.feature.StoreToChests.java

@SubscribeEvent
@SideOnly(Side.CLIENT)//from  w w w  .  jav  a 2  s  .  c  o  m
public void initGui(GuiScreenEvent.InitGuiEvent.Post event) {
    if (event.getGui() instanceof GuiInventory) {
        GuiInventory guiInv = (GuiInventory) event.getGui();

        int guiLeft = (guiInv.width - 176) / 2;
        int guiTop = (guiInv.height - 166) / 2;

        Container container = guiInv.inventorySlots;
        for (Slot s : container.inventorySlots)
            if (s instanceof SlotCrafting) {
                event.getButtonList().add(new GuiButtonStore(13211, guiLeft + s.xDisplayPosition,
                        guiTop + s.yDisplayPosition + 30));
                break;
            }
    }
}

From source file:vazkii.quark.vanity.feature.EmoteSystem.java

License:Creative Commons License

@SubscribeEvent
@SideOnly(Side.CLIENT)/*from  w  w  w. j a  v  a 2 s  .  co  m*/
public void initGui(GuiScreenEvent.InitGuiEvent.Post event) {
    GuiScreen gui = event.getGui();
    if (gui instanceof GuiChat) {
        List<GuiButton> list = event.getButtonList();
        list.add(new GuiButtonTranslucent(EMOTE_BUTTON_START, gui.width - 76, gui.height - 40, 75, 20,
                I18n.format("quark.gui.emotes")));

        int size = EmoteHandler.emoteMap.size() - 1;
        for (String key : EmoteHandler.emoteMap.keySet()) {
            EmoteDescriptor desc = EmoteHandler.emoteMap.get(key);
            int i = desc.index;
            int x = gui.width - ((i % 3) + 1) * 25 - 1;
            int y = gui.height - 65 - 25 * ((size / 3) - i / 3);

            GuiButton button = new GuiButtonEmote(EMOTE_BUTTON_START + i + 1, x, y, desc);
            button.visible = emotesVisible;
            button.enabled = emotesVisible;
            list.add(button);
        }
    }
}