51 lines
2.3 KiB
Java
51 lines
2.3 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.resources.ResourceLocation;
|
|
import net.minecraft.world.entity.animal.horse.Horse;
|
|
import net.minecraft.world.entity.animal.horse.Markings;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class HorseMarkingLayer extends RenderLayer<Horse, HorseModel<Horse>> {
|
|
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<Horse, HorseModel<Horse>> renderer) {
|
|
super(renderer);
|
|
}
|
|
|
|
public void render(
|
|
PoseStack poseStack,
|
|
MultiBufferSource buffer,
|
|
int packedLight,
|
|
Horse livingEntity,
|
|
float limbSwing,
|
|
float limbSwingAmount,
|
|
float partialTicks,
|
|
float ageInTicks,
|
|
float netHeadYaw,
|
|
float headPitch
|
|
) {
|
|
ResourceLocation resourceLocation = (ResourceLocation)LOCATION_BY_MARKINGS.get(livingEntity.getMarkings());
|
|
if (resourceLocation != null && !livingEntity.isInvisible()) {
|
|
VertexConsumer vertexConsumer = buffer.getBuffer(RenderType.entityTranslucent(resourceLocation));
|
|
this.getParentModel().renderToBuffer(poseStack, vertexConsumer, packedLight, LivingEntityRenderer.getOverlayCoords(livingEntity, 0.0F));
|
|
}
|
|
}
|
|
}
|