| 1 | package net.minecraft.client.renderer.entity;
|
| 2 |
|
| 3 | import com.google.common.collect.Maps;
|
| 4 | import java.util.Map;
|
| 5 | import net.minecraft.client.Minecraft;
|
| 6 | import net.minecraft.client.model.ModelHorse;
|
| 7 | import net.minecraft.client.renderer.GlStateManager;
|
| 8 | import net.minecraft.client.renderer.texture.LayeredTexture;
|
| 9 | import net.minecraft.entity.passive.EntityHorse;
|
| 10 | import net.minecraft.util.ResourceLocation;
|
| 11 |
|
| 12 | public class RenderHorse extends RenderLiving<EntityHorse>
|
| 13 | {
|
| 14 | private static final Map<String, ResourceLocation> field_110852_a = Maps.<String, ResourceLocation>newHashMap();
|
| 15 | private static final ResourceLocation whiteHorseTextures = new ResourceLocation("textures/entity/horse/horse_white.png");
|
| 16 | private static final ResourceLocation muleTextures = new ResourceLocation("textures/entity/horse/mule.png");
|
| 17 | private static final ResourceLocation donkeyTextures = new ResourceLocation("textures/entity/horse/donkey.png");
|
| 18 | private static final ResourceLocation zombieHorseTextures = new ResourceLocation("textures/entity/horse/horse_zombie.png");
|
| 19 | private static final ResourceLocation skeletonHorseTextures = new ResourceLocation("textures/entity/horse/horse_skeleton.png");
|
| 20 |
|
| 21 | public RenderHorse(RenderManager rendermanagerIn, ModelHorse model, float shadowSizeIn)
|
| 22 | {
|
| 23 | super(rendermanagerIn, model, shadowSizeIn);
|
| 24 | }
|
| 25 |
|
| 26 | /**
|
| 27 | * Allows the render to do any OpenGL state modifications necessary before the model is rendered. Args:
|
| 28 | * entityLiving, partialTickTime
|
| 29 | */
|
| 30 | protected void preRenderCallback(EntityHorse entitylivingbaseIn, float partialTickTime)
|
| 31 | {
|
| 32 | float f = 1.0F;
|
| 33 | int i = entitylivingbaseIn.getHorseType();
|
| 34 |
|
| 35 | if (i == 1)
|
| 36 | {
|
| 37 | f *= 0.87F;
|
| 38 | }
|
| 39 | else if (i == 2)
|
| 40 | {
|
| 41 | f *= 0.92F;
|
| 42 | }
|
| 43 |
|
| 44 | GlStateManager.scale(f, f, f);
|
| 45 | super.preRenderCallback(entitylivingbaseIn, partialTickTime);
|
| 46 | }
|
| 47 |
|
| 48 | /**
|
| 49 | * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
| 50 | */
|
| 51 | protected ResourceLocation getEntityTexture(EntityHorse entity)
|
| 52 | {
|
| 53 | if (!entity.func_110239_cn())
|
| 54 | {
|
| 55 | switch (entity.getHorseType())
|
| 56 | {
|
| 57 | case 0:
|
| 58 | default:
|
| 59 | return whiteHorseTextures;
|
| 60 |
|
| 61 | case 1:
|
| 62 | return donkeyTextures;
|
| 63 |
|
| 64 | case 2:
|
| 65 | return muleTextures;
|
| 66 |
|
| 67 | case 3:
|
| 68 | return zombieHorseTextures;
|
| 69 |
|
| 70 | case 4:
|
| 71 | return skeletonHorseTextures;
|
| 72 | }
|
| 73 | }
|
| 74 | else
|
| 75 | {
|
| 76 | return this.func_110848_b(entity);
|
| 77 | }
|
| 78 | }
|
| 79 |
|
| 80 | private ResourceLocation func_110848_b(EntityHorse horse)
|
| 81 | {
|
| 82 | String s = horse.getHorseTexture();
|
| 83 |
|
| 84 | if (!horse.func_175507_cI())
|
| 85 | {
|
| 86 | return null;
|
| 87 | }
|
| 88 | else
|
| 89 | {
|
| 90 | ResourceLocation resourcelocation = (ResourceLocation)field_110852_a.get(s);
|
| 91 |
|
| 92 | if (resourcelocation == null)
|
| 93 | {
|
| 94 | resourcelocation = new ResourceLocation(s);
|
| 95 | Minecraft.getMinecraft().getTextureManager().loadTexture(resourcelocation, new LayeredTexture(horse.getVariantTexturePaths()));
|
| 96 | field_110852_a.put(s, resourcelocation);
|
| 97 | }
|
| 98 |
|
| 99 | return resourcelocation;
|
| 100 | }
|
| 101 | }
|
| 102 | }
|
| 103 |
|