| 1 | package net.minecraft.client.renderer.entity.layers;
|
| 2 |
|
| 3 | import com.google.common.collect.Maps;
|
| 4 | import com.mojang.blaze3d.vertex.PoseStack;
|
| 5 | import java.util.Map;
|
| 6 | import net.fabricmc.api.EnvType;
|
| 7 | import net.fabricmc.api.Environment;
|
| 8 | import net.minecraft.client.model.animal.equine.HorseModel;
|
| 9 | import net.minecraft.client.renderer.SubmitNodeCollector;
|
| 10 | import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
| 11 | import net.minecraft.client.renderer.entity.RenderLayerParent;
|
| 12 | import net.minecraft.client.renderer.entity.state.HorseRenderState;
|
| 13 | import net.minecraft.client.renderer.rendertype.RenderTypes;
|
| 14 | import net.minecraft.resources.Identifier;
|
| 15 | import net.minecraft.world.entity.animal.equine.Markings;
|
| 16 |
|
| 17 | @Environment(EnvType.CLIENT)
|
| 18 | public class HorseMarkingLayer extends RenderLayer<HorseRenderState, HorseModel> {
|
| 19 | private static final Identifier INVISIBLE_TEXTURE = Identifier.withDefaultNamespace("invisible");
|
| 20 | private static final Map<Markings, HorseMarkingLayer.HorseMarkingTextures> LOCATION_BY_MARKINGS = Maps.newEnumMap(
|
| 21 | Map.of(
|
| 22 | Markings.NONE,
|
| 23 | new HorseMarkingLayer.HorseMarkingTextures(INVISIBLE_TEXTURE, INVISIBLE_TEXTURE),
|
| 24 | Markings.WHITE,
|
| 25 | new HorseMarkingLayer.HorseMarkingTextures(
|
| 26 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_white.png"),
|
| 27 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_white_baby.png")
|
| 28 | ),
|
| 29 | Markings.WHITE_FIELD,
|
| 30 | new HorseMarkingLayer.HorseMarkingTextures(
|
| 31 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_whitefield.png"),
|
| 32 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_whitefield_baby.png")
|
| 33 | ),
|
| 34 | Markings.WHITE_DOTS,
|
| 35 | new HorseMarkingLayer.HorseMarkingTextures(
|
| 36 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_whitedots.png"),
|
| 37 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_whitedots_baby.png")
|
| 38 | ),
|
| 39 | Markings.BLACK_DOTS,
|
| 40 | new HorseMarkingLayer.HorseMarkingTextures(
|
| 41 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_blackdots.png"),
|
| 42 | Identifier.withDefaultNamespace("textures/entity/horse/horse_markings_blackdots_baby.png")
|
| 43 | )
|
| 44 | )
|
| 45 | );
|
| 46 |
|
| 47 | public HorseMarkingLayer(final RenderLayerParent<HorseRenderState, HorseModel> renderer) {
|
| 48 | super(renderer);
|
| 49 | }
|
| 50 |
|
| 51 | public void submit(
|
| 52 | final PoseStack poseStack,
|
| 53 | final SubmitNodeCollector submitNodeCollector,
|
| 54 | final int lightCoords,
|
| 55 | final HorseRenderState state,
|
| 56 | final float yRot,
|
| 57 | final float xRot
|
| 58 | ) {
|
| 59 | HorseMarkingLayer.HorseMarkingTextures variant = LOCATION_BY_MARKINGS.get(state.markings);
|
| 60 | Identifier texture = state.isBaby ? variant.baby : variant.adult;
|
| 61 | if (texture != INVISIBLE_TEXTURE && !state.isInvisible) {
|
| 62 | submitNodeCollector.order(1)
|
| 63 | .submitModel(
|
| 64 | this.getParentModel(),
|
| 65 | state,
|
| 66 | poseStack,
|
| 67 | RenderTypes.entityTranslucent(texture),
|
| 68 | lightCoords,
|
| 69 | LivingEntityRenderer.getOverlayCoords(state, 0.0F),
|
| 70 | state.outlineColor
|
| 71 | );
|
| 72 | }
|
| 73 | }
|
| 74 |
|
| 75 | @Environment(EnvType.CLIENT)
|
| 76 | private record HorseMarkingTextures(Identifier adult, Identifier baby) {
|
| 77 | }
|
| 78 | }
|
| 79 |
|