Code/net/minecraft/client/renderer/blockentity/TheEndPortalRenderer.java

72 lines
3.1 KiB
Java
Raw Permalink Normal View History

2025-07-01 06:20:03 +00:00
package net.minecraft.client.renderer.blockentity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.entity.TheEndPortalBlockEntity;
import net.minecraft.world.phys.Vec3;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.joml.Matrix4f;
@OnlyIn(Dist.CLIENT)
public class TheEndPortalRenderer<T extends TheEndPortalBlockEntity> implements BlockEntityRenderer<T> {
public static final ResourceLocation END_SKY_LOCATION = ResourceLocation.withDefaultNamespace("textures/environment/end_sky.png");
public static final ResourceLocation END_PORTAL_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/end_portal.png");
public TheEndPortalRenderer(BlockEntityRendererProvider.Context p_173689_) {
}
public void render(T p_112650_, float p_112651_, PoseStack p_112652_, MultiBufferSource p_112653_, int p_112654_, int p_112655_, Vec3 p_395880_) {
Matrix4f matrix4f = p_112652_.last().pose();
this.renderCube(p_112650_, matrix4f, p_112653_.getBuffer(this.renderType()));
}
private void renderCube(T p_173691_, Matrix4f p_254024_, VertexConsumer p_173693_) {
float f = this.getOffsetDown();
float f1 = this.getOffsetUp();
this.renderFace(p_173691_, p_254024_, p_173693_, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, Direction.SOUTH);
this.renderFace(p_173691_, p_254024_, p_173693_, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, Direction.NORTH);
this.renderFace(p_173691_, p_254024_, p_173693_, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, Direction.EAST);
this.renderFace(p_173691_, p_254024_, p_173693_, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, Direction.WEST);
this.renderFace(p_173691_, p_254024_, p_173693_, 0.0F, 1.0F, f, f, 0.0F, 0.0F, 1.0F, 1.0F, Direction.DOWN);
this.renderFace(p_173691_, p_254024_, p_173693_, 0.0F, 1.0F, f1, f1, 1.0F, 1.0F, 0.0F, 0.0F, Direction.UP);
}
private void renderFace(
T p_253949_,
Matrix4f p_254247_,
VertexConsumer p_254390_,
float p_254147_,
float p_253639_,
float p_254107_,
float p_254109_,
float p_254021_,
float p_254458_,
float p_254086_,
float p_254310_,
Direction p_253619_
) {
if (p_253949_.shouldRenderFace(p_253619_)) {
p_254390_.addVertex(p_254247_, p_254147_, p_254107_, p_254021_);
p_254390_.addVertex(p_254247_, p_253639_, p_254107_, p_254458_);
p_254390_.addVertex(p_254247_, p_253639_, p_254109_, p_254086_);
p_254390_.addVertex(p_254247_, p_254147_, p_254109_, p_254310_);
}
}
protected float getOffsetUp() {
return 0.75F;
}
protected float getOffsetDown() {
return 0.375F;
}
protected RenderType renderType() {
return RenderType.endPortal();
}
}