minecraft-src/net/minecraft/client/renderer/entity/layers/HorseMarkingLayer.java
2025-07-04 02:49:36 +03:00

40 lines
2.2 KiB
Java

package net.minecraft.client.renderer.entity.layers;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import java.util.Map;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.Util;
import net.minecraft.client.model.HorseModel;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.LivingEntityRenderer;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.state.HorseRenderState;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.animal.horse.Markings;
@Environment(EnvType.CLIENT)
public class HorseMarkingLayer extends RenderLayer<HorseRenderState, HorseModel> {
private static final Map<Markings, ResourceLocation> LOCATION_BY_MARKINGS = Util.make(Maps.newEnumMap(Markings.class), enumMap -> {
enumMap.put(Markings.NONE, null);
enumMap.put(Markings.WHITE, ResourceLocation.withDefaultNamespace("textures/entity/horse/horse_markings_white.png"));
enumMap.put(Markings.WHITE_FIELD, ResourceLocation.withDefaultNamespace("textures/entity/horse/horse_markings_whitefield.png"));
enumMap.put(Markings.WHITE_DOTS, ResourceLocation.withDefaultNamespace("textures/entity/horse/horse_markings_whitedots.png"));
enumMap.put(Markings.BLACK_DOTS, ResourceLocation.withDefaultNamespace("textures/entity/horse/horse_markings_blackdots.png"));
});
public HorseMarkingLayer(RenderLayerParent<HorseRenderState, HorseModel> renderer) {
super(renderer);
}
public void render(PoseStack poseStack, MultiBufferSource bufferSource, int packedLight, HorseRenderState renderState, float yRot, float xRot) {
ResourceLocation resourceLocation = (ResourceLocation)LOCATION_BY_MARKINGS.get(renderState.markings);
if (resourceLocation != null && !renderState.isInvisible) {
VertexConsumer vertexConsumer = bufferSource.getBuffer(RenderType.entityTranslucent(resourceLocation));
this.getParentModel().renderToBuffer(poseStack, vertexConsumer, packedLight, LivingEntityRenderer.getOverlayCoords(renderState, 0.0F));
}
}
}