@Override public void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock) { if (inGame && minecraft.currentScreen == null) { if (LiteModExample.toggleJumpKeybinding.isPressed()) { Minecraft.getMinecraft().gameSettings.autoJump = !Minecraft.getMinecraft().gameSettings.autoJump; ITextComponent message = new TextComponentString(""); ITextComponent prefix = new TextComponentString("[ToggleJump] "); prefix.setStyle(new Style().setColor(TextFormatting.GOLD)); ITextComponent text; if (Minecraft.getMinecraft().gameSettings.autoJump) { text = new TextComponentString("Auto jump is now enabled"); } else { text = new TextComponentString("Auto jump is now disabled"); } message.appendSibling(prefix); message.appendSibling(text); Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessage(message); } } }
/** * Sends a message that will be displayed ingame. * * @param color The color of the message. * @param message The message to send. */ private void sendMessage(TextFormatting color, String message) { ITextComponent chat = new TextComponentString(PluginStandardValues.PLUGIN_NAME + ": " + message); Style chatStyle = new Style(); chatStyle.setColor(color); chat.setStyle(chatStyle); Minecraft.getMinecraft().thePlayer.addChatMessage(chat); }