package net.minecraft.client.resources.model;

import com.google.common.collect.Maps;
import com.google.common.collect.Lists;
import net.minecraft.client.renderer.block.model.BlockModel;
import java.util.Random;
import javax.annotation.Nullable;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.client.renderer.block.model.ItemOverrides;
import net.minecraft.client.renderer.block.model.ItemTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.core.Direction;
import java.util.Map;
import net.minecraft.client.renderer.block.model.BakedQuad;
import java.util.List;

public class SimpleBakedModel implements BakedModel {
    protected final List<BakedQuad> unculledFaces;
    protected final Map<Direction, List<BakedQuad>> culledFaces;
    protected final boolean hasAmbientOcclusion;
    protected final boolean isGui3d;
    protected final boolean usesBlockLight;
    protected final TextureAtlasSprite particleIcon;
    protected final ItemTransforms transforms;
    protected final ItemOverrides overrides;
    
    public SimpleBakedModel(final List<BakedQuad> list, final Map<Direction, List<BakedQuad>> map, final boolean boolean3, final boolean boolean4, final boolean boolean5, final TextureAtlasSprite eaj, final ItemTransforms drz, final ItemOverrides drx) {
        this.unculledFaces = list;
        this.culledFaces = map;
        this.hasAmbientOcclusion = boolean3;
        this.isGui3d = boolean5;
        this.usesBlockLight = boolean4;
        this.particleIcon = eaj;
        this.transforms = drz;
        this.overrides = drx;
    }
    
    @Override
    public List<BakedQuad> getQuads(@Nullable final BlockState byj, @Nullable final Direction fp, final Random random) {
        return (fp == null) ? this.unculledFaces : this.culledFaces.get(fp);
    }
    
    @Override
    public boolean useAmbientOcclusion() {
        return this.hasAmbientOcclusion;
    }
    
    @Override
    public boolean isGui3d() {
        return this.isGui3d;
    }
    
    @Override
    public boolean usesBlockLight() {
        return this.usesBlockLight;
    }
    
    @Override
    public boolean isCustomRenderer() {
        return false;
    }
    
    @Override
    public TextureAtlasSprite getParticleIcon() {
        return this.particleIcon;
    }
    
    @Override
    public ItemTransforms getTransforms() {
        return this.transforms;
    }
    
    @Override
    public ItemOverrides getOverrides() {
        return this.overrides;
    }
    
    public static class Builder {
        private final List<BakedQuad> unculledFaces;
        private final Map<Direction, List<BakedQuad>> culledFaces;
        private final ItemOverrides overrides;
        private final boolean hasAmbientOcclusion;
        private TextureAtlasSprite particleIcon;
        private final boolean usesBlockLight;
        private final boolean isGui3d;
        private final ItemTransforms transforms;
        
        public Builder(final BlockModel drs, final ItemOverrides drx, final boolean boolean3) {
            this(drs.hasAmbientOcclusion(), drs.getGuiLight().lightLikeBlock(), boolean3, drs.getTransforms(), drx);
        }
        
        private Builder(final boolean boolean1, final boolean boolean2, final boolean boolean3, final ItemTransforms drz, final ItemOverrides drx) {
            this.unculledFaces = Lists.newArrayList();
            this.culledFaces = Maps.newEnumMap(Direction.class);
            for (final Direction fp10 : Direction.values()) {
                this.culledFaces.put(fp10, Lists.newArrayList());
            }
            this.overrides = drx;
            this.hasAmbientOcclusion = boolean1;
            this.usesBlockLight = boolean2;
            this.isGui3d = boolean3;
            this.transforms = drz;
        }
        
        public Builder addCulledFace(final Direction fp, final BakedQuad drn) {
            this.culledFaces.get(fp).add(drn);
            return this;
        }
        
        public Builder addUnculledFace(final BakedQuad drn) {
            this.unculledFaces.add(drn);
            return this;
        }
        
        public Builder particle(final TextureAtlasSprite eaj) {
            this.particleIcon = eaj;
            return this;
        }
        
        public BakedModel build() {
            if (this.particleIcon == null) {
                throw new RuntimeException("Missing particle!");
            }
            return new SimpleBakedModel(this.unculledFaces, this.culledFaces, this.hasAmbientOcclusion, this.usesBlockLight, this.isGui3d, this.particleIcon, this.transforms, this.overrides);
        }
    }
}
