<commit_before>package codechicken.lib.model.bakery;

import codechicken.lib.render.CCModel;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.render.pipeline.IVertexSource;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;

import java.util.List;

/**
 * Created by covers1624 on 8/20/2016.
 * Uses the CCL RenderPipe to bake a CCModel to an array of BakedQuads with the provided VertexFormat.
 */
public class CCModelBakery {

    /**
     * Bakes a CCModel to a List of BakedQuads.
     * Assumes DefaultVertexFormats.BLOCK.
     * Assumes you want to bake the entire model.
     *
     * @param model  Model to bake.
     * @param sprite Sprite the quads are to be baked from.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, TextureAtlasSprite sprite, IVertexOperation... ops) {
        return bakeModel(model, sprite, 0, model.getVertices().length, ops);
    }

    /**
     * Bakes a CCModel to a List of BakedQuads.
     * Assumes DefaultVertexFormats.BLOCK.
     *
     * @param model  Model to bake.
     * @param sprite Sprite the quads are to be baked from.
     * @param start  The first vertex index to bake.
     * @param end    The Vertex index to bake until.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, TextureAtlasSprite sprite, int start, int end, IVertexOperation... ops) {
        return bakeModel(model, DefaultVertexFormats.BLOCK, sprite, start, end, ops);
    }

    /**
     * Bakes a CCModel to a List of BakedQuads.
     * Assumes you want to bake the entire model.
     *
     * @param model  Model to bake.
     * @param format VertexFormat to bake to.
     * @param sprite Sprite the quads are to be baked from.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, VertexFormat format, TextureAtlasSprite sprite, IVertexOperation... ops) {
        return bakeModel(model, format, sprite, 0, model.getVertices().length, ops);
    }

    /**
     * Bakes a IVertexSource model to a List of BakedQuads.
     *
     * @param model  Vertex source to bake.
     * @param format VertexFormat to bake to.
     * @param sprite Sprite the quads are to be baked from.
     * @param start  The first vertex index to bake.
     * @param end    The Vertex index to bake until.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, VertexFormat format, TextureAtlasSprite sprite, int start, int end, IVertexOperation... ops) {
        return bakeModel(model, model.vp == 3, format, sprite, start, end, ops);
    }

    /**
     * Bakes a IVertexSource model to a List of BakedQuads.
     *
     * @param model       Vertex source to bake.
     * @param isTriangles Specifies if the model's vertices are triangles.
     * @param format      VertexFormat to bake to.
     * @param sprite      Sprite the quads are to be baked from.
     * @param start       The first vertex index to bake.
     * @param end         The Vertex index to bake until.
     * @param ops         Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(IVertexSource model, boolean isTriangles, VertexFormat format, TextureAtlasSprite sprite, int start, int end, IVertexOperation... ops) {
        //The face for quads is assigned down the line using the quads normals.
        CCQuadBakery bakery = new CCQuadBakery(format, sprite);
        if (isTriangles) {
            bakery.startBakingTriangles();
        } else {
            bakery.startBakingQuads();
        }
        /*CCRenderState.fmt = format;
        CCRenderState.setPipeline(model, start, end, ops);
        Vertex5[] verts = model.getVertices();
        for (vertexIndex = firstVertexIndex; vertexIndex < lastVertexIndex; vertexIndex++) {
            model.prepareVertex();
            vert.set(verts[vertexIndex]);
            runPipeline();
            if (CCRenderState.sprite != null) {
                try {
                    bakery.setSprite(CCRenderState.sprite);
                } catch (IllegalStateException e) {
                    throw new RuntimeException("Unable to set sprite in baking pipeline! Please ensure your IconVertexRangeUVTransform is correct!", e);
                }
            }
            Vertex5 vert = CCRenderState.vert;
            bakery.setColour(CCRenderState.colour);
            bakery.setLightMap(CCRenderState.brightness);
            bakery.setNormal(CCRenderState.normal);
            bakery.addVertexWithUV(vert);
        }*/
        return bakery.finishBaking();
    }
}<commit_msg>Fix baking CCModel baking pipe.<commit_after>package codechicken.lib.model.bakery;

import codechicken.lib.render.CCModel;
import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.buffer.BakingVertexBuffer;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.render.pipeline.IVertexSource;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.client.renderer.vertex.VertexFormat;

import java.util.List;

/**
 * Created by covers1624 on 8/20/2016.
 * Uses the CCL RenderPipe to bake a CCModel to an array of BakedQuads with the provided VertexFormat.
 */
public class CCModelBakery {

    /**
     * Bakes a CCModel to a List of BakedQuads.
     * Assumes DefaultVertexFormats.BLOCK.
     * Assumes you want to bake the entire model.
     *
     * @param model  Model to bake.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, IVertexOperation... ops) {
        return bakeModel(model, 0, model.getVertices().length, ops);
    }

    /**
     * Bakes a CCModel to a List of BakedQuads.
     * Assumes DefaultVertexFormats.BLOCK.
     *
     * @param model  Model to bake.
     * @param start  The first vertex index to bake.
     * @param end    The Vertex index to bake until.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, int start, int end, IVertexOperation... ops) {
        return bakeModel(model, DefaultVertexFormats.ITEM, start, end, ops);
    }

    /**
     * Bakes a CCModel to a List of BakedQuads.
     * Assumes you want to bake the entire model.
     *
     * @param model  Model to bake.
     * @param format VertexFormat to bake to.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, VertexFormat format, IVertexOperation... ops) {
        return bakeModel(model, format, 0, model.getVertices().length, ops);
    }

    /**
     * Bakes a IVertexSource model to a List of BakedQuads.
     *
     * @param model  Vertex source to bake.
     * @param format VertexFormat to bake to.
     * @param start  The first vertex index to bake.
     * @param end    The Vertex index to bake until.
     * @param ops    Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(CCModel model, VertexFormat format, int start, int end, IVertexOperation... ops) {
        return bakeModel(model, model.vp == 3, format, start, end, ops);
    }

    /**
     * Bakes a IVertexSource model to a List of BakedQuads.
     *
     * @param model       Vertex source to bake.
     * @param isTriangles Specifies if the model's vertices are triangles.
     * @param format      VertexFormat to bake to, You almost always want this to be ITEM.
     * @param start       The first vertex index to bake.
     * @param end         The Vertex index to bake until.
     * @param ops         Any Operations to apply.
     * @return The BakedQuads for the model.
     */
    public static List<BakedQuad> bakeModel(IVertexSource model, boolean isTriangles, VertexFormat format, int start, int end, IVertexOperation... ops) {
        BakingVertexBuffer buffer = BakingVertexBuffer.create();
        buffer.begin(isTriangles ? 4 : 7, format);
        CCRenderState ccrs = CCRenderState.instance();
        ccrs.bind(buffer);
        ccrs.setPipeline(model, start, end, ops);
        ccrs.render();
        return buffer.bake();
    }
}
{'fraction_non_alphanumeric': 0.08567588755739725, 'fraction_numerical': 0.0035838279762571397, 'mean_word_length': 2.6374745417515273, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1371039', 'n_tokens_mistral': 2701, 'n_tokens_neox': 2621, 'n_words': 866}