Add renderer to RenderNameplateEvent (#6562)
This commit is contained in:
parent
f6cb5268a2
commit
2f5172f907
2 changed files with 35 additions and 2 deletions
|
@ -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_) {
|
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_)) {
|
- if (this.func_177070_b(p_225623_1_)) {
|
||||||
- this.func_225629_a_(p_225623_1_, p_225623_1_.func_145748_c_().func_150254_d(), p_225623_4_, p_225623_5_, p_225623_6_);
|
- this.func_225629_a_(p_225623_1_, p_225623_1_.func_145748_c_().func_150254_d(), 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_().func_150254_d(), p_225623_4_, p_225623_5_);
|
+ net.minecraftforge.client.event.RenderNameplateEvent renderNameplateEvent = new net.minecraftforge.client.event.RenderNameplateEvent(p_225623_1_, p_225623_1_.func_145748_c_().func_150254_d(), this, p_225623_4_, p_225623_5_, p_225623_6_);
|
||||||
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(renderNameplateEvent);
|
+ 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_))) {
|
+ 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_);
|
+ this.func_225629_a_(p_225623_1_, renderNameplateEvent.getContent(), p_225623_4_, p_225623_5_, p_225623_6_);
|
||||||
|
|
|
@ -19,8 +19,11 @@
|
||||||
|
|
||||||
package net.minecraftforge.client.event;
|
package net.minecraftforge.client.event;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||||
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.EntityEvent;
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
@ -32,10 +35,13 @@ import net.minecraftforge.eventbus.api.Event;
|
||||||
* {@link #nameplateContent} contains the content being rendered on the name plate/tag. This can be changed by mods.<br>
|
* {@link #nameplateContent} contains the content being rendered on the name plate/tag. This can be changed by mods.<br>
|
||||||
* {@link #originalContent} contains the original content being rendered on the name plate/tag. This cannot be
|
* {@link #originalContent} contains the original content being rendered on the name plate/tag. This cannot be
|
||||||
* changed by mods.<br>
|
* changed by mods.<br>
|
||||||
|
* {@link #entityRenderer} contains the entity renderer instance that renders the name plate/tag. This cannot be
|
||||||
|
* changed by mods.<br>
|
||||||
* {@link #matrixStack} contains the matrix stack instance involved in rendering the name plate/tag. This cannot
|
* {@link #matrixStack} contains the matrix stack instance involved in rendering the name plate/tag. This cannot
|
||||||
* be changed by mods.<br>
|
* be changed by mods.<br>
|
||||||
* {@link #renderTypeBuffer} contains the render type buffer instance involved in rendering the name plate/tag.
|
* {@link #renderTypeBuffer} contains the render type buffer instance involved in rendering the name plate/tag.
|
||||||
* This cannot be changed by mods.<br>
|
* This cannot be changed by mods.<br>
|
||||||
|
* {@link #packedLight} contains the sky and block light values used in rendering the name plate/tag.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* This event has a result. {@link HasResult}. <br>
|
* This event has a result. {@link HasResult}. <br>
|
||||||
* ALLOW will force-render name plate/tag, DEFAULT will ignore the hook and continue using the vanilla check
|
* ALLOW will force-render name plate/tag, DEFAULT will ignore the hook and continue using the vanilla check
|
||||||
|
@ -49,16 +55,26 @@ public class RenderNameplateEvent extends EntityEvent
|
||||||
|
|
||||||
private String nameplateContent;
|
private String nameplateContent;
|
||||||
private final String originalContent;
|
private final String originalContent;
|
||||||
|
private final EntityRenderer<?> entityRenderer;
|
||||||
private final MatrixStack matrixStack;
|
private final MatrixStack matrixStack;
|
||||||
private final IRenderTypeBuffer renderTypeBuffer;
|
private final IRenderTypeBuffer renderTypeBuffer;
|
||||||
|
private final int packedLight;
|
||||||
|
|
||||||
|
@Deprecated //TODO 1.16: upon removal, also remove @Nullable on getEntityRenderer(), and update its javadoc
|
||||||
public RenderNameplateEvent(Entity entity, String content, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer)
|
public RenderNameplateEvent(Entity entity, String content, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer)
|
||||||
|
{
|
||||||
|
this(entity, content, null, matrixStack, renderTypeBuffer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RenderNameplateEvent(Entity entity, String content, EntityRenderer<?> entityRenderer, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int packedLight)
|
||||||
{
|
{
|
||||||
super(entity);
|
super(entity);
|
||||||
this.originalContent = content;
|
this.originalContent = content;
|
||||||
this.setContent(this.originalContent);
|
this.setContent(this.originalContent);
|
||||||
|
this.entityRenderer = entityRenderer;
|
||||||
this.matrixStack = matrixStack;
|
this.matrixStack = matrixStack;
|
||||||
this.renderTypeBuffer = renderTypeBuffer;
|
this.renderTypeBuffer = renderTypeBuffer;
|
||||||
|
this.packedLight = packedLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,6 +101,15 @@ public class RenderNameplateEvent extends EntityEvent
|
||||||
return this.originalContent;
|
return this.originalContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The entity renderer that renders the name plate/tag, if it was provided
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public EntityRenderer<?> getEntityRenderer()
|
||||||
|
{
|
||||||
|
return this.entityRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The matrix stack used during the rendering of the name plate/tag
|
* The matrix stack used during the rendering of the name plate/tag
|
||||||
*/
|
*/
|
||||||
|
@ -100,4 +125,12 @@ public class RenderNameplateEvent extends EntityEvent
|
||||||
{
|
{
|
||||||
return this.renderTypeBuffer;
|
return this.renderTypeBuffer;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* The packed values of sky and block light used during the rendering of the name plate/tag
|
||||||
|
*/
|
||||||
|
public int getPackedLight()
|
||||||
|
{
|
||||||
|
return this.packedLight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue