mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
[1.15.x] Added entity nameplate rendering event hook (#6416)
This commit is contained in:
1 parent
380366e25f
commit
345387645e
5 files changed
+142
-16
No files matched your search
@@ -28,6 +28,7 @@ import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public abstract class RenderLivingEvent<T extends LivingEntity, M extends EntityModel<T>> extends Event
|
||||
{
|
||||
|
||||
private final LivingEntity entity;
|
||||
private final LivingRenderer<T, M> renderer;
|
||||
private final float partialRenderTick;
|
||||
@@ -51,24 +52,10 @@ public abstract class RenderLivingEvent<T extends LivingEntity, M extends Entity
|
||||
{
|
||||
public Pre(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack){ super(entity, renderer, partialRenderTick, matrixStack); }
|
||||
}
|
||||
|
||||
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
public Post(LivingEntity entity, LivingRenderer<T, M> renderer, float partialRenderTick, MatrixStack matrixStack){ super(entity, renderer, partialRenderTick, matrixStack); }
|
||||
}
|
||||
|
||||
// TODO: 1.15 moved all name rendering to EntityRenderer, such that there's not a Living-specific feature anymore
|
||||
public abstract static class Specials<T extends LivingEntity, M extends EntityModel<T>> extends RenderLivingEvent<T, M>
|
||||
{
|
||||
public Specials(LivingEntity entity, LivingRenderer<T, M> renderer, MatrixStack matrixStack){ super(entity, renderer, 0, matrixStack); }
|
||||
|
||||
@Cancelable
|
||||
public static class Pre<T extends LivingEntity, M extends EntityModel<T>> extends Specials<T, M>
|
||||
{
|
||||
public Pre(LivingEntity entity, LivingRenderer<T, M> renderer, MatrixStack matrixStack){ super(entity, renderer, matrixStack); }
|
||||
}
|
||||
public static class Post<T extends LivingEntity, M extends EntityModel<T>> extends Specials<T, M>
|
||||
{
|
||||
public Post(LivingEntity entity, LivingRenderer<T, M> renderer, MatrixStack matrixStack){ super(entity, renderer, matrixStack); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.entity.EntityEvent;
|
||||
import net.minecraftforge.eventbus.api.Event;
|
||||
|
||||
/**
|
||||
* RenderNameplateEvent is fired whenever the entity renderer attempts to render a name plate/tag of an entity.
|
||||
* <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
|
||||
* 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>
|
||||
* <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
|
||||
* & DENY will prevent name plate/tag from rendering<br>
|
||||
* <br>
|
||||
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
|
||||
**/
|
||||
@Event.HasResult
|
||||
public class RenderNameplateEvent extends EntityEvent
|
||||
{
|
||||
|
||||
private String nameplateContent;
|
||||
private final String originalContent;
|
||||
private final MatrixStack matrixStack;
|
||||
private final IRenderTypeBuffer renderTypeBuffer;
|
||||
|
||||
public RenderNameplateEvent(Entity entity, String content, MatrixStack matrixStack, IRenderTypeBuffer renderTypeBuffer)
|
||||
{
|
||||
super(entity);
|
||||
this.originalContent = content;
|
||||
this.setContent(this.originalContent);
|
||||
this.matrixStack = matrixStack;
|
||||
this.renderTypeBuffer = renderTypeBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content that is to be rendered on the name plate/tag
|
||||
*/
|
||||
public void setContent(String contents)
|
||||
{
|
||||
this.nameplateContent = contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* The content being rendered on the name plate/tag
|
||||
*/
|
||||
public String getContent()
|
||||
{
|
||||
return this.nameplateContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* The original content being rendered on the name plate/tag
|
||||
*/
|
||||
public String getOriginalContent()
|
||||
{
|
||||
return this.originalContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* The matrix stack used during the rendering of the name plate/tag
|
||||
*/
|
||||
public MatrixStack getMatrixStack()
|
||||
{
|
||||
return this.matrixStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* The render type buffer used during the rendering of the name plate/tag
|
||||
*/
|
||||
public IRenderTypeBuffer getRenderTypeBuffer()
|
||||
{
|
||||
return this.renderTypeBuffer;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user