57 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.client.model;
 | |
| 
 | |
| import com.mojang.blaze3d.vertex.PoseStack;
 | |
| import com.mojang.blaze3d.vertex.VertexConsumer;
 | |
| import java.util.List;
 | |
| import java.util.function.Function;
 | |
| import net.fabricmc.api.EnvType;
 | |
| import net.fabricmc.api.Environment;
 | |
| import net.minecraft.client.model.geom.ModelPart;
 | |
| import net.minecraft.client.renderer.RenderType;
 | |
| import net.minecraft.resources.ResourceLocation;
 | |
| 
 | |
| @Environment(EnvType.CLIENT)
 | |
| public abstract class Model {
 | |
| 	protected final ModelPart root;
 | |
| 	protected final Function<ResourceLocation, RenderType> renderType;
 | |
| 	private final List<ModelPart> allParts;
 | |
| 
 | |
| 	public Model(ModelPart root, Function<ResourceLocation, RenderType> renderType) {
 | |
| 		this.root = root;
 | |
| 		this.renderType = renderType;
 | |
| 		this.allParts = root.getAllParts();
 | |
| 	}
 | |
| 
 | |
| 	public final RenderType renderType(ResourceLocation location) {
 | |
| 		return (RenderType)this.renderType.apply(location);
 | |
| 	}
 | |
| 
 | |
| 	public final void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay, int color) {
 | |
| 		this.root().render(poseStack, buffer, packedLight, packedOverlay, color);
 | |
| 	}
 | |
| 
 | |
| 	public final void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay) {
 | |
| 		this.renderToBuffer(poseStack, buffer, packedLight, packedOverlay, -1);
 | |
| 	}
 | |
| 
 | |
| 	public final ModelPart root() {
 | |
| 		return this.root;
 | |
| 	}
 | |
| 
 | |
| 	public final List<ModelPart> allParts() {
 | |
| 		return this.allParts;
 | |
| 	}
 | |
| 
 | |
| 	public final void resetPose() {
 | |
| 		for (ModelPart modelPart : this.allParts) {
 | |
| 			modelPart.resetPose();
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	@Environment(EnvType.CLIENT)
 | |
| 	public static class Simple extends Model {
 | |
| 		public Simple(ModelPart root, Function<ResourceLocation, RenderType> renderType) {
 | |
| 			super(root, renderType);
 | |
| 		}
 | |
| 	}
 | |
| }
 |