    001package net.minecraft.client.renderer.entity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.util.Random;
    006import net.minecraft.client.renderer.Tessellator;
    007import net.minecraft.entity.Entity;
    008import net.minecraft.entity.effect.EntityLightningBolt;
    009import org.lwjgl.opengl.GL11;
    010
    011@SideOnly(Side.CLIENT)
    012public class RenderLightningBolt extends Render
    013{
    014    /**
    015     * Actually renders the lightning bolt. This method is called through the doRender method.
    016     */
    017    public void doRenderLightningBolt(EntityLightningBolt par1EntityLightningBolt, double par2, double par4, double par6, float par8, float par9)
    018    {
    019        Tessellator var10 = Tessellator.instance;
    020        GL11.glDisable(GL11.GL_TEXTURE_2D);
    021        GL11.glDisable(GL11.GL_LIGHTING);
    022        GL11.glEnable(GL11.GL_BLEND);
    023        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    024        double[] var11 = new double[8];
    025        double[] var12 = new double[8];
    026        double var13 = 0.0D;
    027        double var15 = 0.0D;
    028        Random var17 = new Random(par1EntityLightningBolt.boltVertex);
    029
    030        for (int var18 = 7; var18 >= 0; --var18)
    031        {
    032            var11[var18] = var13;
    033            var12[var18] = var15;
    034            var13 += (double)(var17.nextInt(11) - 5);
    035            var15 += (double)(var17.nextInt(11) - 5);
    036        }
    037
    038        for (int var45 = 0; var45 < 4; ++var45)
    039        {
    040            Random var46 = new Random(par1EntityLightningBolt.boltVertex);
    041
    042            for (int var19 = 0; var19 < 3; ++var19)
    043            {
    044                int var20 = 7;
    045                int var21 = 0;
    046
    047                if (var19 > 0)
    048                {
    049                    var20 = 7 - var19;
    050                }
    051
    052                if (var19 > 0)
    053                {
    054                    var21 = var20 - 2;
    055                }
    056
    057                double var22 = var11[var20] - var13;
    058                double var24 = var12[var20] - var15;
    059
    060                for (int var26 = var20; var26 >= var21; --var26)
    061                {
    062                    double var27 = var22;
    063                    double var29 = var24;
    064
    065                    if (var19 == 0)
    066                    {
    067                        var22 += (double)(var46.nextInt(11) - 5);
    068                        var24 += (double)(var46.nextInt(11) - 5);
    069                    }
    070                    else
    071                    {
    072                        var22 += (double)(var46.nextInt(31) - 15);
    073                        var24 += (double)(var46.nextInt(31) - 15);
    074                    }
    075
    076                    var10.startDrawing(5);
    077                    float var31 = 0.5F;
    078                    var10.setColorRGBA_F(0.9F * var31, 0.9F * var31, 1.0F * var31, 0.3F);
    079                    double var32 = 0.1D + (double)var45 * 0.2D;
    080
    081                    if (var19 == 0)
    082                    {
    083                        var32 *= (double)var26 * 0.1D + 1.0D;
    084                    }
    085
    086                    double var34 = 0.1D + (double)var45 * 0.2D;
    087
    088                    if (var19 == 0)
    089                    {
    090                        var34 *= (double)(var26 - 1) * 0.1D + 1.0D;
    091                    }
    092
    093                    for (int var36 = 0; var36 < 5; ++var36)
    094                    {
    095                        double var37 = par2 + 0.5D - var32;
    096                        double var39 = par6 + 0.5D - var32;
    097
    098                        if (var36 == 1 || var36 == 2)
    099                        {
    100                            var37 += var32 * 2.0D;
    101                        }
    102
    103                        if (var36 == 2 || var36 == 3)
    104                        {
    105                            var39 += var32 * 2.0D;
    106                        }
    107
    108                        double var41 = par2 + 0.5D - var34;
    109                        double var43 = par6 + 0.5D - var34;
    110
    111                        if (var36 == 1 || var36 == 2)
    112                        {
    113                            var41 += var34 * 2.0D;
    114                        }
    115
    116                        if (var36 == 2 || var36 == 3)
    117                        {
    118                            var43 += var34 * 2.0D;
    119                        }
    120
    121                        var10.addVertex(var41 + var22, par4 + (double)(var26 * 16), var43 + var24);
    122                        var10.addVertex(var37 + var27, par4 + (double)((var26 + 1) * 16), var39 + var29);
    123                    }
    124
    125                    var10.draw();
    126                }
    127            }
    128        }
    129
    130        GL11.glDisable(GL11.GL_BLEND);
    131        GL11.glEnable(GL11.GL_LIGHTING);
    132        GL11.glEnable(GL11.GL_TEXTURE_2D);
    133    }
    134
    135    /**
    136     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    137     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    138     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    139     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    140     */
    141    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    142    {
    143        this.doRenderLightningBolt((EntityLightningBolt)par1Entity, par2, par4, par6, par8, par9);
    144    }
    145}