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 elv, final ItemTransforms edf, final ItemOverrides edd) {
        this.unculledFaces = list;
        this.culledFaces = map;
        this.hasAmbientOcclusion = boolean3;
        this.isGui3d = boolean5;
        this.usesBlockLight = boolean4;
        this.particleIcon = elv;
        this.transforms = edf;
        this.overrides = edd;
    }
    
    @Override
    public List<BakedQuad> getQuads(@Nullable final BlockState cfj, @Nullable final Direction fz, final Random random) {
        return (fz == null) ? this.unculledFaces : this.culledFaces.get(fz);
    }
    
    @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 ecy, final ItemOverrides edd, final boolean boolean3) {
            this(ecy.hasAmbientOcclusion(), ecy.getGuiLight().lightLikeBlock(), boolean3, ecy.getTransforms(), edd);
        }
        
        private Builder(final boolean boolean1, final boolean boolean2, final boolean boolean3, final ItemTransforms edf, final ItemOverrides edd) {
            this.unculledFaces = Lists.newArrayList();
            this.culledFaces = Maps.newEnumMap(Direction.class);
            for (final Direction fz10 : Direction.values()) {
                this.culledFaces.put(fz10, Lists.newArrayList());
            }
            this.overrides = edd;
            this.hasAmbientOcclusion = boolean1;
            this.usesBlockLight = boolean2;
            this.isGui3d = boolean3;
            this.transforms = edf;
        }
        
        public Builder addCulledFace(final Direction fz, final BakedQuad ect) {
            this.culledFaces.get(fz).add(ect);
            return this;
        }
        
        public Builder addUnculledFace(final BakedQuad ect) {
            this.unculledFaces.add(ect);
            return this;
        }
        
        public Builder particle(final TextureAtlasSprite elv) {
            this.particleIcon = elv;
            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);
        }
    }
}
