public boolean shouldAllowWalking() { // check if mod is active if (!isActive()) return false; // check if there is a player to move Minecraft mc = Minecraft.getMinecraft(); if (mc.thePlayer == null) return false; // check if player is viewing chat if ((mc.currentScreen instanceof GuiChat) || (mc.currentScreen instanceof GuiIngameMenu) || (mc.currentScreen instanceof NavigatorScreen)) { return false; } // check if inventory key is pressed return !Keyboard.isKeyDown(mc.gameSettings.keyBindInventory.getKeyCode()); }
@SideOnly(Side.CLIENT) public static boolean shouldDisplayTankGui(GuiScreen gui) { if (FMLClientHandler.instance().getClient().gameSettings.hideGUI) { return false; } if (gui == null) { return true; } if (gui instanceof GuiInventory) { return false; } return gui instanceof GuiChat; }
@SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { // first check that the player is not using the chat menu // you can use this method from before: // if (FMLClientHandler.instance().getClient().inGameHasFocus) { // or you can use this new one that is available, doesn't really matter if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { // you can get the key code of the key pressed using the Keyboard class: int kb = Keyboard.getEventKey(); // similarly, you can get the key state, but this will always be true when the event is fired: boolean isDown = Keyboard.getEventKeyState(); // same as before, chain if-else if statements to find which of your custom keys // was pressed and act accordingly: if (kb == keys[CUSTOM_INV].getKeyCode()) { EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; // before you could close the screen from here, but that no longer seems to be // possible instead, you need to do so from within the GUI itself // so we will just send a packet to open the GUI: player.openGui(LOTRRings.instance, UIHandler.PLAYERINVENTORY_UI_1, player.getEntityWorld(), player.chunkCoordX, player.chunkCoordY, player.chunkCoordZ); } } }
public boolean canDisplayInfoBar(Minecraft mc, ClientProxy clientProxy) { if(!clientProxy.isBuildMode()) return false; if(mc.currentScreen == null) return true; if(mc.currentScreen instanceof GuiIngameMenu) return true; if(mc.currentScreen instanceof GuiChat) return true; return false; }
@SubscribeEvent public void onKeyInput( KeyInputEvent event ) { if( (!FMLClientHandler.instance().isGUIOpen( GuiChat.class )) && (mc.currentScreen == null) && (mc.world != null) ) { if( XRay.keyBind_keys[ XRay.keyIndex_toggleXray ].isPressed() ) { XRay.drawOres = !XRay.drawOres; XrayRenderer.ores.clear(); } else if( XRay.keyBind_keys[ XRay.keyIndex_showXrayMenu ].isPressed() ) { mc.displayGuiScreen( new GuiList() ); } } }
@SubscribeEvent public void onMouseInput(InputEvent.MouseInputEvent event) { if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer thePlayer = mc.getMinecraft().thePlayer; ItemStack hand = thePlayer.getCurrentEquippedItem(); ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) thePlayer); int x = mc.objectMouseOver.blockX; int y = mc.objectMouseOver.blockY; int z = mc.objectMouseOver.blockZ; if (Mouse.isButtonDown(1) && hand == null) props.useMana(10); // TheDarkEra.packetPipeline.sendToServer(new PacketUseShout(x, y, // z)); } }
public static void onTick(TickEvent event) { if (System.currentTimeMillis() % 10 == 0) { Main.start("mcpvp", "vars"); AllVars.putVars(); Main.end(2); } if (event.type == TickEvent.Type.RENDER && event.phase == event.phase.END) { if (Main.mc.currentScreen == null || Main.mc.currentScreen instanceof GuiChat) { Main.start("mcpvp", "alerts"); Alerts.alert.showAlerts(); Medal.showAll(); Main.end(2); } } for (BoardTracker tracker : BoardTracker.boardTrackers) { Main.start("mcpvp", "trackers"); tracker.update(); Main.end(2); } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void textRenderEvent(RenderGameOverlayEvent.Text event) { if (keyBinding == null) return; if (Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu) { event.getLeft().add(NAME + " paused. Main menu open. If you want to AFK, use ALT+TAB."); } else if (Minecraft.getMinecraft().currentScreen instanceof GuiChat) { event.getLeft().add(NAME + " paused. Chat GUI open. If you want to AFK, use ALT+TAB."); } else { event.getLeft().add(NAME + " active: " + keyBinding.getDisplayName() + " (" + keyBinding.getKeyDescription().replaceFirst("^key\\.", "") + ')'); event.getLeft().add("Delay: " + i + " / " + delay); } }
@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 onInitGui(GuiScreenEvent.InitGuiEvent.Post event) { GuiScreen gui = event.getGui(); if(isEnabled && gui.mc.player != null && gui.mc.player.getHealth() <= 0f && gui instanceof GuiChat) { buttonPing = new GuiButton(-999, gui.width / 2 - 100, gui.height / 2 + 30, I18n.format("gui.hardcorerevival.send_ping")); event.getButtonList().add(buttonPing); } }
@SubscribeEvent public void onInitGui(GuiScreenEvent.InitGuiEvent.Post event) { Minecraft mc = event.getGui().mc; if (mc.player != null && isKnockedOut && event.getGui() instanceof GuiChat) { GuiScreen gui = event.getGui(); enableButtonTimer = 0; buttonDie = new GuiButton(-2, gui.width / 2 - 100, gui.height / 2 - 30, I18n.format("gui.hardcorerevival.die")); buttonDie.enabled = false; event.getButtonList().add(buttonDie); } }
@SubscribeEvent public void onDrawScreen(GuiScreenEvent.DrawScreenEvent.Post event) { GuiScreen gui = event.getGui(); Minecraft mc = gui.mc; if (mc.player != null && isKnockedOut && gui instanceof GuiChat) { enableButtonTimer += event.getRenderPartialTicks(); if(buttonDie != null) { if (enableButtonTimer >= 40) { buttonDie.enabled = true; buttonDie.displayString = I18n.format("gui.hardcorerevival.die"); } else if (enableButtonTimer >= 30) { buttonDie.displayString = "... " + I18n.format("gui.hardcorerevival.die") + " ..."; } else if (enableButtonTimer >= 20) { buttonDie.displayString = ".. " + I18n.format("gui.hardcorerevival.die") + " .."; } else if (enableButtonTimer >= 10) { buttonDie.displayString = ". " + I18n.format("gui.hardcorerevival.die") + " ."; } } GlStateManager.pushMatrix(); GlStateManager.scale(2f, 2f, 2f); gui.drawCenteredString(mc.fontRenderer, I18n.format("gui.hardcorerevival.knocked_out"), gui.width / 2 / 2, 30, 16777215); GlStateManager.popMatrix(); gui.drawCenteredString(mc.fontRenderer, I18n.format("gui.hardcorerevival.rescue_time_left", Math.max(0, (ModConfig.maxDeathTicks - deathTime) / 20)), gui.width / 2, gui.height / 2 + 10, 16777215); } else if(buttonDie != null) { buttonDie.visible = false; } }
/** * Displays the available command-completion options the server knows of */ public void handleTabComplete(S3APacketTabComplete packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); String[] astring = packetIn.func_149630_c(); if (this.gameController.currentScreen instanceof GuiChat) { GuiChat guichat = (GuiChat)this.gameController.currentScreen; guichat.onAutocompleteResponse(astring); } }
/** * Displays the available command-completion options the server knows of */ public void handleTabComplete(S3APacketTabComplete packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); String[] astring = packetIn.func_149630_c(); if (this.gameController.currentScreen instanceof GuiChat) { GuiChat guichat = (GuiChat) this.gameController.currentScreen; guichat.onAutocompleteResponse(astring); } }
public static boolean isChatOpen() { if (Minecraft.getMinecraft().currentScreen != null) { if (Minecraft.getMinecraft().currentScreen instanceof GuiChat) { return true; } } return false; }
public void autoComplete(String leftOfCursor) { latestAutoComplete = null; if (leftOfCursor.charAt(0) == '/') { leftOfCursor = leftOfCursor.substring(1); Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.currentScreen instanceof GuiChat) { List<String> commands = getTabCompletionOptions(mc.thePlayer, leftOfCursor, mc.thePlayer.getPosition()); if (commands != null && !commands.isEmpty()) { if (leftOfCursor.indexOf(' ') == -1) { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + "/" + commands.get(i) + RESET); } } else { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + commands.get(i) + RESET); } } latestAutoComplete = commands.toArray(new String[commands.size()]); } } } }
public void autoComplete(String leftOfCursor, String full) { latestAutoComplete = null; if (leftOfCursor.charAt(0) == '/') { leftOfCursor = leftOfCursor.substring(1); Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.field_71462_r instanceof GuiChat) { @SuppressWarnings("unchecked") List<String> commands = func_71558_b(mc.field_71439_g, leftOfCursor); if (commands != null && !commands.isEmpty()) { if (leftOfCursor.indexOf(' ') == -1) { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + "/" + commands.get(i) + RESET); } } else { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + commands.get(i) + RESET); } } latestAutoComplete = commands.toArray(new String[commands.size()]); } } } }
@SideOnly(Side.CLIENT) @Hook("net.minecraft.client.Minecraft#func_184117_aA") public static Hook.Result processKeyBinds(Minecraft mc) { if (projectionState) { for (; mc.gameSettings.keyBindTogglePerspective.isPressed(); mc.renderGlobal.setDisplayListEntitiesDirty()) { ++mc.gameSettings.thirdPersonView; if (mc.gameSettings.thirdPersonView > 2) mc.gameSettings.thirdPersonView = 0; if (mc.gameSettings.thirdPersonView == 0) mc.entityRenderer.loadEntityShader(mc.getRenderViewEntity()); else if (mc.gameSettings.thirdPersonView == 1) mc.entityRenderer.loadEntityShader(null); } while (mc.gameSettings.keyBindSmoothCamera.isPressed()) mc.gameSettings.smoothCamera = !mc.gameSettings.smoothCamera; boolean flag = mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN; if (flag) { while (mc.gameSettings.keyBindChat.isPressed()) mc.displayGuiScreen(new GuiChat()); if (mc.currentScreen == null && mc.gameSettings.keyBindCommand.isPressed()) mc.displayGuiScreen(new GuiChat("/")); } return Hook.Result.NULL; } return Hook.Result.VOID; }
@SubscribeEvent public void sendTyping(TickEvent e) { if (e.type != TickEvent.Type.CLIENT || DiscordCE.client == null || DiscordCE.client.getTextChannelById(Preferences.i.usingChannel) == null || lastTyping > System.currentTimeMillis() - 9000 || Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().currentScreen == null || !(Minecraft.getMinecraft().currentScreen instanceof GuiChat)) return; GuiChat gui = (GuiChat) Minecraft.getMinecraft().currentScreen; GuiTextField field = ReflectionHelper.getPrivateValue(GuiChat.class, gui, 4); // Players is typing in command and not sending message if (field.getText().isEmpty() || !field.getText().startsWith("//")) return; field.setMaxStringLength(2000); // Setting the last time the typing packet was sent lastTyping = System.currentTimeMillis(); // Sending typing packet in new thread so it doesn't lag ConcurrentUtil.executor.execute(() -> DiscordCE.client.getTextChannelById(Preferences.i.usingChannel).sendTyping()); }
@Override public void onPostRenderHUD(int screenWidth, int screenHeight) { ArmourSlotsHandler AR = new ArmourSlotsHandler(mc.thePlayer.inventory.armorInventory, this.mc, instance.RADurBar); ScaledResolution sc = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); if ((this.mc.inGameHasFocus || mc.currentScreen == null || mc.currentScreen instanceof GuiChat) && instance.RADur && !(instance.ArmourLoc == 0 && this.mc.gameSettings.keyBindPlayerList.isKeyDown() && this.mc.thePlayer.sendQueue.func_175106_d().size() > 1)) { AR.Render(sc.getScaledWidth(), sc.getScaledHeight(), this.ArmourRh); } }
public void autoComplete(String leftOfCursor, String full) { latestAutoComplete = null; if (leftOfCursor.charAt(0) == '/') { leftOfCursor = leftOfCursor.substring(1); Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.currentScreen instanceof GuiChat) { @SuppressWarnings("unchecked") List<String> commands = getPossibleCommands(mc.thePlayer, leftOfCursor); if (commands != null && !commands.isEmpty()) { if (leftOfCursor.indexOf(' ') == -1) { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + "/" + commands.get(i) + RESET); } } else { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + commands.get(i) + RESET); } } latestAutoComplete = commands.toArray(new String[commands.size()]); } } } }
@SideOnly(Side.CLIENT) @SubscribeEvent(priority = EventPriority.LOW) public void onRenderExperienceBar(RenderGameOverlayEvent event) { if (event.isCancelable() || event.type != ElementType.ALL) return; LocX = ConfigBaublesHud.hudPositionX; LocY = ConfigBaublesHud.hudPositionY; isVertical = ConfigBaublesHud.isVertical; scale = ConfigBaublesHud.hudScale; if(isVertical == 0) { LocOffsetY = 15; LocOffsetX = 0; } if(isVertical == 1) { LocOffsetY = 0; LocOffsetX = 15; } if (mc.inGameHasFocus || mc.currentScreen == null || (mc.currentScreen instanceof GuiChat) || (mc.currentScreen instanceof GuiHud) && !mc.gameSettings.showDebugInfo) { if(ConfigBaublesHud.enable == 0) drawBaublesHudIcons(event.resolution); } }
/** * Displays the available command-completion options the server knows of */ public void handleTabComplete(S3APacketTabComplete p_147274_1_) { String[] var2 = p_147274_1_.func_149630_c(); if (this.gameController.currentScreen instanceof GuiChat) { GuiChat var3 = (GuiChat)this.gameController.currentScreen; var3.func_146406_a(var2); } }
@SubscribeEvent public void onKeyInput(KeyboardInputEvent event) { if(FMLClientHandler.instance().isGUIOpen(GuiChat.class) || mc.currentScreen != null) return; EntityPlayer player = mc.thePlayer; Entity ridingEntity = player.ridingEntity; if(ridingEntity instanceof IControllable){ IControllable riding =(IControllable)ridingEntity; if(mc.gameSettings.keyBindForward.isKeyDown()) riding.pressKey(0, player); if(mc.gameSettings.keyBindBack.isKeyDown()) riding.pressKey(1, player); if(mc.gameSettings.keyBindLeft.isKeyDown()) riding.pressKey(2, player); if(mc.gameSettings.keyBindRight.isKeyDown()) riding.pressKey(3, player); if(mc.gameSettings.keyBindJump.isKeyDown()) riding.pressKey(4, player); if(downKey.isPressed()) riding.pressKey(5, player); if(mc.gameSettings.keyBindSneak.isKeyDown()) riding.pressKey(6, player); } }
@SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { int key = Keyboard.getEventKey(); boolean isDown = Keyboard.getEventKeyState(); if (isDown) { switch (key) { case Keyboard.KEY_Y: Minecraft mc = Minecraft.getMinecraft(); int x = mc.objectMouseOver.blockX; int y = mc.objectMouseOver.blockY; int z = mc.objectMouseOver.blockZ; ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer) Minecraft.getMinecraft().thePlayer); int a = props.getMaxMana(); TheDarkEra.packetPipeline.sendToServer(new PacketGetMana(a + 10)); break; case Keyboard.KEY_O: ShoutList.PreviousShout(); break; case Keyboard.KEY_P: ShoutList.NextShout(); break; default: break; } } } }
@SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.thePlayer != null && !InputWindow.isFrameDisplayable()) { if (inputKey.isPressed()) { InputWindow.showGUI(""); FMLClientHandler.instance().displayGuiScreen(FMLClientHandler.instance().getClient().thePlayer, new GuiChat()); } if (commandKey.isPressed()) { InputWindow.showGUI("/"); FMLClientHandler.instance().displayGuiScreen(FMLClientHandler.instance().getClient().thePlayer, new GuiChat()); } } }
@SubscribeEvent @SideOnly(Side.CLIENT) public void onKeyInput(InputEvent.KeyInputEvent event) { if (!FMLClientHandler.instance().isGUIOpen(GuiChat.class)) { if (keys[ACTIVATE_BAUBLE_KEY].isKeyDown() && !ACTIVATE_BAUBLE_KEY_PRESSED) { Network.sendToServer(new ActivateBaubleMessage()); ACTIVATE_BAUBLE_KEY_PRESSED = true; } else if (!keys[ACTIVATE_BAUBLE_KEY].isKeyDown() && ACTIVATE_BAUBLE_KEY_PRESSED) { ACTIVATE_BAUBLE_KEY_PRESSED = false; } } }
@SubscribeEvent public void onRenderGameOverlay(RenderGameOverlayEvent.Post event) { if (event.getType() != ElementType.ALL) { return; } if ((this.mc.currentScreen instanceof GuiChat) == false && this.mc.player != null) { this.buildersWandRenderer.renderHud(this.mc.player); this.rulerRenderer.renderHud(); this.renderPlacementPropertiesHud(this.mc.player); } }
@SubscribeEvent(priority = EventPriority.HIGHEST) public void tickEvent(TickEvent.ClientTickEvent event) { if (event.phase != TickEvent.Phase.START) return; if (Minecraft.getMinecraft().currentScreen instanceof GuiMainMenu) return; if (Minecraft.getMinecraft().currentScreen instanceof GuiChat) return; if (keyBinding == null) return; if (i++ < delay) return; i = 0; if (delay == 0) KeyBinding.setKeyBindState(keyBinding.getKeyCode(), true); KeyBinding.onTick(keyBinding.getKeyCode()); }
public void handleTabComplete(S3APacketTabComplete p_147274_1_) { String[] astring = p_147274_1_.func_149630_c(); if (this.gameController.currentScreen instanceof GuiChat) { GuiChat guichat = (GuiChat)this.gameController.currentScreen; guichat.func_146406_a(astring); } }
private static void tickEnd() { if (mc.thePlayer != null) { if ((mc.currentScreen == null || Config.showHUDWhileChatting && mc.currentScreen instanceof GuiChat) && !mc.gameSettings.hideGUI && !mc.gameSettings.showDebugInfo) { ItemStack chestplate = mc.thePlayer.getCurrentArmor(2); if (chestplate != null && chestplate.getItem() instanceof IHUDInfoProvider) { IHUDInfoProvider provider = (IHUDInfoProvider) chestplate.getItem(); List<String> info = new ArrayList<String>(); provider.addHUDInfo(info, chestplate, Config.enableFuelHUD, Config.enableStateHUD); if (info.isEmpty()) { return; } GL11.glPushMatrix(); mc.entityRenderer.setupOverlayRendering(); GL11.glScaled(Config.HUDScale, Config.HUDScale, 1.0D); int i = 0; for (String s : info) { RenderUtils.drawStringAtHUDPosition(s, HUDPositions.values()[Config.HUDPosition], mc.fontRenderer, Config.HUDOffsetX, Config.HUDOffsetY, Config.HUDScale, 0xeeeeee, true, i); i++; } GL11.glPopMatrix(); } } } }
private static void tickEnd() { if (mc.thePlayer != null) { mc.entityRenderer.setupOverlayRendering(); long time = mc.theWorld.getWorldTime(); mc.fontRenderer.drawString(String.valueOf(time), 5, 5, 0); if ((mc.currentScreen == null || mc.currentScreen instanceof GuiChat) && !mc.gameSettings.hideGUI && !mc.gameSettings.showDebugInfo) { // if (stopWatch != null && stopWatch.getItem() instanceof // ItemPocketWatch) { // } } } }
public void func_72461_a(Packet203AutoComplete p_72461_1_) { String[] var2 = p_72461_1_.func_73473_d().split("\u0000"); if(this.field_72563_h.field_71462_r instanceof GuiChat) { GuiChat var3 = (GuiChat)this.field_72563_h.field_71462_r; var3.func_73894_a(var2); } }
public void autoComplete(String leftOfCursor, String full) { latestAutoComplete = null; if (leftOfCursor.charAt(0) == '/') { leftOfCursor = leftOfCursor.substring(1); Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.currentScreen instanceof GuiChat) { List<String> commands = getPossibleCommands(mc.thePlayer, leftOfCursor); if (commands != null && !commands.isEmpty()) { if (leftOfCursor.indexOf(' ') == -1) { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + "/" + commands.get(i) + RESET); } } else { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + commands.get(i) + RESET); } } latestAutoComplete = commands.toArray(new String[commands.size()]); } } } }
public void handleAutoComplete(Packet203AutoComplete par1Packet203AutoComplete) { String[] astring = par1Packet203AutoComplete.getText().split("\u0000"); if (this.mc.currentScreen instanceof GuiChat) { GuiChat guichat = (GuiChat)this.mc.currentScreen; guichat.func_73894_a(astring); } }