net.minecraftforge.client.event.GuiOpenEvent Java Examples
The following examples show how to use
net.minecraftforge.client.event.GuiOpenEvent.
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: PlayerListener.java From SkyblockAddons with MIT License | 6 votes |
@SubscribeEvent public void onGuiOpen(GuiOpenEvent e) { if (e.gui == null && GuiChest.class.equals(lastOpenedInventory)) { lastClosedInv = System.currentTimeMillis(); lastOpenedInventory = null; } if (e.gui != null) { lastOpenedInventory = e.gui.getClass(); if (e.gui instanceof GuiChest) { Minecraft mc = Minecraft.getMinecraft(); IInventory chestInventory = ((GuiChest)e.gui).lowerChestInventory; if (chestInventory.hasCustomName()) { if (chestInventory.getDisplayName().getUnformattedText().contains("Backpack")) { if (ThreadLocalRandom.current().nextInt(0, 2) == 0) { mc.thePlayer.playSound("mob.horse.armor", 0.5F, 1); } else { mc.thePlayer.playSound("mob.horse.leather", 0.5F, 1); } } } } } }
Example #2
Source File: GuiEventHandler.java From enderutilities with GNU Lesser General Public License v3.0 | 6 votes |
@SubscribeEvent public void onGuiOpenEvent(GuiOpenEvent event) { // Reset the scrolling modifier when the player opens a GUI. // Otherwise the key up event will get eaten and our scrolling mode will get stuck on // until the player sneaks again. // FIXME Apparently there are key input events for GUI screens in 1.8, // so this probably can be removed then. InputEventHandler.resetModifiers(); // Opening the player's Inventory GUI if (event.getGui() != null && event.getGui().getClass() == GuiInventory.class) { EntityPlayer player = FMLClientHandler.instance().getClientPlayerEntity(); if (this.handyBagShouldOpen && player != null && ItemHandyBag.getOpenableBag(player).isEmpty() == false) { if (event.isCancelable()) { event.setCanceled(true); } PacketHandler.INSTANCE.sendToServer(new MessageOpenGui(player.dimension, ReferenceGuiIds.GUI_ID_HANDY_BAG)); } } }
Example #3
Source File: CMMEventHandler.java From Custom-Main-Menu with MIT License | 6 votes |
@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 #4
Source File: AutoReconnectMod.java From ForgeHax with MIT License | 6 votes |
@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 #5
Source File: NEIClientEventHandler.java From NotEnoughItems with MIT License | 6 votes |
@SubscribeEvent public void guiOpenEvent(GuiOpenEvent event) { if (event.getGui() instanceof GuiContainer) { if (lastGui != event.getGui()) { if (event.getGui() == null) { instanceTooltipHandlers = null; } else { instanceTooltipHandlers = new LinkedList<>(); if (event.getGui() instanceof IContainerTooltipHandler) { instanceTooltipHandlers.add((IContainerTooltipHandler) event.getGui()); } instanceTooltipHandlers.addAll(tooltipHandlers); } lastGui = event.getGui(); } } }
Example #6
Source File: MatrixNotifications.java From ForgeHax with MIT License | 6 votes |
@SubscribeEvent public void onGuiOpened(GuiOpenEvent event) { if (event.getGui() instanceof GuiDisconnected && joined) { joined = false; if (on_disconnected.get()) { String reason = Optional.ofNullable(GuiDisconnected_message.get(event.getGui())) .map(ITextComponent::getUnformattedText) .orElse(""); if (reason.isEmpty()) { notify("Disconnected from %s", serverName); } else { notify("Disconnected from %s. Reason: %s", serverName, reason); } } } }
Example #7
Source File: YUNoMakeGoodMap.java From YUNoMakeGoodMap with Apache License 2.0 | 5 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) //Modders should never do this, im just lazy, and I KNOW what im doing. public void onOpenGui(GuiOpenEvent e) { //If we're opening the new world screen from the world selection, default to void world. if (e.getGui() instanceof GuiCreateWorld && Minecraft.getMinecraft().currentScreen instanceof GuiWorldSelection) { //Auto-select void world. GuiCreateWorld cw = (GuiCreateWorld)e.getGui(); ReflectionHelper.setPrivateValue(GuiCreateWorld.class, cw, worldType.getId(), "field_146331_K", "selectedIndex"); } }
Example #8
Source File: ClientEventHandler.java From Better-Sprinting with Mozilla Public License 2.0 | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true) public static void onGuiOpen(GuiOpenEvent e){ if (stopCheckingNewServer && mc.getRenderViewEntity() == null){ ClientModManager.onDisconnectedFromServer(); IntegrityCheck.unregister(); LivingUpdate.cleanup(); stopCheckingNewServer = false; showDisableWarningWhenPossible = false; } }
Example #9
Source File: CraftingKeys.java From CraftingKeys with MIT License | 5 votes |
/** * This method listens on GUIs open. Just to test my own gui! * * @param event Some Forge input event */ @SuppressWarnings({"EmptyMethod", "UnusedParameters"}) @SubscribeEvent public void onGuiOpened(GuiOpenEvent event) { //if (event.gui instanceof GuiMainMenu) { //event.gui = new GuiConfig(); // (Only for testing) //} }
Example #10
Source File: ItemHandUpgrade.java From Cyberware with MIT License | 5 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public void handleOpenInv(GuiOpenEvent event) { if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().thePlayer != null && event.getGui() != null && event.getGui().getClass() == GuiInventory.class && !Minecraft.getMinecraft().thePlayer.isCreative()) { if (CyberwareAPI.isCyberwareInstalled(Minecraft.getMinecraft().thePlayer, new ItemStack(this, 1, 0))) { event.setCanceled(true); Minecraft.getMinecraft().thePlayer.openGui(Cyberware.INSTANCE, 1, Minecraft.getMinecraft().thePlayer.worldObj, 0, 0, 0); CyberwarePacketHandler.INSTANCE.sendToServer(new GuiPacket(1, 0, 0, 0)); } } }
Example #11
Source File: AutoMine.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onGuiOpened(GuiOpenEvent event) { // process keys and mouse input even if this gui is open if (getWorld() != null && getLocalPlayer() != null && event.getGui() != null) { event.getGui().allowUserInput = true; } }
Example #12
Source File: ExtraInventory.java From ForgeHax with MIT License | 5 votes |
@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 #13
Source File: AutoEatMod.java From ForgeHax with MIT License | 5 votes |
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onGuiOpened(GuiOpenEvent event) { // process keys and mouse input even if this gui is open if (eating && getWorld() != null && getLocalPlayer() != null && event.getGui() != null) { event.getGui().allowUserInput = true; } }
Example #14
Source File: EnchantmentTableTweaks.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@SubscribeEvent @SideOnly(Side.CLIENT) public static void onGuiOpen(GuiOpenEvent event) { if (event.getGui() instanceof GuiContainer) { GuiContainer guiContainer = (GuiContainer) event.getGui(); EntityPlayerSP playerSP = Minecraft.getMinecraft().player; onContainerOpen(playerSP, guiContainer.inventorySlots); } }
Example #15
Source File: TofuClientEventLoader.java From TofuCraftReload with MIT License | 5 votes |
@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 #16
Source File: ShulkerViewer.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onGuiChanged(GuiOpenEvent event) { if (event.getGui() == null) { reset(); } }
Example #17
Source File: BedModeMod.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onGuiUpdate(GuiOpenEvent event) { if (event.getGui() instanceof GuiSleepMP) { event.setCanceled(true); } }
Example #18
Source File: GuiHandler.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void openGuiHandler(GuiOpenEvent event) { if(event.getGui() instanceof GuiInventory && !(event.getGui() instanceof GuiInventoryTFC)) event.setGui(new GuiInventoryTFC(Minecraft.getMinecraft().player)); }
Example #19
Source File: MixinMinecraftClient.java From patchwork-api with GNU Lesser General Public License v2.1 | 3 votes |
/** * <p>Sets the argument Screen as the main (topmost visible) screen.</p> * <strong>WARNING</strong>: This method is not thread-safe. Opening Screens from a * thread other than the main thread may cause many different issues, including * the Screen being rendered before it has initialized (leading to unusual * crashes). If on a thread other than the main thread, use * {@link net.minecraft.client.MinecraftClient#executeTask}: * * <pre> * MinecraftClient.getInstance().executeTask(() -> MinecraftClient.getInstance().openScreen(screen)); * </pre> * * @return the screen object which can be replaced during the GuiOpenEvent. */ private Screen patchwork_impl_fireOpenEvent(Screen screen) { // This is called just before: if (screen instanceof TitleScreen ... ) // We need to save a copy of currentScreen, just in case if it gets changed during GuiOpenEvent patchwork_oldScreen = this.currentScreen; GuiOpenEvent event = new GuiOpenEvent(screen); if (MinecraftForge.EVENT_BUS.post(event)) { return GuiOpenEventCancelMarker.INSTANCE; } else { return event.getGui(); } }