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