// Path: src/codechicken/wirelessredstone/core/WirelessBolt.java
// public class Segment
// {
//     public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) {
//         this.startpoint = start;
//         this.endpoint = end;
//         this.light = light;
//         this.segmentno = segmentnumber;
//         this.splitno = splitnumber;
// 
//         calcDiff();
//     }
// 
//     public Segment(Vector3 start, Vector3 end) {
//         this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0);
//     }
// 
//     public void calcDiff() {
//         diff = endpoint.point.copy().subtract(startpoint.point);
//     }
// 
//     public void calcEndDiffs() {
//         if (prev != null) {
//             Vector3 prevdiffnorm = prev.diff.copy().normalize();
//             Vector3 thisdiffnorm = diff.copy().normalize();
// 
//             prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize();
//             sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.negate()) / 2);
//         } else {
//             prevdiff = diff.copy().normalize();
//             sinprev = 1;
//         }
// 
//         if (next != null) {
//             Vector3 nextdiffnorm = next.diff.copy().normalize();
//             Vector3 thisdiffnorm = diff.copy().normalize();
// 
//             nextdiff = thisdiffnorm.add(nextdiffnorm).normalize();
//             sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.negate()) / 2);
//         } else {
//             nextdiff = diff.copy().normalize();
//             sinnext = 1;
//         }
//     }
// 
//     public String toString() {
//         return startpoint.point.toString() + " " + endpoint.point.toString();
//     }
// 
//     public BoltPoint startpoint;
//     public BoltPoint endpoint;
// 
//     public Vector3 diff;
// 
//     public Segment prev;
//     public Segment next;
// 
//     public Vector3 nextdiff;
//     public Vector3 prevdiff;
// 
//     public float sinprev;
//     public float sinnext;
//     public float light;
// 
//     public int segmentno;
//     public int splitno;
// }


import java.util.Iterator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Vector3;
import codechicken.wirelessredstone.core.WirelessBolt.Segment;
        for(WirelessBolt bolt : WirelessBolt.clientboltlist)
            renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0);
        CCRenderState.draw();
        
        CCRenderState.changeTexture("wrcbe_core:textures/lightning_redstone.png");
        CCRenderState.startDrawing(7);
        for(WirelessBolt bolt : WirelessBolt.clientboltlist)
            renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1);
        CCRenderState.draw();
        
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);

        GL11.glPopMatrix();
    }
    
    private static void renderBolt(WirelessBolt bolt, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass)
    {
        Tessellator t = Tessellator.instance;
        float boltage = bolt.particleAge < 0 ? 0 : (float)bolt.particleAge / (float)bolt.particleMaxAge;
        float mainalpha = 1;
        if(pass == 0)
            mainalpha = (1 - boltage) * 0.4F;
        else
            mainalpha = 1 - boltage * 0.5F;
        
        int expandTime = (int)(bolt.length*WirelessBolt.speed);    
        int renderstart = (int) ((expandTime/2-bolt.particleMaxAge+bolt.particleAge) / (float)(expandTime/2) * bolt.numsegments0);
        int renderend = (int) ((bolt.particleAge+expandTime) / (float)expandTime * bolt.numsegments0);
        
// Path: src/codechicken/wirelessredstone/core/WirelessBolt.java
// public class Segment
// {
//     public Segment(BoltPoint start, BoltPoint end, float light, int segmentnumber, int splitnumber) {
//         this.startpoint = start;
//         this.endpoint = end;
//         this.light = light;
//         this.segmentno = segmentnumber;
//         this.splitno = splitnumber;
// 
//         calcDiff();
//     }
// 
//     public Segment(Vector3 start, Vector3 end) {
//         this(new BoltPoint(start, new Vector3(0, 0, 0)), new BoltPoint(end, new Vector3(0, 0, 0)), 1, 0, 0);
//     }
// 
//     public void calcDiff() {
//         diff = endpoint.point.copy().subtract(startpoint.point);
//     }
// 
//     public void calcEndDiffs() {
//         if (prev != null) {
//             Vector3 prevdiffnorm = prev.diff.copy().normalize();
//             Vector3 thisdiffnorm = diff.copy().normalize();
// 
//             prevdiff = thisdiffnorm.copy().add(prevdiffnorm).normalize();
//             sinprev = (float) Math.sin(thisdiffnorm.angle(prevdiffnorm.negate()) / 2);
//         } else {
//             prevdiff = diff.copy().normalize();
//             sinprev = 1;
//         }
// 
//         if (next != null) {
//             Vector3 nextdiffnorm = next.diff.copy().normalize();
//             Vector3 thisdiffnorm = diff.copy().normalize();
// 
//             nextdiff = thisdiffnorm.add(nextdiffnorm).normalize();
//             sinnext = (float) Math.sin(thisdiffnorm.angle(nextdiffnorm.negate()) / 2);
//         } else {
//             nextdiff = diff.copy().normalize();
//             sinnext = 1;
//         }
//     }
// 
//     public String toString() {
//         return startpoint.point.toString() + " " + endpoint.point.toString();
//     }
// 
//     public BoltPoint startpoint;
//     public BoltPoint endpoint;
// 
//     public Vector3 diff;
// 
//     public Segment prev;
//     public Segment next;
// 
//     public Vector3 nextdiff;
//     public Vector3 prevdiff;
// 
//     public float sinprev;
//     public float sinnext;
//     public float light;
// 
//     public int segmentno;
//     public int splitno;
// }


// Path: src/codechicken/wirelessredstone/core/RenderWirelessBolt.java
import java.util.Iterator;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.Tessellator;
import org.lwjgl.opengl.GL11;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Vector3;
import codechicken.wirelessredstone.core.WirelessBolt.Segment;

        for(WirelessBolt bolt : WirelessBolt.clientboltlist)
            renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 0);
        CCRenderState.draw();
        
        CCRenderState.changeTexture("wrcbe_core:textures/lightning_redstone.png");
        CCRenderState.startDrawing(7);
        for(WirelessBolt bolt : WirelessBolt.clientboltlist)
            renderBolt(bolt, frame, ActiveRenderInfo.rotationX, ActiveRenderInfo.rotationXZ, ActiveRenderInfo.rotationZ, ActiveRenderInfo.rotationXY, 1);
        CCRenderState.draw();
        
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);

        GL11.glPopMatrix();
    }
    
    private static void renderBolt(WirelessBolt bolt, float partialframe, float cosyaw, float cospitch, float sinyaw, float cossinpitch, int pass)
    {
        Tessellator t = Tessellator.instance;
        float boltage = bolt.particleAge < 0 ? 0 : (float)bolt.particleAge / (float)bolt.particleMaxAge;
        float mainalpha = 1;
        if(pass == 0)
            mainalpha = (1 - boltage) * 0.4F;
        else
            mainalpha = 1 - boltage * 0.5F;
        
        int expandTime = (int)(bolt.length*WirelessBolt.speed);    
        int renderstart = (int) ((expandTime/2-bolt.particleMaxAge+bolt.particleAge) / (float)(expandTime/2) * bolt.numsegments0);
        int renderend = (int) ((bolt.particleAge+expandTime) / (float)expandTime * bolt.numsegments0);
        
        for(Iterator<Segment> iterator = bolt.segments.iterator(); iterator.hasNext();)