ArmorModelSet .java

net.minecraft.client.renderer.entity.ArmorModelSet (record): members: head, chest, legs, feet, putFrom, modelSet, bake, map, get. imports: HumanoidModel.

net.minecraft.client.renderer.entityrecord43 linesclient1.6 KB

API Surface (4)

T get(final EquipmentSlot slot)
<U> ArmorModelSet<U> map(final Function<? super T, ? extends U> mapper)
void putFrom(final ArmorModelSet<LayerDefinition> values, final Builder<T, LayerDefinition> output)
<M extends HumanoidModel<?>> ArmorModelSet<M> bake(final ArmorModelSet<ModelLayerLocation> locations, final EntityModelSet modelSet, final Function<ModelPart, M> factory)

Fields & Constants (1)

modelSet

String literals (1)

"No model for slot: "

Code Graph: Dependencies (6)

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

Full Source

ArmorModelSet.java43 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.entity;
2
3
import com.google.common.collect.ImmutableMap.Builder;
4
import java.util.function.Function;
5
import net.fabricmc.api.EnvType;
6
import net.fabricmc.api.Environment;
7
import net.minecraft.client.model.HumanoidModel;
8
import net.minecraft.client.model.geom.EntityModelSet;
9
import net.minecraft.client.model.geom.ModelLayerLocation;
10
import net.minecraft.client.model.geom.ModelPart;
11
import net.minecraft.client.model.geom.builders.LayerDefinition;
12
import net.minecraft.world.entity.EquipmentSlot;
13
14
@Environment(EnvType.CLIENT)
15
public record ArmorModelSet<T>(T head, T chest, T legs, T feet) {
16
	public T get(final EquipmentSlot slot) {
17
		return (T)(switch (slot) {
18
			case HEAD -> this.head;
19
			case CHEST -> this.chest;
20
			case LEGS -> this.legs;
21
			case FEET -> this.feet;
22
			default -> throw new IllegalStateException("No model for slot: " + slot);
23
		});
24
	}
25
26
	public <U> ArmorModelSet<U> map(final Function<? super T, ? extends U> mapper) {
27
		return (ArmorModelSet<U>)(new ArmorModelSet<>(mapper.apply(this.head), mapper.apply(this.chest), mapper.apply(this.legs), mapper.apply(this.feet)));
28
	}
29
30
	public void putFrom(final ArmorModelSet<LayerDefinition> values, final Builder<T, LayerDefinition> output) {
31
		output.put(this.head, values.head);
32
		output.put(this.chest, values.chest);
33
		output.put(this.legs, values.legs);
34
		output.put(this.feet, values.feet);
35
	}
36
37
	public static <M extends HumanoidModel<?>> ArmorModelSet<M> bake(
38
		final ArmorModelSet<ModelLayerLocation> locations, final EntityModelSet modelSet, final Function<ModelPart, M> factory
39
	) {
40
		return locations.map(id -> factory.apply(modelSet.bakeLayer(id)));
41
	}
42
}
43

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