package net.minecraft.world.level.levelgen.feature.configurations;

import com.google.common.collect.ImmutableList;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.DynamicOps;
import net.minecraft.world.level.levelgen.feature.treedecorators.TreeDecorator;
import java.util.List;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;

public class MegaTreeConfiguration extends TreeConfiguration {
    public final int heightInterval;
    public final int crownHeight;
    
    protected MegaTreeConfiguration(final BlockStateProvider chw1, final BlockStateProvider chw2, final List<TreeDecorator> list, final int integer4, final int integer5, final int integer6) {
        super(chw1, chw2, list, integer4);
        this.heightInterval = integer5;
        this.crownHeight = integer6;
    }
    
    @Override
    public <T> Dynamic<T> serialize(final DynamicOps<T> dynamicOps) {
        final Dynamic<T> dynamic3 = (Dynamic<T>)new Dynamic((DynamicOps)dynamicOps, dynamicOps.createMap((Map)ImmutableMap.of(dynamicOps.createString("height_interval"), dynamicOps.createInt(this.heightInterval), dynamicOps.createString("crown_height"), dynamicOps.createInt(this.crownHeight))));
        return (Dynamic<T>)dynamic3.merge((Dynamic)super.<T>serialize(dynamicOps));
    }
    
    public static <T> MegaTreeConfiguration deserialize(final Dynamic<T> dynamic) {
        final TreeConfiguration chl2 = TreeConfiguration.<T>deserialize(dynamic);
        return new MegaTreeConfiguration(chl2.trunkProvider, chl2.leavesProvider, chl2.decorators, chl2.baseHeight, dynamic.get("height_interval").asInt(0), dynamic.get("crown_height").asInt(0));
    }
    
    public static class MegaTreeConfigurationBuilder extends TreeConfigurationBuilder {
        private List<TreeDecorator> decorators;
        private int baseHeight;
        private int heightInterval;
        private int crownHeight;
        
        public MegaTreeConfigurationBuilder(final BlockStateProvider chw1, final BlockStateProvider chw2) {
            super(chw1, chw2);
            this.decorators = ImmutableList.of();
        }
        
        public MegaTreeConfigurationBuilder decorators(final List<TreeDecorator> list) {
            this.decorators = list;
            return this;
        }
        
        @Override
        public MegaTreeConfigurationBuilder baseHeight(final int integer) {
            this.baseHeight = integer;
            return this;
        }
        
        public MegaTreeConfigurationBuilder heightInterval(final int integer) {
            this.heightInterval = integer;
            return this;
        }
        
        public MegaTreeConfigurationBuilder crownHeight(final int integer) {
            this.crownHeight = integer;
            return this;
        }
        
        @Override
        public MegaTreeConfiguration build() {
            return new MegaTreeConfiguration(this.trunkProvider, this.leavesProvider, this.decorators, this.baseHeight, this.heightInterval, this.crownHeight);
        }
    }
}
