package net.minecraft.client.renderer.blockentity; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderType; import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context; 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 org.joml.Matrix4f; @Environment(EnvType.CLIENT) public class TheEndPortalRenderer implements BlockEntityRenderer { 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(Context context) { } public void render(T theEndPortalBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j, Vec3 vec3) { Matrix4f matrix4f = poseStack.last().pose(); this.renderCube(theEndPortalBlockEntity, matrix4f, multiBufferSource.getBuffer(this.renderType())); } private void renderCube(T blockEntity, Matrix4f pose, VertexConsumer consumer) { float f = this.getOffsetDown(); float g = this.getOffsetUp(); this.renderFace(blockEntity, pose, consumer, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, Direction.SOUTH); this.renderFace(blockEntity, pose, consumer, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, Direction.NORTH); this.renderFace(blockEntity, pose, consumer, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, Direction.EAST); this.renderFace(blockEntity, pose, consumer, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, Direction.WEST); this.renderFace(blockEntity, pose, consumer, 0.0F, 1.0F, f, f, 0.0F, 0.0F, 1.0F, 1.0F, Direction.DOWN); this.renderFace(blockEntity, pose, consumer, 0.0F, 1.0F, g, g, 1.0F, 1.0F, 0.0F, 0.0F, Direction.UP); } private void renderFace( T blockEntity, Matrix4f pose, VertexConsumer consumer, float x0, float x1, float y0, float y1, float z0, float z1, float z2, float z3, Direction direction ) { if (blockEntity.shouldRenderFace(direction)) { consumer.addVertex(pose, x0, y0, z0); consumer.addVertex(pose, x1, y0, z1); consumer.addVertex(pose, x1, y1, z2); consumer.addVertex(pose, x0, y1, z3); } } protected float getOffsetUp() { return 0.75F; } protected float getOffsetDown() { return 0.375F; } protected RenderType renderType() { return RenderType.endPortal(); } }