mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
Add renderer to RenderNameplateEvent (#6562)
This commit is contained in:
1 parent
f6cb5268a2
commit
2f5172f907
2 files changed
+35
-2
No files matched your search
@@ -19,8 +19,11 @@
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
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 #originalContent} contains the original content being rendered on the name plate/tag. This cannot be
|
||||
* 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
|
||||
* be changed by mods.<br>
|
||||
* {@link #renderTypeBuffer} contains the render type buffer instance involved in rendering the name plate/tag.
|
||||
* 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>
|
||||
* 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
|
||||
@@ -49,16 +55,26 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
|
||||
private String nameplateContent;
|
||||
private final String originalContent;
|
||||
private final EntityRenderer<?> entityRenderer;
|
||||
private final MatrixStack matrixStack;
|
||||
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)
|
||||
{
|
||||
this(entity, content, null, matrixStack, renderTypeBuffer, 0);
|
||||
}
|
||||
|
||||
public RenderNameplateEvent(Entity entity, String content, EntityRenderer<?> entityRenderer, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer, int packedLight)
|
||||
{
|
||||
super(entity);
|
||||
this.originalContent = content;
|
||||
this.setContent(this.originalContent);
|
||||
this.entityRenderer = entityRenderer;
|
||||
this.matrixStack = matrixStack;
|
||||
this.renderTypeBuffer = renderTypeBuffer;
|
||||
this.packedLight = packedLight;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,6 +101,15 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
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
|
||||
*/
|
||||
@@ -100,4 +125,12 @@ public class RenderNameplateEvent extends EntityEvent
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user