From bd5e1076281252039379eea27ed8f14581e0b5a2 Mon Sep 17 00:00:00 2001 From: Tschipp Date: Tue, 8 Sep 2020 22:24:02 +0200 Subject: [PATCH] Add partialTicks to RenderNameplateEvent (#7277) --- .../renderer/entity/EntityRenderer.java.patch | 2 +- .../client/event/RenderNameplateEvent.java | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch index fdf723bf3..11e2ace78 100644 --- a/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/entity/EntityRenderer.java.patch @@ -6,7 +6,7 @@ public void func_225623_a_(T p_225623_1_, float p_225623_2_, float p_225623_3_, MatrixStack p_225623_4_, IRenderTypeBuffer p_225623_5_, int p_225623_6_) { - if (this.func_177070_b(p_225623_1_)) { - this.func_225629_a_(p_225623_1_, p_225623_1_.func_145748_c_(), p_225623_4_, p_225623_5_, p_225623_6_); -+ net.minecraftforge.client.event.RenderNameplateEvent renderNameplateEvent = new net.minecraftforge.client.event.RenderNameplateEvent(p_225623_1_, p_225623_1_.func_145748_c_(), this, p_225623_4_, p_225623_5_, p_225623_6_); ++ net.minecraftforge.client.event.RenderNameplateEvent renderNameplateEvent = new net.minecraftforge.client.event.RenderNameplateEvent(p_225623_1_, p_225623_1_.func_145748_c_(), this, p_225623_4_, p_225623_5_, p_225623_6_, p_225623_3_); + net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(renderNameplateEvent); + if (renderNameplateEvent.getResult() != net.minecraftforge.eventbus.api.Event.Result.DENY && (renderNameplateEvent.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW || this.func_177070_b(p_225623_1_))) { + this.func_225629_a_(p_225623_1_, renderNameplateEvent.getContent(), p_225623_4_, p_225623_5_, p_225623_6_); diff --git a/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java b/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java index 1d1b16c9a..8b253d8d0 100644 --- a/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java +++ b/src/main/java/net/minecraftforge/client/event/RenderNameplateEvent.java @@ -41,6 +41,7 @@ import net.minecraftforge.eventbus.api.Event; * {@link #renderTypeBuffer} contains the render type buffer instance involved in rendering the name plate/tag. * This cannot be changed by mods.
* {@link #packedLight} contains the sky and block light values used in rendering the name plate/tag.
+ * {@link #partialTicks} contains the partial ticks used in rendering the name plate/tag. This cannot be changed by mods.
*
* This event has a result. {@link HasResult}.
* ALLOW will force-render name plate/tag, DEFAULT will ignore the hook and continue using the vanilla check @@ -58,8 +59,9 @@ public class RenderNameplateEvent extends EntityEvent private final MatrixStack matrixStack; private final IRenderTypeBuffer renderTypeBuffer; private final int packedLight; - - public RenderNameplateEvent(Entity entity, ITextComponent content, EntityRenderer entityRenderer, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int packedLight) + private final float partialTicks; + + public RenderNameplateEvent(Entity entity, ITextComponent content, EntityRenderer entityRenderer, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int packedLight, float partialTicks) { super(entity); this.originalContent = content; @@ -68,6 +70,7 @@ public class RenderNameplateEvent extends EntityEvent this.matrixStack = matrixStack; this.renderTypeBuffer = renderTypeBuffer; this.packedLight = packedLight; + this.partialTicks = partialTicks; } /** @@ -125,4 +128,12 @@ public class RenderNameplateEvent extends EntityEvent { return this.packedLight; } + + /** + * The partial ticks used during the rendering of the name plate/tag + */ + public float getPartialTicks() + { + return this.partialTicks; + } }