package reborncore.client.models;

import net.minecraft.client.renderer.block.model.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import org.lwjgl.util.vector.Vector3f;
import reborncore.common.misc.vecmath.Vecs3dCube;

import java.util.ArrayList;

/**
 * Created by modmuss50 on 09/05/2016.
 */
public class BakedModelUtils {

    public static void addCubeToList(Vecs3dCube cube, ArrayList<BakedQuad> list, BlockPartFace face,
                                     ModelRotation modelRotation, TextureAtlasSprite cubeTexture, EnumFacing dir, FaceBakery faceBakery)
    {
        BlockFaceUV uv = new BlockFaceUV(new float[] { (float) cube.getMinX(), (float) cube.getMinY(),
                (float) cube.getMaxX(), (float) cube.getMaxY() }, 90);
        face = new BlockPartFace(dir, 0, "", uv);
//        if(dir == EnumFacing.NORTH ||  dir == EnumFacing.SOUTH){
//            modelRotation = ModelRotation.X0_Y90;
//            uv = new BlockFaceUV(new float[] { (float) cube.getMinZ(), (float) cube.getMinY(),
//                    (float) cube.getMaxZ(), (float) cube.getMaxY() }, 180);
//            face = new BlockPartFace(dir, 0, "", uv);
//        }
        list.add(faceBakery.makeBakedQuad(
                new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
                new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMaxZ()), face, cubeTexture,
                EnumFacing.DOWN, modelRotation, null, true, true));// down
        list.add(faceBakery.makeBakedQuad(
                new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMinZ()),
                new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
                EnumFacing.UP, modelRotation, null, true, true));// up
        list.add(faceBakery.makeBakedQuad(
                new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
                new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
                EnumFacing.NORTH, modelRotation, null, true, true));// north
        list.add(faceBakery.makeBakedQuad(
                new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMaxZ()),
                new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
                EnumFacing.SOUTH, modelRotation, null, true, true));// south
        list.add(faceBakery.makeBakedQuad(
                new Vector3f((float) cube.getMaxX(), (float) cube.getMinY(), (float) cube.getMinZ()),
                new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
                EnumFacing.EAST, modelRotation, null, true, true));// east
        list.add(faceBakery.makeBakedQuad(
                new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),
                new Vector3f((float) cube.getMinX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), face, cubeTexture,
                EnumFacing.WEST, modelRotation, null, true, true));// west
    }

}

@@ -853,370 +853,8 @@
 v);%0A
-//        if(dir == EnumFacing.NORTH %7C%7C  dir == EnumFacing.SOUTH)%7B%0A//            modelRotation = ModelRotation.X0_Y90;%0A//            uv = new BlockFaceUV(new float%5B%5D %7B (float) cube.getMinZ(), (float) cube.getMinY(),%0A//                    (float) cube.getMaxZ(), (float) cube.getMaxY() %7D, 180);%0A//            face = new BlockPartFace(dir, 0, %22%22, uv);%0A//        %7D%0A
     
@@ -1527,16 +1527,258 @@
 );// up%0A
+        if(dir == EnumFacing.NORTH %7C%7C dir == EnumFacing.SOUTH)%7B%0A            BlockFaceUV uv2 = new BlockFaceUV(new float%5B%5D %7B (float) cube.getMaxX() + 4, (float) cube.getMinY(),%0A                    (float) 16, (float) cube.getMaxY() %7D, 0);%0A    
         
@@ -1820,32 +1820,36 @@
                 
+    
 new Vector3f((fl
@@ -1910,32 +1910,442 @@
 ube.getMinZ()),%0A
+                    new Vector3f((float) cube.getMaxX(), (float) cube.getMaxY(), (float) cube.getMaxZ()), new BlockPartFace(dir, 0, %22%22, uv2), cubeTexture,%0A                    EnumFacing.NORTH, modelRotation, null, true, true));// north%0A        %7D else %7B%0A            list.add(faceBakery.makeBakedQuad(%0A                    new Vector3f((float) cube.getMinX(), (float) cube.getMinY(), (float) cube.getMinZ()),%0A    
                 
@@ -2441,32 +2441,36 @@
 e, cubeTexture,%0A
+    
                 
@@ -2522,32 +2522,43 @@
 true));// north%0A
+        %7D%0A%0A
         list.add

Fix cable rendering