| 1 | package net.minecraft.client.renderer.entity;
|
| 2 |
|
| 3 | import net.minecraft.client.model.ModelBase;
|
| 4 | import net.minecraft.client.model.ModelBoat;
|
| 5 | import net.minecraft.client.renderer.GlStateManager;
|
| 6 | import net.minecraft.entity.item.EntityBoat;
|
| 7 | import net.minecraft.util.MathHelper;
|
| 8 | import net.minecraft.util.ResourceLocation;
|
| 9 |
|
| 10 | public class RenderBoat extends Render<EntityBoat>
|
| 11 | {
|
| 12 | private static final ResourceLocation boatTextures = new ResourceLocation("textures/entity/boat.png");
|
| 13 |
|
| 14 | /** instance of ModelBoat for rendering */
|
| 15 | protected ModelBase modelBoat = new ModelBoat();
|
| 16 |
|
| 17 | public RenderBoat(RenderManager renderManagerIn)
|
| 18 | {
|
| 19 | super(renderManagerIn);
|
| 20 | this.shadowSize = 0.5F;
|
| 21 | }
|
| 22 |
|
| 23 | /**
|
| 24 | * Renders the desired {@code T} type Entity.
|
| 25 | */
|
| 26 | public void doRender(EntityBoat entity, double x, double y, double z, float entityYaw, float partialTicks)
|
| 27 | {
|
| 28 | GlStateManager.pushMatrix();
|
| 29 | GlStateManager.translate((float)x, (float)y + 0.25F, (float)z);
|
| 30 | GlStateManager.rotate(180.0F - entityYaw, 0.0F, 1.0F, 0.0F);
|
| 31 | float f = (float)entity.getTimeSinceHit() - partialTicks;
|
| 32 | float f1 = entity.getDamageTaken() - partialTicks;
|
| 33 |
|
| 34 | if (f1 < 0.0F)
|
| 35 | {
|
| 36 | f1 = 0.0F;
|
| 37 | }
|
| 38 |
|
| 39 | if (f > 0.0F)
|
| 40 | {
|
| 41 | GlStateManager.rotate(MathHelper.sin(f) * f * f1 / 10.0F * (float)entity.getForwardDirection(), 1.0F, 0.0F, 0.0F);
|
| 42 | }
|
| 43 |
|
| 44 | float f2 = 0.75F;
|
| 45 | GlStateManager.scale(f2, f2, f2);
|
| 46 | GlStateManager.scale(1.0F / f2, 1.0F / f2, 1.0F / f2);
|
| 47 | this.bindEntityTexture(entity);
|
| 48 | GlStateManager.scale(-1.0F, -1.0F, 1.0F);
|
| 49 | this.modelBoat.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
|
| 50 | GlStateManager.popMatrix();
|
| 51 | super.doRender(entity, x, y, z, entityYaw, partialTicks);
|
| 52 | }
|
| 53 |
|
| 54 | /**
|
| 55 | * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
| 56 | */
|
| 57 | protected ResourceLocation getEntityTexture(EntityBoat entity)
|
| 58 | {
|
| 59 | return boatTextures;
|
| 60 | }
|
| 61 | }
|
| 62 |
|