| 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.llama.BabyLlamaModel;
|
| 8 | import net.minecraft.client.model.animal.llama.LlamaModel;
|
| 9 | import net.minecraft.client.model.geom.ModelLayerLocation;
|
| 10 | import net.minecraft.client.renderer.entity.layers.LlamaDecorLayer;
|
| 11 | import net.minecraft.client.renderer.entity.state.LlamaRenderState;
|
| 12 | import net.minecraft.resources.Identifier;
|
| 13 | import net.minecraft.world.entity.animal.equine.Llama;
|
| 14 | import net.minecraft.world.entity.animal.equine.Llama.Variant;
|
| 15 |
|
| 16 | @Environment(EnvType.CLIENT)
|
| 17 | public class LlamaRenderer extends AgeableMobRenderer<Llama, LlamaRenderState, LlamaModel> {
|
| 18 | private static final Map<Variant, Identifier> TEXTURES = Maps.newEnumMap(
|
| 19 | Map.of(
|
| 20 | Variant.CREAMY,
|
| 21 | Identifier.withDefaultNamespace("textures/entity/llama/llama_creamy.png"),
|
| 22 | Variant.WHITE,
|
| 23 | Identifier.withDefaultNamespace("textures/entity/llama/llama_white.png"),
|
| 24 | Variant.BROWN,
|
| 25 | Identifier.withDefaultNamespace("textures/entity/llama/llama_brown.png"),
|
| 26 | Variant.GRAY,
|
| 27 | Identifier.withDefaultNamespace("textures/entity/llama/llama_gray.png")
|
| 28 | )
|
| 29 | );
|
| 30 | private static final Map<Variant, Identifier> BABY_TEXTURES = Maps.newEnumMap(
|
| 31 | Map.of(
|
| 32 | Variant.CREAMY,
|
| 33 | Identifier.withDefaultNamespace("textures/entity/llama/llama_creamy_baby.png"),
|
| 34 | Variant.WHITE,
|
| 35 | Identifier.withDefaultNamespace("textures/entity/llama/llama_white_baby.png"),
|
| 36 | Variant.BROWN,
|
| 37 | Identifier.withDefaultNamespace("textures/entity/llama/llama_brown_baby.png"),
|
| 38 | Variant.GRAY,
|
| 39 | Identifier.withDefaultNamespace("textures/entity/llama/llama_gray_baby.png")
|
| 40 | )
|
| 41 | );
|
| 42 |
|
| 43 | public LlamaRenderer(final EntityRendererProvider.Context context, final ModelLayerLocation model, final ModelLayerLocation babyModel) {
|
| 44 | super(context, new LlamaModel(context.bakeLayer(model)), new BabyLlamaModel(context.bakeLayer(babyModel)), 0.7F);
|
| 45 | this.addLayer(new LlamaDecorLayer(this, context.getModelSet(), context.getEquipmentRenderer()));
|
| 46 | }
|
| 47 |
|
| 48 | public Identifier getTextureLocation(final LlamaRenderState state) {
|
| 49 | Map<Variant, Identifier> textures = state.isBaby ? BABY_TEXTURES : TEXTURES;
|
| 50 | return textures.get(state.variant);
|
| 51 | }
|
| 52 |
|
| 53 | public LlamaRenderState createRenderState() {
|
| 54 | return new LlamaRenderState();
|
| 55 | }
|
| 56 |
|
| 57 | public void extractRenderState(final Llama entity, final LlamaRenderState state, final float partialTicks) {
|
| 58 | super.extractRenderState(entity, state, partialTicks);
|
| 59 | state.variant = entity.getVariant();
|
| 60 | state.hasChest = !entity.isBaby() && entity.hasChest();
|
| 61 | state.bodyItem = entity.getBodyArmorItem();
|
| 62 | state.isTraderLlama = entity.isTraderLlama();
|
| 63 | }
|
| 64 | }
|
| 65 |
|