Merge pull request #1062 from bspkrs/master
New GuiScreen events and a new ElementType DEBUG for RenderGameOverlayEvent
This commit is contained in:
commit
3b79370be1
5 changed files with 254 additions and 17 deletions
|
@ -1,6 +1,17 @@
|
|||
--- ../src-base/minecraft/net/minecraft/client/gui/GuiScreen.java
|
||||
+++ ../src-work/minecraft/net/minecraft/client/gui/GuiScreen.java
|
||||
@@ -111,7 +111,9 @@
|
||||
@@ -17,6 +17,10 @@
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
+import net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent;
|
||||
+import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
+
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -111,7 +115,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,7 +21,7 @@
|
|||
}
|
||||
|
||||
protected void func_146279_a(String p_146279_1_, int p_146279_2_, int p_146279_3_)
|
||||
@@ -121,6 +123,11 @@
|
||||
@@ -121,6 +127,11 @@
|
||||
|
||||
protected void func_146283_a(List p_146283_1_, int p_146283_2_, int p_146283_3_)
|
||||
{
|
||||
|
@ -22,7 +33,7 @@
|
|||
if (!p_146283_1_.isEmpty())
|
||||
{
|
||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
||||
@@ -133,7 +140,7 @@
|
||||
@@ -133,7 +144,7 @@
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String s = (String)iterator.next();
|
||||
|
@ -31,7 +42,7 @@
|
|||
|
||||
if (l > k)
|
||||
{
|
||||
@@ -178,7 +185,7 @@
|
||||
@@ -178,7 +189,7 @@
|
||||
for (int i2 = 0; i2 < p_146283_1_.size(); ++i2)
|
||||
{
|
||||
String s1 = (String)p_146283_1_.get(i2);
|
||||
|
@ -40,3 +51,36 @@
|
|||
|
||||
if (i2 == 0)
|
||||
{
|
||||
@@ -207,9 +218,14 @@
|
||||
|
||||
if (guibutton.func_146116_c(this.field_146297_k, p_73864_1_, p_73864_2_))
|
||||
{
|
||||
- this.field_146290_a = guibutton;
|
||||
- guibutton.func_146113_a(this.field_146297_k.func_147118_V());
|
||||
- this.func_146284_a(guibutton);
|
||||
+ ActionPerformedEvent.Pre event = new ActionPerformedEvent.Pre(this, guibutton, this.field_146292_n);
|
||||
+ if (MinecraftForge.EVENT_BUS.post(event))
|
||||
+ break;
|
||||
+ this.field_146290_a = event.button;
|
||||
+ event.button.func_146113_a(this.field_146297_k.func_147118_V());
|
||||
+ this.func_146284_a(event.button);
|
||||
+ if (this.field_146297_k.field_71462_r.equals(this))
|
||||
+ MinecraftForge.EVENT_BUS.post(new ActionPerformedEvent.Post(this, event.button, this.field_146292_n));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -234,8 +250,12 @@
|
||||
this.field_146289_q = p_146280_1_.field_71466_p;
|
||||
this.field_146294_l = p_146280_2_;
|
||||
this.field_146295_m = p_146280_3_;
|
||||
- this.field_146292_n.clear();
|
||||
- this.func_73866_w_();
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Pre(this, this.field_146292_n)))
|
||||
+ {
|
||||
+ this.field_146292_n.clear();
|
||||
+ this.func_73866_w_();
|
||||
+ }
|
||||
+ MinecraftForge.EVENT_BUS.post(new InitGuiEvent.Post(this, this.field_146292_n));
|
||||
}
|
||||
|
||||
public void func_73866_w_() {}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
--- ../src-base/minecraft/net/minecraft/client/renderer/EntityRenderer.java
|
||||
+++ ../src-work/minecraft/net/minecraft/client/renderer/EntityRenderer.java
|
||||
@@ -51,6 +51,11 @@
|
||||
@@ -51,6 +51,12 @@
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GLContext;
|
||||
import org.lwjgl.util.glu.Project;
|
||||
+import net.minecraftforge.client.ForgeHooksClient;
|
||||
+import net.minecraftforge.client.IRenderHandler;
|
||||
+import net.minecraftforge.client.event.DrawBlockHighlightEvent;
|
||||
+import net.minecraftforge.client.event.GuiScreenEvent.DrawScreenEvent;
|
||||
+import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
+import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class EntityRenderer implements IResourceManagerReloadListener
|
||||
@@ -358,7 +363,7 @@
|
||||
@@ -358,7 +364,7 @@
|
||||
|
||||
if (d3 < d2 || d2 == 0.0D)
|
||||
{
|
||||
|
@ -21,7 +22,7 @@
|
|||
{
|
||||
if (d2 == 0.0D)
|
||||
{
|
||||
@@ -392,8 +397,15 @@
|
||||
@@ -392,8 +398,15 @@
|
||||
|
||||
private void func_78477_e()
|
||||
{
|
||||
|
@ -39,7 +40,7 @@
|
|||
this.field_78506_S = this.field_78507_R;
|
||||
this.field_78507_R += (this.field_78501_T - this.field_78507_R) * 0.5F;
|
||||
|
||||
@@ -416,7 +428,7 @@
|
||||
@@ -416,7 +429,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -48,7 +49,7 @@
|
|||
float f1 = 70.0F;
|
||||
|
||||
if (p_78481_2_)
|
||||
@@ -497,15 +509,7 @@
|
||||
@@ -497,15 +510,7 @@
|
||||
|
||||
if (!this.field_78531_r.field_71474_y.field_74325_U)
|
||||
{
|
||||
|
@ -65,7 +66,18 @@
|
|||
GL11.glRotatef(entitylivingbase.field_70126_B + (entitylivingbase.field_70177_z - entitylivingbase.field_70126_B) * p_78467_1_ + 180.0F, 0.0F, -1.0F, 0.0F);
|
||||
GL11.glRotatef(entitylivingbase.field_70127_C + (entitylivingbase.field_70125_A - entitylivingbase.field_70127_C) * p_78467_1_, -1.0F, 0.0F, 0.0F);
|
||||
}
|
||||
@@ -1203,7 +1207,10 @@
|
||||
@@ -1052,7 +1057,9 @@
|
||||
|
||||
try
|
||||
{
|
||||
- this.field_78531_r.field_71462_r.func_73863_a(k, l, p_78480_1_);
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(new DrawScreenEvent.Pre(this.field_78531_r.field_71462_r, k, l, p_78480_1_)))
|
||||
+ this.field_78531_r.field_71462_r.func_73863_a(k, l, p_78480_1_);
|
||||
+ MinecraftForge.EVENT_BUS.post(new DrawScreenEvent.Post(this.field_78531_r.field_71462_r, k, l, p_78480_1_));
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
@@ -1203,7 +1210,10 @@
|
||||
GL11.glPushMatrix();
|
||||
RenderHelper.func_74519_b();
|
||||
this.field_78531_r.field_71424_I.func_76318_c("entities");
|
||||
|
@ -76,7 +88,7 @@
|
|||
this.func_78463_b((double)p_78471_1_);
|
||||
this.field_78531_r.field_71424_I.func_76318_c("litParticles");
|
||||
effectrenderer.func_78872_b(entitylivingbase, p_78471_1_);
|
||||
@@ -1221,7 +1228,10 @@
|
||||
@@ -1221,7 +1231,10 @@
|
||||
entityplayer = (EntityPlayer)entitylivingbase;
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
this.field_78531_r.field_71424_I.func_76318_c("outline");
|
||||
|
@ -88,7 +100,7 @@
|
|||
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
||||
}
|
||||
}
|
||||
@@ -1234,14 +1244,17 @@
|
||||
@@ -1234,14 +1247,17 @@
|
||||
entityplayer = (EntityPlayer)entitylivingbase;
|
||||
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
||||
this.field_78531_r.field_71424_I.func_76318_c("outline");
|
||||
|
@ -108,7 +120,7 @@
|
|||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
@@ -1296,6 +1309,16 @@
|
||||
@@ -1296,6 +1312,16 @@
|
||||
renderglobal.func_72719_a(entitylivingbase, 1, (double)p_78471_1_);
|
||||
}
|
||||
|
||||
|
@ -125,7 +137,7 @@
|
|||
GL11.glDepthMask(true);
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
@@ -1307,9 +1330,12 @@
|
||||
@@ -1307,9 +1333,12 @@
|
||||
this.func_82829_a(renderglobal, p_78471_1_);
|
||||
}
|
||||
|
||||
|
@ -139,7 +151,7 @@
|
|||
{
|
||||
GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
|
||||
this.func_78476_b(p_78471_1_, j);
|
||||
@@ -1425,6 +1451,13 @@
|
||||
@@ -1425,6 +1454,13 @@
|
||||
|
||||
protected void func_78474_d(float p_78474_1_)
|
||||
{
|
||||
|
|
|
@ -630,7 +630,7 @@ public class GuiIngameForge extends GuiIngame
|
|||
}
|
||||
|
||||
|
||||
if (this.mc.gameSettings.showDebugInfo)
|
||||
if (this.mc.gameSettings.showDebugInfo && !pre(DEBUG))
|
||||
{
|
||||
mc.mcProfiler.startSection("debug");
|
||||
GL11.glPushMatrix();
|
||||
|
@ -688,6 +688,7 @@ public class GuiIngameForge extends GuiIngame
|
|||
}
|
||||
GL11.glPopMatrix();
|
||||
mc.mcProfiler.endSection();
|
||||
post(DEBUG);
|
||||
}
|
||||
|
||||
RenderGameOverlayEvent.Text event = new RenderGameOverlayEvent.Text(eventParent, left, right);
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
package net.minecraftforge.client.event;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* Event classes for GuiScreen events.
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiScreenEvent extends Event
|
||||
{
|
||||
/**
|
||||
* The GuiScreen object generating this event.
|
||||
*/
|
||||
public final GuiScreen gui;
|
||||
|
||||
public GuiScreenEvent(GuiScreen gui)
|
||||
{
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public static class InitGuiEvent extends GuiScreenEvent
|
||||
{
|
||||
/**
|
||||
* The {@code buttonList} field from the GuiScreen object referenced by {@code gui}.
|
||||
*/
|
||||
public List buttonList;
|
||||
|
||||
public InitGuiEvent(GuiScreen gui, List buttonList)
|
||||
{
|
||||
super(gui);
|
||||
this.buttonList = buttonList;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires just after initializing {@code GuiScreen.mc}, {@code GuiScreen.fontRendererObj},
|
||||
* {@code GuiScreen.width}, and {@code GuiScreen.height}, and just before calling {@code GuiScreen.buttonList.clear()}
|
||||
* and {@code GuiScreen.initGui()}. To skip or override a screen's initGui() method cancel the event.<br/><br/>
|
||||
*
|
||||
* If canceled the following lines are skipped in {@code GuiScreen.setWorldAndResolution()}:<br/>
|
||||
* {@code this.buttonList.clear();}<br/>
|
||||
* {@code this.initGui();}<br/>
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends InitGuiEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, List buttonList)
|
||||
{
|
||||
super(gui, buttonList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires right after {@code GuiScreen.initGui()}.
|
||||
* This is a good place to alter a GuiScreen's component layout if desired.
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public static class Post extends InitGuiEvent
|
||||
{
|
||||
public Post(GuiScreen gui, List buttonList)
|
||||
{
|
||||
super(gui, buttonList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class DrawScreenEvent extends GuiScreenEvent
|
||||
{
|
||||
/**
|
||||
* The x coordinate of the mouse pointer on the screen.
|
||||
*/
|
||||
public final int mouseX;
|
||||
/**
|
||||
* The y coordinate of the mouse pointer on the screen.
|
||||
*/
|
||||
public final int mouseY;
|
||||
/**
|
||||
* Partial render ticks elapsed.
|
||||
*/
|
||||
public final float renderPartialTicks;
|
||||
|
||||
public DrawScreenEvent(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui);
|
||||
this.mouseX = mouseX;
|
||||
this.mouseY = mouseY;
|
||||
this.renderPartialTicks = renderPartialTicks;
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires just before {@code GuiScreen.drawScreen()} is called.
|
||||
* Cancel this event to skip {@code GuiScreen.drawScreen()}.
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends DrawScreenEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui, mouseX, mouseY, renderPartialTicks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires just after {@code GuiScreen.drawScreen()} is called.
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public static class Post extends DrawScreenEvent
|
||||
{
|
||||
public Post(GuiScreen gui, int mouseX, int mouseY, float renderPartialTicks)
|
||||
{
|
||||
super(gui, mouseX, mouseY, renderPartialTicks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ActionPerformedEvent extends GuiScreenEvent
|
||||
{
|
||||
/**
|
||||
* The button that was clicked.
|
||||
*/
|
||||
public GuiButton button;
|
||||
/**
|
||||
* A COPY of the {@code buttonList} field from the GuiScreen referenced by {@code gui}.
|
||||
*/
|
||||
public List buttonList;
|
||||
|
||||
public ActionPerformedEvent(GuiScreen gui, GuiButton button, List buttonList)
|
||||
{
|
||||
super(gui);
|
||||
this.button = button;
|
||||
this.buttonList = new ArrayList(buttonList);
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires once it has been determined that a GuiButton object has been clicked.
|
||||
* Cancel this event to bypass {@code GuiScreen.actionPerformed()}.
|
||||
* Replace button with a different button from buttonList to have that button's action executed.
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
@Cancelable
|
||||
public static class Pre extends ActionPerformedEvent
|
||||
{
|
||||
public Pre(GuiScreen gui, GuiButton button, List buttonList)
|
||||
{
|
||||
super(gui, button, buttonList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This event fires after {@code GuiScreen.actionPerformed()} provided that the active
|
||||
* screen has not been changed as a result of {@code GuiScreen.actionPerformed()}.
|
||||
*
|
||||
* @author bspkrs
|
||||
*/
|
||||
public static class Post extends ActionPerformedEvent
|
||||
{
|
||||
public Post(GuiScreen gui, GuiButton button, List buttonList)
|
||||
{
|
||||
super(gui, button, buttonList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,7 +27,8 @@ public class RenderGameOverlayEvent extends Event
|
|||
HEALTHMOUNT,
|
||||
JUMPBAR,
|
||||
CHAT,
|
||||
PLAYER_LIST
|
||||
PLAYER_LIST,
|
||||
DEBUG
|
||||
}
|
||||
|
||||
public final float partialTicks;
|
||||
|
|
Loading…
Reference in a new issue