61 lines
		
	
	
	
		
			2.7 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
	
		
			2.7 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| 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.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<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 context) {
 | |
| 	}
 | |
| 
 | |
| 	public void render(T blockEntity, float partialTick, PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, int packedOverlay, Vec3 cameraPos) {
 | |
| 		Matrix4f matrix4f = poseStack.last().pose();
 | |
| 		this.renderCube(blockEntity, matrix4f, bufferSource.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();
 | |
| 	}
 | |
| }
 |