@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() )); } }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onGuiOpenEvent(GuiOpenEvent event) { if (event.getGui() == null) { // a gui has been closed -- reset remote gui if (Minecraft.getMinecraft().world instanceof HookedClientWorld) { ((HookedClientWorld)Minecraft.getMinecraft().world).ClearRemoteGui(); } else { Util.logger.error("Minecraft.getMinecraft().world is not instance of RemoteGuiEnabledClientWorld!"); } } }
@SubscribeEvent public void onOpenGui(GuiOpenEvent event) { if (event.gui instanceof GuiMainMenu) { event.gui = new RewiMainMenu(); } if (event.gui instanceof GuiIngameMenu) { event.gui = new RewiIngameMenu(); } if (event.gui instanceof GuiOptions) { event.gui = new RewiOptionsMenu(Minecraft.getMinecraft().currentScreen, Minecraft.getMinecraft().gameSettings); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onGuiOpen(GuiOpenEvent event) { if(event.getGui() instanceof GuiMainMenu && !played) { played = true; if(playOn == 1 || playOn == 3) { SoundEvent sound = SoundEvent.REGISTRY.getObject(new ResourceLocation(name)); if(sound != null) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.getMasterRecord(sound, (float)pitch)); } else { logger.log(Level.WARN, "Could not find sound: %s", new ResourceLocation(name)); } } } }
@SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { GuiScreen gui = event.getGui(); if(gui !=null && gui instanceof GuiScreenHorseInventory){ GuiScreenHorseInventory horseGui = (GuiScreenHorseInventory)gui; EntityHorse horse = (EntityHorse)ReflectionUtils.getPrivateValue(horseGui, GuiScreenHorseInventory.class, ObfuscatedNames.GuiScreenHorseInventory_horseEntity); if(horse !=null && HorseAccessories.hasEnderChest(horse)){ ContainerHorseChest animalchest = new ContainerHorseChest("HorseChest", 2); animalchest.setCustomName(horse.getName()); event.setGui(new GuiHorseEnderChest(CrystalMod.proxy.getClientPlayer().inventory, animalchest, horse)); PacketGuiMessage pkt = new PacketGuiMessage("Gui"); pkt.setOpenGui(GuiHandler.GUI_ID_ENTITY, horse.getEntityId(), 0, 0); CrystalModNetwork.sendToServer(pkt); } } }
@SubscribeEvent public static void onGuiOpen(@Nonnull final GuiOpenEvent event) { if (!hasPlayed && event.getGui() instanceof GuiMainMenu) { hasPlayed = true; final String[] possibles = ModOptions.startupSoundList; if (possibles == null || possibles.length == 0) return; final String res = possibles[XorShiftRandom.current().nextInt(possibles.length)]; if (!StringUtils.isEmpty(res)) { final SoundEvent se = SoundEvent.REGISTRY.getObject(new ResourceLocation(res)); if (se != null) SoundEngine.instance().playSound(new AdhocSound(se, SoundCategory.MASTER)); else DSurround.log().warn("Unable to locate startup sound [%s]", res); } else { DSurround.log().warn("Improperly formatted startup sound list!"); } } }
@SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { // if (event.gui instanceof GuiMainMenu) // { // { // // } // } if (event.gui instanceof GuiGameOver) { GuiFNAFGameOver.ticksElapsed = 0; mc.getSoundHandler().stopSounds(); if (!mc.getSoundHandler().isSoundPlaying(FNAFSoundHandler.deathStatic)) { mc.getSoundHandler().playSound(FNAFSoundHandler.deathStatic); } } }
@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(); } } }
@SideOnly(Side.CLIENT) @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(GuiOpenEvent event) { if (event.gui instanceof GuiIngameModOptions) { event.gui = new GuiModList(new GuiIngameMenu()); } }
@SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { if (event.gui == null) { return; } try { if (event.gui.getClass() == GuiModList.class) { event.setCanceled(true); Minecraft.getMinecraft().displayGuiScreen(new GuiEnhancedModList((GuiScreen) _mainMenu.get(event.gui))); } if (event.gui.getClass() == GuiIngameModOptions.class) { event.setCanceled(true); Minecraft.getMinecraft().displayGuiScreen(new GuiEnhancedModList((GuiScreen) _parentScreen.get(event.gui))); } } catch (Exception e) { Throwables.propagate(e); } }
@SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { GuiScreen gui = event.gui; if (!Settings.autoRespawn) { return; } if (gui instanceof GuiGameOver && !hasClicked) { Minecraft mc = Minecraft.getMinecraft(); if (!mc.theWorld.getWorldInfo().isHardcoreModeEnabled()) { hasClicked = true; mc.thePlayer.respawnPlayer(); mc.displayGuiScreen((GuiScreen) null); event.setCanceled(true); } } else if (!(gui instanceof GuiGameOver) && hasClicked) { hasClicked = false; } }
@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)); } } }
@SubscribeEvent public void onOpenGui(GuiOpenEvent evt) { GuiScreen gui = evt.getGui(); if (gui instanceof GuiMainMenu) { try { GuiMainMenu menu = (GuiMainMenu) gui; String splash = mainMenuGetSplashText(menu); if (splash.equals("Kind of dragon free!")) { splash = "Not really dragon free!"; mainMenuSetSplashText(menu, splash); } else if (splashLines != null && !splashLines.isEmpty() && rand.nextInt(10) == 0) { splash = splashLines.get(rand.nextInt(splashLines.size())); mainMenuSetSplashText(menu, splash); } } catch (Throwable t) { L.warn("Can't override splash", t); } } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void openMainMenu(GuiOpenEvent e) { if (e.gui instanceof GuiMainMenu && Config.replacements.isEmpty() && Config.itemReplacements.isEmpty()) { File file = new File(configDir, Refs.MOD_ID + "_data"); if (!file.exists()) { try { file.createNewFile(); } catch (Throwable t) { TooManyDanyOres.logger.warn("Unable to create a data file!"); TooManyDanyOres.logger.catching(t); } e.gui = new GuiStartupWarning((GuiMainMenu)e.gui); MinecraftForge.EVENT_BUS.unregister(this); } } }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onGui(GuiOpenEvent event) { if (event.gui instanceof GuiMainMenu) { if (shouldLoadGUI && ConfigurationHandler.showIRCGui) { event.gui = new IRCGui(); shouldLoadGUI = false; } else { ObfuscationReflectionHelper.setPrivateValue(GuiMainMenu.class, (GuiMainMenu) event.gui, getRandTPPISplash(), "splashText", "field_73975_c"); } } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void onOpenGui(GuiOpenEvent event) { Minecraft mc = Minecraft.getMinecraft(); if (mc.player != null && mc.player.getHealth() <= 0f) { mc.player.setSneaking(false); if (event.getGui() instanceof GuiChat && mc.gameSettings.keyBindSneak.isKeyDown()) { event.setGui(new GuiChat("/team ")); } } }
@SubscribeEvent public void onOpenGui(GuiOpenEvent event) { Minecraft mc = Minecraft.getMinecraft(); if (mc.player != null) { if (event.getGui() instanceof GuiGameOver && isKnockedOut && !acceptedDeath) { // Minor hack: isKnockedOut is always set AFTER the game over screen pops up, so we can abuse that here event.setGui(null); } else if (isKnockedOut && event.getGui() instanceof GuiInventory) { event.setGui(null); } } }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onEvent(GuiOpenEvent event) { if (event.gui instanceof GuiIngameModOptions) { event.gui = new MalmoModGuiOptions.MalmoModGuiScreen(null); } }
@SubscribeEvent public void guiInit(GuiOpenEvent e) { if(e.getGui() instanceof GuiVideoSettings) { e.setGui(new GuiNewVideoSettings(Minecraft.getMinecraft().currentScreen, Minecraft.getMinecraft().gameSettings)); } else if(e.getGui() instanceof GuiOptions) { e.setGui(new GuiNewOptions(((GuiOptions) e.getGui()).lastScreen, Minecraft.getMinecraft().gameSettings)); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onGuiOpen(GuiOpenEvent event) { if (event.gui instanceof GuiInventory) { } }
@SubscribeEvent(priority = EventPriority.LOWEST) public void onGuiClosed(GuiOpenEvent event) { MinecraftForge.EVENT_BUS.unregister(this); if (active) { active = false; getSuperMcGui().onGuiClosed(); } }
@SubscribeEvent public void onOpenGui(GuiOpenEvent event) { if (TickHandler.getInstance().fakeUseInProgress()) { event.setCanceled(true); } }
@SubscribeEvent public void guiOpenEvent(GuiOpenEvent event){ System.out.println(event.getGui()); if(event.getGui() instanceof GuiInventory){ event.setCanceled(true); Minecraft.getMinecraft().thePlayer.openGui(Main.instance, 21, Minecraft.getMinecraft().theWorld, (int) Minecraft.getMinecraft().thePlayer.posX, (int) Minecraft.getMinecraft().thePlayer.posY, (int) Minecraft.getMinecraft().thePlayer.posZ); } }
/** * Refresh models, skins and morphs upon entering in Metamorph and/or * Blockbuster GUIs. */ @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { if (!Blockbuster.proxy.config.auto_refresh_models) { return; } GuiScreen gui = event.getGui(); boolean isMetamorph = gui instanceof GuiCreativeMenu || gui instanceof GuiSurvivalMenu; boolean isBlockbuster = gui instanceof GuiDirector || gui instanceof GuiActor; boolean exitME = gui == null && Minecraft.getMinecraft().currentScreen instanceof GuiModelEditor; if (isMetamorph || isBlockbuster || exitME) { /* Reload models and skin */ ModelPack pack = Blockbuster.proxy.models.pack; if (pack == null) { pack = Blockbuster.proxy.getPack(); if (Minecraft.getMinecraft().isSingleplayer()) { pack.addFolder(DimensionManager.getCurrentSaveRootDirectory() + "/blockbuster/models"); } } Blockbuster.proxy.loadModels(pack); ClientProxy.actorPack.pack.reload(); } }
@Method(modid = "aperture") @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { if (Minecraft.getMinecraft().thePlayer == null) { return; } GuiScreen current = Minecraft.getMinecraft().currentScreen; GuiScreen toOpen = event.getGui(); BlockPos pos = getDirectorPos(); if (pos != null) { int tick = ClientProxy.cameraEditor.scrub.value; if (current != ClientProxy.cameraEditor && toOpen instanceof GuiCameraEditor) { /* Camera editor opens */ CameraHandler.tick = tick; if (CameraHandler.reload) { Dispatcher.sendToServer(new PacketDirectorPlay(pos, PacketDirectorPlay.START, tick)); } Dispatcher.sendToServer(new PacketRequestLength(pos)); } } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onMainMenuOpen(GuiOpenEvent event) { if (!dumped && event.getGui() instanceof GuiMainMenu) { dumped = true; TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); for (Map.Entry<ResourceLocation, ITextureObject> entry : textureManager.mapTextureObjects.entrySet()) { ITextureObject textureObject = entry.getValue(); if (textureObject instanceof TextureMap) { String name = entry.getKey().toString().replace(':', '_').replace('/', '_'); dumpTextureMap((TextureMap) textureObject, name); } } } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void openMainMenu(GuiOpenEvent event) throws IOException { if (event.gui instanceof GuiMainMenu) { event.gui = new NewMenu(); } }
/** Alters which vanilla Gui is opened. */ @SubscribeEvent public void guiOpen(GuiOpenEvent event) { EntityPlayer player = Minecraft.getMinecraft().player; if (event.getGui() instanceof net.minecraft.client.gui.inventory.GuiInventory && player.inventoryContainer instanceof ContainerInventory) { event.setGui(new jayavery.geomastery.gui.GuiInventory( (ContainerInventory) player.inventoryContainer)); } }
@SubscribeEvent public void onGui(GuiOpenEvent event) { if (event.getGui() == null || !GuiEnchantment.class.equals(event.getGui().getClass())) { // Only hook the enchantment GUI. We don't use instanceof, because we *only* want to // hook the unmodified GUI. return; } event.setGui(GuiEnchantmentWrapper.wrap((GuiEnchantment) event.getGui(), worker, lastInteractPos)); }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onPlayerDeathImage(GuiOpenEvent e) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if (!(e.getGui() instanceof GuiGameOver) || !Config.demiseImage || player == null || player.getHealth() <= 0F) return; // Getting discord and minecraft user try { User me = DiscordCE.client.getUserById(DiscordCE.client.getSelfInfo().getId()); Minecraft mc = Minecraft.getMinecraft(); ITextComponent t = ScreenShotHelper.saveScreenshot(mc.mcDataDir, mc.displayWidth, mc.displayHeight, mc.getFramebuffer()); String fileName = new JSONObject(TextComponentBase.Serializer.componentToJson(t)).getJSONArray("with") .getJSONObject(0).getJSONObject("clickEvent").getString("value"); File file = new File(fileName); TextChannel c = DiscordCE.client.getTextChannelById(Preferences.i.usingChannel); // Doing checks if (c == null || !c.checkPermission(me, Permission.MESSAGE_ATTACH_FILES)) return; //Sending file c.sendFileAsync(file, null, m -> file.delete()); } catch (Exception e1) { e1.printStackTrace(); } }
static void mainMenuGUI(GuiOpenEvent e) { if (menuGUI) if (e.gui instanceof GuiMainMenu) if (StartupGUI.shouldShow()) { e.gui = new StartupGUI(); menuGUI = false; } else if (e.gui instanceof GuiMainMenu) e.gui = new MainMenuGUI(); }
@SubscribeEvent public void npcTradeOpen(GuiOpenEvent event){ if(event.getGui() instanceof GuiMerchant){ if(((GuiMerchant) event.getGui()).getMerchant() instanceof NPCShop){ lastOpened = (NPCShop) ((GuiMerchant) event.getGui()).getMerchant(); }else{ Minecraft mc = Minecraft.getMinecraft(); event.setGui(new GuiNPCMerchant(mc.player.inventory, lastOpened, mc.world)); } } }
@SubscribeEvent @SideOnly( Side.CLIENT ) public void openMainMenu(final GuiOpenEvent event ) { // if the max shades has changed in form the user of the new usage. if ((!detectedSdVersion.equals(config.lastSDVersionWarned)) && (sdMajorMismatch || sdMinorMismatch || sdVersionCheckFailed)) { event.setGui(new GuiScreenStartup()); } }
@SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { if (allowNext) { allowNext = false; return; } if (event.gui instanceof GuiContainerCreative) { event.gui = new GuiBetterCreative(Minecraft.getMinecraft().thePlayer); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void checkMainMenu(GuiOpenEvent event) { String update = getUpdate(); if (event.getGui() instanceof GuiMainMenu && update != null) { event.setGui(new UiUpdate(event.getGui(), update)); MinecraftForge.EVENT_BUS.unregister(this); } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void checkMultiplayer(GuiOpenEvent event) { System.out.println("Checking for multiplayer."); if (event.getGui() instanceof GuiMultiplayer) event.setGui(new UiMultiplayer(new GuiMainMenu())); }
@Override public <T extends Event> boolean applyForgeEventPatch(T e) { GuiOpenEvent event = (GuiOpenEvent) e; String prefilledText = ReflectionHelper.get(ObfuscatedField.GuiChat_defaultInputFieldText, (net.minecraft.client.gui.GuiChat) event.getGui()); if (event.getGui() instanceof net.minecraft.client.gui.GuiSleepMP) event.setGui(new GuiSleepMP()); else event.setGui(prefilledText == null ? new GuiChat() : new GuiChat(prefilledText)); PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, true); return true; }
private boolean applyGuiOpenPatches(GuiOpenEvent event) { if (event.getGui() instanceof GuiMainMenu && this.startupServerName != null) { GuiScreen screen = connectToServerAtStartup(this.startupServerName, this.startupServerPort); this.startupServerName = null; if (screen == null) { FMLClientHandler.instance().connectToServerAtStartup(this.startupServerName, this.startupServerPort); PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, false); return false; } else { event.setGui(screen); PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, true); return true; } } else if (event.getGui() instanceof net.minecraft.client.gui.GuiMultiplayer) { if (parentScreenField == null) { PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, false); return false; } GuiScreen parentScreen = ReflectionHelper.get(ObfuscatedField.GuiMultiplayer_parentScreen, parentScreenField, (net.minecraft.client.gui.GuiMultiplayer) event.getGui()); event.setGui(new GuiMultiplayer(parentScreen)); PatchManager.instance().getGlobalAppliedPatches().setPatchSuccessfullyApplied(this.displayName, true); return true; } else throw new IllegalArgumentException("Invalid argument: GuiOpenEvent with GuiMainMenu or GuiMultiplayer required"); }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onGuiOpen(GuiOpenEvent event) { if (event.gui instanceof GuiEnchantment && !(event.gui instanceof SK_GuiEnchantment)) { event.gui = new SK_GuiEnchantment((GuiEnchantment) event.gui); } }