Model .java

net.minecraft.client.model.Model (class): members: renderToBuffer, allParts, resetPose, Simple, root, renderType, setupAnim. imports: FabricModel, Unit.

net.minecraft.client.modelclass67 linesclient1.9 KB

Implements

API Surface (8)

Function<Identifier, RenderType> renderType()
RenderType renderType(final Identifier texture)
void renderToBuffer(final PoseStack poseStack, final VertexConsumer buffer, final int lightCoords, final int overlayCoords, final int color)
ModelPart root()
List<ModelPart> allParts()
void setupAnim(final S state)
void resetPose()
void setupAnim(final Unit state)

Fields & Constants (3)

root
renderType
allParts

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

Model.java67 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.model;
2
3
import com.mojang.blaze3d.vertex.PoseStack;
4
import com.mojang.blaze3d.vertex.VertexConsumer;
5
import java.util.List;
6
import java.util.function.Function;
7
import net.fabricmc.api.EnvType;
8
import net.fabricmc.api.Environment;
9
import net.fabricmc.fabric.api.client.rendering.v1.FabricModel;
10
import net.minecraft.client.model.geom.ModelPart;
11
import net.minecraft.client.renderer.rendertype.RenderType;
12
import net.minecraft.resources.Identifier;
13
import net.minecraft.util.Unit;
14
15
@Environment(EnvType.CLIENT)
16
public abstract class Model<S> implements FabricModel<S> {
17
	protected final ModelPart root;
18
	protected final Function<Identifier, RenderType> renderType;
19
	private final List<ModelPart> allParts;
20
21
	public Model(final ModelPart root, final Function<Identifier, RenderType> renderType) {
22
		this.root = root;
23
		this.renderType = renderType;
24
		this.allParts = root.getAllParts();
25
	}
26
27
	public final Function<Identifier, RenderType> renderType() {
28
		return this.renderType;
29
	}
30
31
	public final RenderType renderType(final Identifier texture) {
32
		return this.renderType().apply(texture);
33
	}
34
35
	public final void renderToBuffer(final PoseStack poseStack, final VertexConsumer buffer, final int lightCoords, final int overlayCoords, final int color) {
36
		this.root().render(poseStack, buffer, lightCoords, overlayCoords, color);
37
	}
38
39
	public final ModelPart root() {
40
		return this.root;
41
	}
42
43
	public final List<ModelPart> allParts() {
44
		return this.allParts;
45
	}
46
47
	public void setupAnim(final S state) {
48
		this.resetPose();
49
	}
50
51
	public final void resetPose() {
52
		for (ModelPart part : this.allParts) {
53
			part.resetPose();
54
		}
55
	}
56
57
	@Environment(EnvType.CLIENT)
58
	public static class Simple extends Model<Unit> {
59
		public Simple(final ModelPart root, final Function<Identifier, RenderType> renderType) {
60
			super(root, renderType);
61
		}
62
63
		public void setupAnim(final Unit state) {
64
		}
65
	}
66
}
67

Decompiled Minecraft 26.3 source of Model (net/minecraft/client/model/Model.java) with Mojang official mappings, stored verbatim on the site.