Java Code Examples for net.minecraftforge.client.event.GuiOpenEvent#setGui()

The following examples show how to use net.minecraftforge.client.event.GuiOpenEvent#setGui() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoReconnectMod.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onGuiOpened(GuiOpenEvent event) {
  if (!hasAutoLogged) {
    if (event.getGui() instanceof GuiDisconnected
        && !(event.getGui() instanceof GuiDisconnectedOverride)) {
      updateLastConnectedServer();
      GuiDisconnected disconnected = (GuiDisconnected) event.getGui();
      event.setGui(
          new GuiDisconnectedOverride(
              FastReflection.Fields.GuiDisconnected_parentScreen.get(disconnected),
              "connect.failed",
              FastReflection.Fields.GuiDisconnected_message.get(disconnected),
              FastReflection.Fields.GuiDisconnected_reason.get(disconnected),
              delay.get()));
    }
  }
}
 
Example 2
Source File: CMMEventHandler.java    From Custom-Main-Menu with MIT License 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void openGui(GuiOpenEvent event)
{
	if (event.getGui() instanceof GuiMainMenu)
	{
		GuiCustom customMainMenu = CustomMainMenu.INSTANCE.config.getGUI("mainmenu");
		if (customMainMenu != null)
		{
			event.setGui(customMainMenu);
		}
	}
	else if (event.getGui() instanceof GuiCustom)
	{
		GuiCustom custom = (GuiCustom) event.getGui();

		GuiCustom target = CustomMainMenu.INSTANCE.config.getGUI(custom.guiConfig.name);
		if (target != custom)
		{
			event.setGui(target);
		}
	}
}
 
Example 3
Source File: TofuClientEventLoader.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {

    if (event.getGui() instanceof GuiDownloadTerrain && client.player != null) {
        int tofuDimension = TofuConfig.dimensionID;
        if (client.player.dimension == tofuDimension || lastDimension == tofuDimension) {
            if (client.player.dimension == tofuDimension) {
                event.setGui(new GuiLoadTofuTerrain());
            } else {
                event.setGui(new GuiDownloadTofuTerrain());
            }
        }

    }
}
 
Example 4
Source File: ExtraInventory.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onGuiOpen(GuiOpenEvent event) {
  if (guiCloseGuard) {
    // do not close the gui when this mod executes closeWindow()
    event.setCanceled(true);
  } else if (event.getGui() instanceof GuiInventory) {
    // create a wrapper and replace the gui
    event.setGui(openedGui = createGuiWrapper((GuiInventory) event.getGui()));
    // server doesn't need to be informed the gui has been closed
    guiNeedsClose.set(false);
  }
}
 
Example 5
Source File: GuiHandler.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void openGuiHandler(GuiOpenEvent event)
{
	if(event.getGui() instanceof GuiInventory && !(event.getGui() instanceof GuiInventoryTFC))
		event.setGui(new GuiInventoryTFC(Minecraft.getMinecraft().player));
}