private void buildAutoCompletes(GuiTextField inputField, GuiChat chat) { String leftOfCursor; if(inputField.getCursorPosition() == 0) leftOfCursor = ""; else leftOfCursor = inputField.getText().substring(0, inputField.getCursorPosition()); if(leftOfCursor.length() == 0 || leftOfCursor.charAt(0) == '/') return; completions = getNames(leftOfCursor); if(completions.isEmpty()) return; position = -1; //ReflectionHelper.setPrivateValue(GuiChat.class, chat, true, LibObfuscation.COMPLETE_FLAG); StringBuilder stringbuilder = new StringBuilder(); CompletionData data; for(Iterator<CompletionData> iterator = completions.iterator(); iterator.hasNext(); stringbuilder.append(data.string)) { data = iterator.next(); if(stringbuilder.length() > 0) stringbuilder.append(", "); } Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(stringbuilder.toString()), 1); isAutoCompleted = true; originalString = inputField.getText(); }
String cmd = "/botania-share " + entry.getUnlocalizedName(); mc.ingameGUI.getChatGUI().addToSentMessages(cmd); mc.player.sendChatMessage(cmd); break;
@SubscribeEvent public static void buttonPressed(KeyboardInputEvent.Post event) { Minecraft mc = Minecraft.getMinecraft(); if(mc.world == null || !supportedGuiFilter.test(mc.currentScreen) || Keyboard.getEventKey() != ClientProxy.CORPOREA_REQUEST.getKeyCode() || !Keyboard.getEventKeyState() || Keyboard.isRepeatEvent() || TileCorporeaIndex.InputHandler.getNearbyIndexes(mc.player).isEmpty()) return; ItemStack stack = getStackUnderMouse(); if(stack != null && !stack.isEmpty()) { int count = 1; int max = stack.getMaxStackSize(); if(GuiScreen.isShiftKeyDown()) { count = max; if(GuiScreen.isCtrlKeyDown()) count /= 4; } else if(GuiScreen.isCtrlKeyDown()) count = max / 2; if(count > 0) { String name = CorporeaHelper.stripControlCodes(stack.getDisplayName()); String full = count + " " + name; mc.ingameGUI.getChatGUI().addToSentMessages(full); mc.player.sendChatMessage(full); event.setCanceled(true); } } }
@Override public void addIndexedChatMessage(ITextComponent chat, int index) { if (chat == null) { Minecraft.getMinecraft().ingameGUI.getChatGUI().deleteChatLine(index); } else { Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(chat, index); } }
@SuppressWarnings("unchecked") @ClientSideOnlyMethodContent private void storeSendMessages() { sendChatMessages = new ArrayList<>(); sendChatMessages.addAll(FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().getSentMessages()); }
private static void sendNoSpamMessages(ITextComponent[] messages) { GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) { chat.deleteChatLine(i); } for (int i = 0; i < messages.length; i++) { chat.printChatMessageWithOptionalDeletion(messages[i], DELETION_ID + i); } lastAdded = DELETION_ID + messages.length - 1; }
private static void displayChatMessages(ITextComponent[] messages) { GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) { chat.deleteChatLine(i); } for (int i = 0; i < messages.length; i++) { chat.printChatMessageWithOptionalDeletion(messages[i], DELETION_ID + i); } lastAdded = DELETION_ID + messages.length - 1; }
@ClientSideOnlyMethodContent private void addSendMessages(String substring) { if (sendChatMessages != null) { sendChatMessages.add(substring); } else { FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().addToSentMessages(substring); } }
static void sendNoSpamMessages(ITextComponent[] messages) { GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); for (int i = DELETION_ID + messages.length - 1; i <= lastAdded; i++) { chat.deleteChatLine(i); } for (int i = 0; i < messages.length; i++) { final ITextComponent chatComponent = messages[i]; if (chatComponent != null) { chat.printChatMessageWithOptionalDeletion(chatComponent, DELETION_ID + i); } } lastAdded = DELETION_ID + messages.length - 1; }
/** * Sends a spamless message to the chat. A spamless message is one that only shows up in * the chat once. If another version of the message were to be added to chat, the earlier * one would be removed. * * @param messageID A unique message ID used to separate your message from the others. It * is highly recommended to use a random number to prevent conflicts with other mods * doing similar things. Each message type should have it's own ID. * @param message The message to send to chat, this message will replace earlier messages * in the gui that use the same ID. */ @SideOnly(Side.CLIENT) public static void sendSpamlessMessage (int messageID, ITextComponent message) { final GuiNewChat chat = Minecraft.getMinecraft().ingameGUI.getChatGUI(); chat.printChatMessageWithOptionalDeletion(message, messageID); }
@Override public void handlePacket(EntityPlayer player) { if (gold) { CalendarHUD.editingCalendar = false; CalendarHUD.editingGold = true; MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + "Open a gui to edit the gold hud position")); MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + " WASD/Arrows to move around")); MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + " H to Hide/Show the textures")); MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + " Enter to Finish Editing")); } else { CalendarHUD.editingCalendar = true; CalendarHUD.editingGold = false; MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + "Open a gui to edit the date hud position")); MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + " WASD/Arrows to move around")); MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + " H to Hide/Show the textures")); MCClientHelper.getMinecraft().ingameGUI.getChatGUI().printChatMessage(new TextComponentString(TextFormatting.GOLD + " Enter to Finish Editing")); } } }
protected void keyTyped(char typedChar, int keyCode) throws IOException { if (keyCode == 1) { this.wakeFromSleep(); } else if (keyCode != 28 && keyCode != 156) { super.keyTyped(typedChar, keyCode); } else { String s = this.inputField.getText().trim(); if (!s.isEmpty()) { this.sendChatMessage(s); } this.inputField.setText(""); this.mc.ingameGUI.getChatGUI().resetScroll(); } }
@ClientSideOnlyMethodContent private void restoreSendMessages() { if (sendChatMessages != null) { for (String o : sendChatMessages) { FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().addToSentMessages(o); } sendChatMessages = null; } }
@ClientSideOnlyMethodContent private void clearChat() { FMLClientHandler.instance().getClient().ingameGUI.getChatGUI().clearChatMessages(true); }
public void displayCrashScreen(CrashReport report) { try { CrashUtils.outputReport(report); // Reset hasCrashed, debugCrashKeyPressTime, and crashIntegratedServerNextTick hasCrashed = false; debugCrashKeyPressTime = -1; crashIntegratedServerNextTick = false; // Vanilla does this when switching to main menu but not our custom crash screen // nor the out of memory screen (see https://bugs.mojang.com/browse/MC-128953) gameSettings.showDebugInfo = false; ingameGUI.getChatGUI().clearChatMessages(true); // Display the crash screen runGUILoop(new GuiCrashScreen(report)); } catch (Throwable t) { // The crash screen has crashed. Report it normally instead. LOGGER.error("An uncaught exception occured while displaying the crash screen, making normal report instead", t); displayCrashReport(report); System.exit(report.getFile() != null ? -1 : -2); } }
ingameGUI.getChatGUI().printChatMessage(event.getCancelMessage()); return; } else { ingameGUI.getChatGUI().printChatMessage(event.getResultMessage()); return; screenshotLink.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, screenshotFile.getAbsolutePath())); screenshotLink.getStyle().setUnderlined(true); ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("screenshot.success", screenshotLink)); } catch (Exception e) { LOGGER.warn("Couldn't save screenshot", e); ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("screenshot.failure", e.getMessage())); ingameGUI.getChatGUI().printChatMessage(new TextComponentTranslation("screenshot.failure", e.getMessage()));
/** * Sends a spamless chat message to the client. * * @param messageID The unique ID for the spamless message. * @param message The message to send. */ @SideOnly(Side.CLIENT) public static void sendSpamlessMessage (int messageID, ITextComponent message) { Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(message, messageID); }