Posted December 29, 20159 yr I'm trying to create a mod that removes the chat background (when you send a chat message, there is a transparent gray box behind it). I managed to do this using MCP, however I'd like to make a forge version of it now. When making a normal mod using MCP it's very easy to do, all I did was remove the 'drawRect' line in GuiNewChat, however I'm unsure how to do this in Forge. I noticed that GuiIngame has a field called 'persistantChatGUI', which is an instance of GuiNewChat. My current idea is to create a new class extending GuiNewChat, where the drawRect line is removed, then replace the persistantChatGUI field in GuiIngame using reflection. Is this the only way, or is there an easier solution? Thanks in advance.
December 29, 20159 yr Author Cancel RenderGameOverlayEvent.Chat and render your own chat version. I thought of that, however I'm not really sure how I would render the chat myself. For example, I could draw the chat using the drawString method in FontRenderer, but what if the chat message contained a website, how would I make that clickable?
December 29, 20159 yr Author That is part of the actual chat GuiScreen (GuiChat as opposed to GuiNewChat). If you want to replace that as well, use GuiOpenEvent. Oh you're right, didn't realise that. I don't necessarily have to replace the actual chat screen so I don't have to worry about that. I'll see how the chat is drawn in GuiNewChat and try it myself.
December 29, 20159 yr Author That is part of the actual chat GuiScreen (GuiChat as opposed to GuiNewChat). If you want to replace that as well, use GuiOpenEvent. I've cancelled the RenderGameOverlayEvent.Chat and copied the drawChat method into it, however I'm running into a new issue now. This is the code I currently have: @SubscribeEvent public void onChatRender(RenderGameOverlayEvent.Chat e) { e.setCanceled(true); GuiNewChat gui = mc.ingameGUI.getChatGUI(); if (mc.gameSettings.chatVisibility != EntityPlayer.EnumChatVisibility.HIDDEN) { int j = gui.func_146232_i(); boolean flag = false; int k = 0; int l = gui.field_146253_i.size(); float f = mc.gameSettings.chatOpacity * 0.9F + 0.1F; if (l > 0) { if (gui.getChatOpen()) { flag = true; } float f1 = gui.func_146244_h(); int i1 = MathHelper.ceiling_float_int((float) gui.func_146228_f() / f1); GL11.glPushMatrix(); GL11.glTranslatef(2.0F, 20.0F, 0.0F); GL11.glScalef(f1, f1, 1.0F); int j1; int k1; int i2; for (j1 = 0; j1 + gui.field_146250_j < gui.field_146253_i.size() && j1 < j; ++j1) { ChatLine chatline = (ChatLine) gui.field_146253_i.get(j1 + gui.field_146250_j); if (chatline != null) { k1 = mc.ingameGUI.getUpdateCounter() - chatline.getUpdatedCounter(); if (k1 < 200 || flag) { double d0 = (double) k1 / 200.0D; d0 = 1.0D - d0; d0 *= 10.0D; if (d0 < 0.0D) { d0 = 0.0D; } if (d0 > 1.0D) { d0 = 1.0D; } d0 *= d0; i2 = (int) (255.0D * d0); if (flag) { i2 = 255; } i2 = (int) ((float) i2 * f); ++k; if (i2 > 3) { byte b0 = 0; int j2 = -j1 * 9; GL11.glEnable(GL11.GL_BLEND); String s = chatline.func_151461_a().getFormattedText(); mc.fontRenderer.drawStringWithShadow(s, b0, j2 - 8, 16777215 + (i2 << 24)); GL11.glDisable(GL11.GL_ALPHA_TEST); } } } } if (flag) { j1 = mc.fontRenderer.FONT_HEIGHT; GL11.glTranslatef(-3.0F, 0.0F, 0.0F); int k2 = l * j1 + l; k1 = k * j1 + k; int l2 = gui.field_146250_j * k1 / l; int l1 = k1 * k1 / k2; if (k2 != k1) { i2 = l2 > 0 ? 170 : 96; int i3 = gui.field_146251_k ? 13382451 : 3355562; Gui.drawRect(0, -l2, 2, -l2 - l1, i3 + (i2 << 24)); Gui.drawRect(2, -l2, 1, -l2 - l1, 13421772 + (i2 << 24)); } } GL11.glPopMatrix(); } } } Some fields are not visible. I found a getter method for some of them, however some fields are not visible and don't have a getter either (for example 'field_146253_i').
December 29, 20159 yr Author Reflection to the rescue! I got it to work, and only had to use reflection once (the field was an ArrayList so I could just 'cache it'). Thanks a lot!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.