| 1 | package net.minecraft.client.renderer.entity;
|
| 2 |
|
| 3 | import net.minecraft.client.model.ModelDragon;
|
| 4 | import net.minecraft.client.renderer.GlStateManager;
|
| 5 | import net.minecraft.client.renderer.RenderHelper;
|
| 6 | import net.minecraft.client.renderer.Tessellator;
|
| 7 | import net.minecraft.client.renderer.WorldRenderer;
|
| 8 | import net.minecraft.client.renderer.entity.layers.LayerEnderDragonDeath;
|
| 9 | import net.minecraft.client.renderer.entity.layers.LayerEnderDragonEyes;
|
| 10 | import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
| 11 | import net.minecraft.entity.boss.BossStatus;
|
| 12 | import net.minecraft.entity.boss.EntityDragon;
|
| 13 | import net.minecraft.util.MathHelper;
|
| 14 | import net.minecraft.util.ResourceLocation;
|
| 15 |
|
| 16 | public class RenderDragon extends RenderLiving<EntityDragon>
|
| 17 | {
|
| 18 | private static final ResourceLocation enderDragonCrystalBeamTextures = new ResourceLocation("textures/entity/endercrystal/endercrystal_beam.png");
|
| 19 | private static final ResourceLocation enderDragonExplodingTextures = new ResourceLocation("textures/entity/enderdragon/dragon_exploding.png");
|
| 20 | private static final ResourceLocation enderDragonTextures = new ResourceLocation("textures/entity/enderdragon/dragon.png");
|
| 21 |
|
| 22 | /** An instance of the dragon model in RenderDragon */
|
| 23 | protected ModelDragon modelDragon;
|
| 24 |
|
| 25 | public RenderDragon(RenderManager renderManagerIn)
|
| 26 | {
|
| 27 | super(renderManagerIn, new ModelDragon(0.0F), 0.5F);
|
| 28 | this.modelDragon = (ModelDragon)this.mainModel;
|
| 29 | this.addLayer(new LayerEnderDragonEyes(this));
|
| 30 | this.addLayer(new LayerEnderDragonDeath());
|
| 31 | }
|
| 32 |
|
| 33 | protected void rotateCorpse(EntityDragon bat, float p_77043_2_, float p_77043_3_, float partialTicks)
|
| 34 | {
|
| 35 | float f = (float)bat.getMovementOffsets(7, partialTicks)[0];
|
| 36 | float f1 = (float)(bat.getMovementOffsets(5, partialTicks)[1] - bat.getMovementOffsets(10, partialTicks)[1]);
|
| 37 | GlStateManager.rotate(-f, 0.0F, 1.0F, 0.0F);
|
| 38 | GlStateManager.rotate(f1 * 10.0F, 1.0F, 0.0F, 0.0F);
|
| 39 | GlStateManager.translate(0.0F, 0.0F, 1.0F);
|
| 40 |
|
| 41 | if (bat.deathTime > 0)
|
| 42 | {
|
| 43 | float f2 = ((float)bat.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
|
| 44 | f2 = MathHelper.sqrt_float(f2);
|
| 45 |
|
| 46 | if (f2 > 1.0F)
|
| 47 | {
|
| 48 | f2 = 1.0F;
|
| 49 | }
|
| 50 |
|
| 51 | GlStateManager.rotate(f2 * this.getDeathMaxRotation(bat), 0.0F, 0.0F, 1.0F);
|
| 52 | }
|
| 53 | }
|
| 54 |
|
| 55 | /**
|
| 56 | * Renders the model in RenderLiving
|
| 57 | */
|
| 58 | protected void renderModel(EntityDragon entitylivingbaseIn, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float scaleFactor)
|
| 59 | {
|
| 60 | if (entitylivingbaseIn.deathTicks > 0)
|
| 61 | {
|
| 62 | float f = (float)entitylivingbaseIn.deathTicks / 200.0F;
|
| 63 | GlStateManager.depthFunc(515);
|
| 64 | GlStateManager.enableAlpha();
|
| 65 | GlStateManager.alphaFunc(516, f);
|
| 66 | this.bindTexture(enderDragonExplodingTextures);
|
| 67 | this.mainModel.render(entitylivingbaseIn, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
|
| 68 | GlStateManager.alphaFunc(516, 0.1F);
|
| 69 | GlStateManager.depthFunc(514);
|
| 70 | }
|
| 71 |
|
| 72 | this.bindEntityTexture(entitylivingbaseIn);
|
| 73 | this.mainModel.render(entitylivingbaseIn, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
|
| 74 |
|
| 75 | if (entitylivingbaseIn.hurtTime > 0)
|
| 76 | {
|
| 77 | GlStateManager.depthFunc(514);
|
| 78 | GlStateManager.disableTexture2D();
|
| 79 | GlStateManager.enableBlend();
|
| 80 | GlStateManager.blendFunc(770, 771);
|
| 81 | GlStateManager.color(1.0F, 0.0F, 0.0F, 0.5F);
|
| 82 | this.mainModel.render(entitylivingbaseIn, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
|
| 83 | GlStateManager.enableTexture2D();
|
| 84 | GlStateManager.disableBlend();
|
| 85 | GlStateManager.depthFunc(515);
|
| 86 | }
|
| 87 | }
|
| 88 |
|
| 89 | /**
|
| 90 | * Renders the desired {@code T} type Entity.
|
| 91 | */
|
| 92 | public void doRender(EntityDragon entity, double x, double y, double z, float entityYaw, float partialTicks)
|
| 93 | {
|
| 94 | BossStatus.setBossStatus(entity, false);
|
| 95 | super.doRender(entity, x, y, z, entityYaw, partialTicks);
|
| 96 |
|
| 97 | if (entity.healingEnderCrystal != null)
|
| 98 | {
|
| 99 | this.drawRechargeRay(entity, x, y, z, partialTicks);
|
| 100 | }
|
| 101 | }
|
| 102 |
|
| 103 | /**
|
| 104 | * Draws the ray from the dragon to it's crystal
|
| 105 | */
|
| 106 | protected void drawRechargeRay(EntityDragon dragon, double p_180574_2_, double p_180574_4_, double p_180574_6_, float p_180574_8_)
|
| 107 | {
|
| 108 | float f = (float)dragon.healingEnderCrystal.innerRotation + p_180574_8_;
|
| 109 | float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F;
|
| 110 | f1 = (f1 * f1 + f1) * 0.2F;
|
| 111 | float f2 = (float)(dragon.healingEnderCrystal.posX - dragon.posX - (dragon.prevPosX - dragon.posX) * (double)(1.0F - p_180574_8_));
|
| 112 | float f3 = (float)((double)f1 + dragon.healingEnderCrystal.posY - 1.0D - dragon.posY - (dragon.prevPosY - dragon.posY) * (double)(1.0F - p_180574_8_));
|
| 113 | float f4 = (float)(dragon.healingEnderCrystal.posZ - dragon.posZ - (dragon.prevPosZ - dragon.posZ) * (double)(1.0F - p_180574_8_));
|
| 114 | float f5 = MathHelper.sqrt_float(f2 * f2 + f4 * f4);
|
| 115 | float f6 = MathHelper.sqrt_float(f2 * f2 + f3 * f3 + f4 * f4);
|
| 116 | GlStateManager.pushMatrix();
|
| 117 | GlStateManager.translate((float)p_180574_2_, (float)p_180574_4_ + 2.0F, (float)p_180574_6_);
|
| 118 | GlStateManager.rotate((float)(-Math.atan2((double)f4, (double)f2)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
|
| 119 | GlStateManager.rotate((float)(-Math.atan2((double)f5, (double)f3)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
|
| 120 | Tessellator tessellator = Tessellator.getInstance();
|
| 121 | WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
| 122 | RenderHelper.disableStandardItemLighting();
|
| 123 | GlStateManager.disableCull();
|
| 124 | this.bindTexture(enderDragonCrystalBeamTextures);
|
| 125 | GlStateManager.shadeModel(7425);
|
| 126 | float f7 = 0.0F - ((float)dragon.ticksExisted + p_180574_8_) * 0.01F;
|
| 127 | float f8 = MathHelper.sqrt_float(f2 * f2 + f3 * f3 + f4 * f4) / 32.0F - ((float)dragon.ticksExisted + p_180574_8_) * 0.01F;
|
| 128 | worldrenderer.begin(5, DefaultVertexFormats.POSITION_TEX_COLOR);
|
| 129 | int i = 8;
|
| 130 |
|
| 131 | for (int j = 0; j <= 8; ++j)
|
| 132 | {
|
| 133 | float f9 = MathHelper.sin((float)(j % 8) * (float)Math.PI * 2.0F / 8.0F) * 0.75F;
|
| 134 | float f10 = MathHelper.cos((float)(j % 8) * (float)Math.PI * 2.0F / 8.0F) * 0.75F;
|
| 135 | float f11 = (float)(j % 8) * 1.0F / 8.0F;
|
| 136 | worldrenderer.pos((double)(f9 * 0.2F), (double)(f10 * 0.2F), 0.0D).tex((double)f11, (double)f8).color(0, 0, 0, 255).endVertex();
|
| 137 | worldrenderer.pos((double)f9, (double)f10, (double)f6).tex((double)f11, (double)f7).color(255, 255, 255, 255).endVertex();
|
| 138 | }
|
| 139 |
|
| 140 | tessellator.draw();
|
| 141 | GlStateManager.enableCull();
|
| 142 | GlStateManager.shadeModel(7424);
|
| 143 | RenderHelper.enableStandardItemLighting();
|
| 144 | GlStateManager.popMatrix();
|
| 145 | }
|
| 146 |
|
| 147 | /**
|
| 148 | * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
| 149 | */
|
| 150 | protected ResourceLocation getEntityTexture(EntityDragon entity)
|
| 151 | {
|
| 152 | return enderDragonTextures;
|
| 153 | }
|
| 154 | }
|
| 155 |
|