package codechicken.lib.model;

import codechicken.lib.model.loader.CCBakedModelLoader;
import codechicken.lib.render.TextureUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;

import javax.annotation.Nullable;
import java.util.LinkedList;
import java.util.List;

/**
 * Created by covers1624 on 7/31/2016.
 */
public class CCOverrideBakedBlockModel implements IBakedModel {

    private final String particle;
    private final boolean isAmbientOcclusion;

    public CCOverrideBakedBlockModel(String particle) {
        this(particle, false);
    }

    public CCOverrideBakedBlockModel(String particle, boolean isAmbientOcclusion) {

        this.particle = particle;
        this.isAmbientOcclusion = isAmbientOcclusion;
    }

    @Override
    public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
        IBakedModel correctModel = CCBakedModelLoader.getModel(state);
        LinkedList<BakedQuad> quads = new LinkedList<BakedQuad>();
        if (correctModel != null) {
            quads.addAll(correctModel.getQuads(state, side, rand));
        }
        return quads;
    }

    @Override
    public boolean isAmbientOcclusion() {
        return isAmbientOcclusion;
    }

    @Override
    public boolean isGui3d() {
        return false;
    }

    @Override
    public boolean isBuiltInRenderer() {
        return false;
    }

    @Override
    public TextureAtlasSprite getParticleTexture() {
        return TextureUtils.getTexture(particle);
    }

    @Override
    public ItemCameraTransforms getItemCameraTransforms() {
        return ItemCameraTransforms.DEFAULT;
    }

    @Override
    public ItemOverrideList getOverrides() {
        return ItemOverrideList.NONE;
    }
}

@@ -814,16 +814,65 @@
 clusion;
+%0A    private final ItemOverrideList overrideList;
 %0A%0A    pu
@@ -944,21 +944,175 @@
 rticle, 
-false
+ItemOverrideList.NONE);%0A    %7D%0A%0A    public CCOverrideBakedBlockModel(String particle, ItemOverrideList overrideList)%7B%0A        this(particle, false, overrideList
 );%0A    %7D
@@ -1197,13 +1197,43 @@
 sion
+, ItemOverrideList overrideList
 ) %7B%0A
-%0A
     
@@ -1308,32 +1308,74 @@
 bientOcclusion;%0A
+        this.overrideList = overrideList;%0A
     %7D%0A%0A    @Over
@@ -1480,24 +1480,155 @@
 ong rand) %7B%0A
+        LinkedList%3CBakedQuad%3E quads = new LinkedList%3CBakedQuad%3E();%0A        if (state == null)%7B%0A            return quads;%0A        %7D%0A
         IBak
@@ -1690,75 +1690,8 @@
 e);%0A
-        LinkedList%3CBakedQuad%3E quads = new LinkedList%3CBakedQuad%3E();%0A
     
@@ -2409,21 +2409,17 @@
  return 
-ItemO
+o
 verrideL
@@ -2421,21 +2421,16 @@
 rideList
-.NONE
 ;%0A    %7D%0A

Allow ItemOverrideList in CCOverrideBakedBlockModel