ResolvedModel .java

net.minecraft.client.resources.model.ResolvedModel (interface, 136 lines): members: DEFAULT_AMBIENT_OCCLUSION, findTopAmbientOcclusion, getTopTextureSlots.

net.minecraft.client.resources.modelinterface136 linesclientextends ModelDebugName4.5 KB

API Surface (0)

No public/protected methods detected (fields or constants only).

Fields & Constants (2)

DEFAULT_AMBIENT_OCCLUSION
DEFAULT_GUI_LIGHT

String literals (1)

"particle"

Full Source

ResolvedModel.java136 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.resources.model;
2
3
import net.fabricmc.api.EnvType;
4
import net.fabricmc.api.Environment;
5
import net.minecraft.client.renderer.block.dispatch.ModelState;
6
import net.minecraft.client.resources.model.cuboid.ItemTransform;
7
import net.minecraft.client.resources.model.cuboid.ItemTransforms;
8
import net.minecraft.client.resources.model.geometry.QuadCollection;
9
import net.minecraft.client.resources.model.geometry.UnbakedGeometry;
10
import net.minecraft.client.resources.model.sprite.Material;
11
import net.minecraft.client.resources.model.sprite.TextureSlots;
12
import net.minecraft.world.item.ItemDisplayContext;
13
import org.jspecify.annotations.Nullable;
14
15
@Environment(EnvType.CLIENT)
16
public interface ResolvedModel extends ModelDebugName {
17
	boolean DEFAULT_AMBIENT_OCCLUSION = true;
18
	UnbakedModel.GuiLight DEFAULT_GUI_LIGHT = UnbakedModel.GuiLight.SIDE;
19
20
	UnbakedModel wrapped();
21
22
	@Nullable ResolvedModel parent();
23
24
	static TextureSlots findTopTextureSlots(final ResolvedModel top) {
25
		ResolvedModel current = top;
26
		TextureSlots.Resolver resolver = new TextureSlots.Resolver();
27
28
		while (current != null) {
29
			resolver.addLast(current.wrapped().textureSlots());
30
			current = current.parent();
31
		}
32
33
		return resolver.resolve(top);
34
	}
35
36
	default TextureSlots getTopTextureSlots() {
37
		return findTopTextureSlots(this);
38
	}
39
40
	static boolean findTopAmbientOcclusion(ResolvedModel current) {
41
		while (current != null) {
42
			Boolean hasAmbientOcclusion = current.wrapped().ambientOcclusion();
43
			if (hasAmbientOcclusion != null) {
44
				return hasAmbientOcclusion;
45
			}
46
47
			current = current.parent();
48
		}
49
50
		return true;
51
	}
52
53
	default boolean getTopAmbientOcclusion() {
54
		return findTopAmbientOcclusion(this);
55
	}
56
57
	static UnbakedModel.GuiLight findTopGuiLight(ResolvedModel current) {
58
		while (current != null) {
59
			UnbakedModel.GuiLight guiLight = current.wrapped().guiLight();
60
			if (guiLight != null) {
61
				return guiLight;
62
			}
63
64
			current = current.parent();
65
		}
66
67
		return DEFAULT_GUI_LIGHT;
68
	}
69
70
	default UnbakedModel.GuiLight getTopGuiLight() {
71
		return findTopGuiLight(this);
72
	}
73
74
	static UnbakedGeometry findTopGeometry(ResolvedModel current) {
75
		while (current != null) {
76
			UnbakedGeometry geometry = current.wrapped().geometry();
77
			if (geometry != null) {
78
				return geometry;
79
			}
80
81
			current = current.parent();
82
		}
83
84
		return UnbakedGeometry.EMPTY;
85
	}
86
87
	default UnbakedGeometry getTopGeometry() {
88
		return findTopGeometry(this);
89
	}
90
91
	default QuadCollection bakeTopGeometry(final TextureSlots textureSlots, final ModelBaker baker, final ModelState state) {
92
		return this.getTopGeometry().bake(textureSlots, baker, state, this);
93
	}
94
95
	static Material.Baked resolveParticleMaterial(final TextureSlots textureSlots, final ModelBaker baker, final ModelDebugName resolvedModel) {
96
		return baker.materials().resolveSlot(textureSlots, "particle", resolvedModel);
97
	}
98
99
	default Material.Baked resolveParticleMaterial(final TextureSlots textureSlots, final ModelBaker baker) {
100
		return resolveParticleMaterial(textureSlots, baker, this);
101
	}
102
103
	static ItemTransform findTopTransform(ResolvedModel current, final ItemDisplayContext type) {
104
		while (current != null) {
105
			ItemTransforms transforms = current.wrapped().transforms();
106
			if (transforms != null) {
107
				ItemTransform transform = transforms.getTransform(type);
108
				if (transform != ItemTransform.NO_TRANSFORM) {
109
					return transform;
110
				}
111
			}
112
113
			current = current.parent();
114
		}
115
116
		return ItemTransform.NO_TRANSFORM;
117
	}
118
119
	static ItemTransforms findTopTransforms(final ResolvedModel top) {
120
		ItemTransform thirdPersonLeftHand = findTopTransform(top, ItemDisplayContext.THIRD_PERSON_LEFT_HAND);
121
		ItemTransform thirdPersonRightHand = findTopTransform(top, ItemDisplayContext.THIRD_PERSON_RIGHT_HAND);
122
		ItemTransform firstPersonLeftHand = findTopTransform(top, ItemDisplayContext.FIRST_PERSON_LEFT_HAND);
123
		ItemTransform firstPersonRightHand = findTopTransform(top, ItemDisplayContext.FIRST_PERSON_RIGHT_HAND);
124
		ItemTransform head = findTopTransform(top, ItemDisplayContext.HEAD);
125
		ItemTransform gui = findTopTransform(top, ItemDisplayContext.GUI);
126
		ItemTransform ground = findTopTransform(top, ItemDisplayContext.GROUND);
127
		ItemTransform fixed = findTopTransform(top, ItemDisplayContext.FIXED);
128
		ItemTransform fixedFromBottom = findTopTransform(top, ItemDisplayContext.ON_SHELF);
129
		return new ItemTransforms(thirdPersonLeftHand, thirdPersonRightHand, firstPersonLeftHand, firstPersonRightHand, head, gui, ground, fixed, fixedFromBottom);
130
	}
131
132
	default ItemTransforms getTopTransforms() {
133
		return findTopTransforms(this);
134
	}
135
}
136

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