// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.builtin.hytalegenerator.assets.materialproviders;

import com.hypixel.hytale.codec.KeyedCodec;
import com.hypixel.hytale.codec.Codec;
import com.hypixel.hytale.builtin.hytalegenerator.materialproviders.DownwardDepthMaterialProvider;
import com.hypixel.hytale.builtin.hytalegenerator.material.Material;
import com.hypixel.hytale.builtin.hytalegenerator.materialproviders.MaterialProvider;
import javax.annotation.Nonnull;
import com.hypixel.hytale.codec.builder.BuilderCodec;

public class DownwardDepthMaterialProviderAsset extends MaterialProviderAsset
{
    public static final BuilderCodec<DownwardDepthMaterialProviderAsset> CODEC;
    private int depth;
    private MaterialProviderAsset materialProviderAsset;
    
    public DownwardDepthMaterialProviderAsset() {
        this.depth = 0;
        this.materialProviderAsset = new ConstantMaterialProviderAsset();
    }
    
    @Nonnull
    @Override
    public MaterialProvider<Material> build(@Nonnull final Argument argument) {
        if (super.skip()) {
            return MaterialProvider.noMaterialProvider();
        }
        return new DownwardDepthMaterialProvider<Material>(this.materialProviderAsset.build(argument), this.depth);
    }
    
    @Override
    public void cleanUp() {
        this.materialProviderAsset.cleanUp();
    }
    
    static {
        CODEC = BuilderCodec.builder(DownwardDepthMaterialProviderAsset.class, DownwardDepthMaterialProviderAsset::new, MaterialProviderAsset.ABSTRACT_CODEC).append(new KeyedCodec<Integer>("Depth", Codec.INTEGER, true), (t, k) -> t.depth = k, k -> k.depth).add().append(new KeyedCodec("Material", MaterialProviderAsset.CODEC, true), (t, k) -> t.materialProviderAsset = k, k -> k.materialProviderAsset).add().build();
    }
}
