From 306af4feee2d2eea48dbdefa754a088c00319353 Mon Sep 17 00:00:00 2001 From: Flan Date: Fri, 8 May 2015 15:31:23 +0100 Subject: [PATCH] Added CameraSetup sub-event for camera angles Allows players to alter yaw and pitch of renderViewEntity, but more importantly, adds the ability to roll the view. Added camera roll hook --- .../client/renderer/EntityRenderer.java.patch | 50 +++++++++++++++---- .../client/event/EntityViewRenderEvent.java | 18 +++++++ 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch index d6cf9bf11..657aa973d 100644 --- a/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/EntityRenderer.java.patch @@ -25,7 +25,35 @@ GlStateManager.func_179114_b(entity.field_70126_B + (entity.field_70177_z - entity.field_70126_B) * p_78467_1_ + 180.0F, 0.0F, -1.0F, 0.0F); GlStateManager.func_179114_b(entity.field_70127_C + (entity.field_70125_A - entity.field_70127_C) * p_78467_1_, -1.0F, 0.0F, 0.0F); } -@@ -1081,7 +1075,7 @@ +@@ -630,17 +624,20 @@ + + if (!this.field_78531_r.field_71474_y.field_74325_U) + { +- GlStateManager.func_179114_b(entity.field_70127_C + (entity.field_70125_A - entity.field_70127_C) * p_78467_1_, 1.0F, 0.0F, 0.0F); +- ++ float yaw = entity.field_70126_B + (entity.field_70177_z - entity.field_70126_B) * p_78467_1_ + 180.0F; ++ float pitch = entity.field_70127_C + (entity.field_70125_A - entity.field_70127_C) * p_78467_1_; ++ float roll = 0.0F; + if (entity instanceof EntityAnimal) + { + EntityAnimal entityanimal = (EntityAnimal)entity; +- GlStateManager.func_179114_b(entityanimal.field_70758_at + (entityanimal.field_70759_as - entityanimal.field_70758_at) * p_78467_1_ + 180.0F, 0.0F, 1.0F, 0.0F); ++ yaw = entityanimal.field_70758_at + (entityanimal.field_70759_as - entityanimal.field_70758_at) * p_78467_1_ + 180.0F; + } +- else +- { +- GlStateManager.func_179114_b(entity.field_70126_B + (entity.field_70177_z - entity.field_70126_B) * p_78467_1_ + 180.0F, 0.0F, 1.0F, 0.0F); +- } ++ Block block = ActiveRenderInfo.func_180786_a(this.field_78531_r.field_71441_e, entity, p_78467_1_); ++ net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup event = new net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup(this, entity, block, p_78467_1_, yaw, pitch, roll); ++ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event); ++ GlStateManager.func_179114_b(event.roll, 0.0F, 0.0F, 1.0F); ++ GlStateManager.func_179114_b(event.pitch, 1.0F, 0.0F, 0.0F); ++ GlStateManager.func_179114_b(event.yaw, 0.0F, 1.0F, 0.0F); + } + + GlStateManager.func_179109_b(0.0F, -f1, 0.0F); +@@ -1081,7 +1078,7 @@ try { @@ -34,7 +62,7 @@ } catch (Throwable throwable) { -@@ -1145,7 +1139,7 @@ +@@ -1145,7 +1142,7 @@ if (this.field_78531_r.field_71442_b.func_178889_l() == WorldSettings.GameType.SPECTATOR) { @@ -43,7 +71,7 @@ } else { -@@ -1296,7 +1290,9 @@ +@@ -1296,7 +1293,9 @@ GlStateManager.func_179094_E(); RenderHelper.func_74519_b(); this.field_78531_r.field_71424_I.func_76318_c("entities"); @@ -53,7 +81,7 @@ RenderHelper.func_74518_a(); this.func_175072_h(); GlStateManager.func_179128_n(5888); -@@ -1308,6 +1304,7 @@ +@@ -1308,6 +1307,7 @@ entityplayer = (EntityPlayer)entity; GlStateManager.func_179118_c(); this.field_78531_r.field_71424_I.func_76318_c("outline"); @@ -61,7 +89,7 @@ renderglobal.func_72731_b(entityplayer, this.field_78531_r.field_71476_x, 0, p_175068_2_); GlStateManager.func_179141_d(); } -@@ -1321,6 +1318,7 @@ +@@ -1321,6 +1321,7 @@ entityplayer = (EntityPlayer)entity; GlStateManager.func_179118_c(); this.field_78531_r.field_71424_I.func_76318_c("outline"); @@ -69,7 +97,7 @@ renderglobal.func_72731_b(entityplayer, this.field_78531_r.field_71476_x, 0, p_175068_2_); GlStateManager.func_179141_d(); } -@@ -1373,6 +1371,16 @@ +@@ -1373,6 +1374,16 @@ renderglobal.func_174977_a(EnumWorldBlockLayer.TRANSLUCENT, (double)p_175068_2_, p_175068_1_, entity); } @@ -86,7 +114,7 @@ GlStateManager.func_179103_j(7424); GlStateManager.func_179132_a(true); GlStateManager.func_179089_o(); -@@ -1385,8 +1393,12 @@ +@@ -1385,8 +1396,12 @@ this.func_180437_a(renderglobal, p_175068_2_, p_175068_1_); } @@ -99,7 +127,7 @@ if (this.field_175074_C) { GlStateManager.func_179086_m(256); -@@ -1498,6 +1510,13 @@ +@@ -1498,6 +1513,13 @@ protected void func_78474_d(float p_78474_1_) { @@ -113,7 +141,7 @@ float f1 = this.field_78531_r.field_71441_e.func_72867_j(p_78474_1_); if (f1 > 0.0F) -@@ -1835,6 +1854,13 @@ +@@ -1835,6 +1857,13 @@ this.field_175081_S = f8; } @@ -127,7 +155,7 @@ GlStateManager.func_179082_a(this.field_175080_Q, this.field_175082_R, this.field_175081_S, 0.0F); } -@@ -1854,6 +1880,10 @@ +@@ -1854,6 +1883,10 @@ Block block = ActiveRenderInfo.func_180786_a(this.field_78531_r.field_71441_e, entity, p_78468_2_); float f1; @@ -138,7 +166,7 @@ if (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).func_70644_a(Potion.field_76440_q)) { f1 = 5.0F; -@@ -1931,6 +1961,7 @@ +@@ -1931,6 +1964,7 @@ GlStateManager.func_179102_b(f1 * 0.05F); GlStateManager.func_179153_c(Math.min(f1, 192.0F) * 0.5F); } diff --git a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java index 1979a1e03..4dfd78301 100644 --- a/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java +++ b/src/main/java/net/minecraftforge/client/event/EntityViewRenderEvent.java @@ -78,4 +78,22 @@ public abstract class EntityViewRenderEvent extends Event this.blue = blue; } } + + /** + * Event that allows mods to alter the angles of the player's camera. Mainly useful for applying roll. + */ + public static class CameraSetup extends EntityViewRenderEvent + { + public float yaw; + public float pitch; + public float roll; + + public CameraSetup(EntityRenderer renderer, Entity entity, Block block, double renderPartialTicks, float yaw, float pitch, float roll) + { + super(renderer, entity, block, renderPartialTicks); + this.yaw = yaw; + this.pitch = pitch; + this.roll = roll; + } + } }