HorseRenderer .java

net.minecraft.client.renderer.entity.HorseRenderer (class, 103 lines): members: LOCATION_BY_VARIANT, HorseTextures, getTextureLocation, createRenderState.

net.minecraft.client.renderer.entityclass103 linesclientextends AbstractHorseRenderer<Horse4.0 KB

API Surface (3)

Identifier getTextureLocation(final HorseRenderState state)
HorseRenderState createRenderState()
void extractRenderState(final Horse entity, final HorseRenderState state, final float partialTicks)

Fields & Constants (1)

LOCATION_BY_VARIANT

String literals (14)

"textures/entity/horse/horse_white.png"
"textures/entity/horse/horse_white_baby.png"
"textures/entity/horse/horse_creamy.png"
"textures/entity/horse/horse_creamy_baby.png"
"textures/entity/horse/horse_chestnut.png"
"textures/entity/horse/horse_chestnut_baby.png"
"textures/entity/horse/horse_brown.png"
"textures/entity/horse/horse_brown_baby.png"
"textures/entity/horse/horse_black.png"
"textures/entity/horse/horse_black_baby.png"
"textures/entity/horse/horse_gray.png"
"textures/entity/horse/horse_gray_baby.png"
"textures/entity/horse/horse_darkbrown.png"
"textures/entity/horse/horse_darkbrown_baby.png"

Full Source

HorseRenderer.java103 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.renderer.entity;
2
3
import com.google.common.collect.Maps;
4
import java.util.Map;
5
import net.fabricmc.api.EnvType;
6
import net.fabricmc.api.Environment;
7
import net.minecraft.client.model.animal.equine.BabyHorseModel;
8
import net.minecraft.client.model.animal.equine.EquineSaddleModel;
9
import net.minecraft.client.model.animal.equine.HorseModel;
10
import net.minecraft.client.model.geom.ModelLayers;
11
import net.minecraft.client.renderer.entity.layers.HorseMarkingLayer;
12
import net.minecraft.client.renderer.entity.layers.SimpleEquipmentLayer;
13
import net.minecraft.client.renderer.entity.state.HorseRenderState;
14
import net.minecraft.client.resources.model.EquipmentClientInfo;
15
import net.minecraft.resources.Identifier;
16
import net.minecraft.world.entity.animal.equine.Horse;
17
import net.minecraft.world.entity.animal.equine.Variant;
18
19
@Environment(EnvType.CLIENT)
20
public final class HorseRenderer extends AbstractHorseRenderer<Horse, HorseRenderState, HorseModel> {
21
	private static final Map<Variant, HorseRenderer.HorseTextures> LOCATION_BY_VARIANT = Maps.newEnumMap(
22
		Map.of(
23
			Variant.WHITE,
24
			new HorseRenderer.HorseTextures(
25
				Identifier.withDefaultNamespace("textures/entity/horse/horse_white.png"), Identifier.withDefaultNamespace("textures/entity/horse/horse_white_baby.png")
26
			),
27
			Variant.CREAMY,
28
			new HorseRenderer.HorseTextures(
29
				Identifier.withDefaultNamespace("textures/entity/horse/horse_creamy.png"), Identifier.withDefaultNamespace("textures/entity/horse/horse_creamy_baby.png")
30
			),
31
			Variant.CHESTNUT,
32
			new HorseRenderer.HorseTextures(
33
				Identifier.withDefaultNamespace("textures/entity/horse/horse_chestnut.png"),
34
				Identifier.withDefaultNamespace("textures/entity/horse/horse_chestnut_baby.png")
35
			),
36
			Variant.BROWN,
37
			new HorseRenderer.HorseTextures(
38
				Identifier.withDefaultNamespace("textures/entity/horse/horse_brown.png"), Identifier.withDefaultNamespace("textures/entity/horse/horse_brown_baby.png")
39
			),
40
			Variant.BLACK,
41
			new HorseRenderer.HorseTextures(
42
				Identifier.withDefaultNamespace("textures/entity/horse/horse_black.png"), Identifier.withDefaultNamespace("textures/entity/horse/horse_black_baby.png")
43
			),
44
			Variant.GRAY,
45
			new HorseRenderer.HorseTextures(
46
				Identifier.withDefaultNamespace("textures/entity/horse/horse_gray.png"), Identifier.withDefaultNamespace("textures/entity/horse/horse_gray_baby.png")
47
			),
48
			Variant.DARK_BROWN,
49
			new HorseRenderer.HorseTextures(
50
				Identifier.withDefaultNamespace("textures/entity/horse/horse_darkbrown.png"),
51
				Identifier.withDefaultNamespace("textures/entity/horse/horse_darkbrown_baby.png")
52
			)
53
		)
54
	);
55
56
	public HorseRenderer(final EntityRendererProvider.Context context) {
57
		super(context, new HorseModel(context.bakeLayer(ModelLayers.HORSE)), new BabyHorseModel(context.bakeLayer(ModelLayers.HORSE_BABY)));
58
		this.addLayer(new HorseMarkingLayer(this));
59
		this.addLayer(
60
			new SimpleEquipmentLayer<>(
61
				this,
62
				context.getEquipmentRenderer(),
63
				EquipmentClientInfo.LayerType.HORSE_BODY,
64
				state -> state.bodyArmorItem,
65
				new HorseModel(context.bakeLayer(ModelLayers.HORSE_ARMOR)),
66
				null,
67
				2
68
			)
69
		);
70
		this.addLayer(
71
			new SimpleEquipmentLayer<>(
72
				this,
73
				context.getEquipmentRenderer(),
74
				EquipmentClientInfo.LayerType.HORSE_SADDLE,
75
				state -> state.saddle,
76
				new EquineSaddleModel(context.bakeLayer(ModelLayers.HORSE_SADDLE)),
77
				null,
78
				2
79
			)
80
		);
81
	}
82
83
	public Identifier getTextureLocation(final HorseRenderState state) {
84
		HorseRenderer.HorseTextures variant = LOCATION_BY_VARIANT.get(state.variant);
85
		return state.isBaby ? variant.baby : variant.adult;
86
	}
87
88
	public HorseRenderState createRenderState() {
89
		return new HorseRenderState();
90
	}
91
92
	public void extractRenderState(final Horse entity, final HorseRenderState state, final float partialTicks) {
93
		super.extractRenderState(entity, state, partialTicks);
94
		state.variant = entity.getVariant();
95
		state.markings = entity.getMarkings();
96
		state.bodyArmorItem = entity.getBodyArmorItem().copy();
97
	}
98
99
	@Environment(EnvType.CLIENT)
100
	private record HorseTextures(Identifier adult, Identifier baby) {
101
	}
102
}
103

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