From 01cf29a202bac8b74498861f630485e6a331c939 Mon Sep 17 00:00:00 2001 From: Lex Manos Date: Mon, 30 Sep 2013 14:32:12 -0700 Subject: [PATCH] Add pre and post event to rendering Chat, allowing for placement of the chat box. Closes #733 --- .../minecraftforge/client/GuiIngameForge.java | 13 ++++++++++--- .../client/event/RenderGameOverlayEvent.java | 16 +++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/client/net/minecraftforge/client/GuiIngameForge.java b/client/net/minecraftforge/client/GuiIngameForge.java index 24ac8a865..93eabfef9 100644 --- a/client/net/minecraftforge/client/GuiIngameForge.java +++ b/client/net/minecraftforge/client/GuiIngameForge.java @@ -723,12 +723,19 @@ public class GuiIngameForge extends GuiIngame protected void renderChat(int width, int height) { - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, (float)(height - 48), 0.0F); mc.mcProfiler.startSection("chat"); + + RenderGameOverlayEvent.Chat event = new RenderGameOverlayEvent.Chat(eventParent, 0, height - 48); + if (MinecraftForge.EVENT_BUS.post(event)) return; + + GL11.glPushMatrix(); + GL11.glTranslatef((float)event.posX, (float)event.posY, 0.0F); persistantChatGUI.drawChat(updateCounter); - mc.mcProfiler.endSection(); GL11.glPopMatrix(); + + post(CHAT); + + mc.mcProfiler.endSection(); } protected void renderPlayerList(int width, int height) diff --git a/client/net/minecraftforge/client/event/RenderGameOverlayEvent.java b/client/net/minecraftforge/client/event/RenderGameOverlayEvent.java index 68ab5f73f..0c7ca2758 100644 --- a/client/net/minecraftforge/client/event/RenderGameOverlayEvent.java +++ b/client/net/minecraftforge/client/event/RenderGameOverlayEvent.java @@ -24,7 +24,8 @@ public class RenderGameOverlayEvent extends Event EXPERIENCE, TEXT, HEALTHMOUNT, - JUMPBAR + JUMPBAR, + CHAT } public final float partialTicks; @@ -79,4 +80,17 @@ public class RenderGameOverlayEvent extends Event this.right = right; } } + + public static class Chat extends Pre + { + public int posX; + public int posY; + + public Chat(RenderGameOverlayEvent parent, int posX, int posY) + { + super(parent, ElementType.CHAT); + this.posX = posX; + this.posY = posY; + } + } }