package net.minecraft.world.level.levelgen.flat;

import java.util.function.BiFunction;
import com.mojang.datafixers.kinds.Applicative;
import net.minecraft.world.level.block.Blocks;
import java.util.function.Function;
import net.minecraft.util.Codecs;
import com.mojang.datafixers.kinds.App;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.core.Registry;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import com.mojang.serialization.Codec;

public class FlatLayerInfo {
    public static final Codec<FlatLayerInfo> CODEC;
    private final BlockState blockState;
    private final int height;
    private int start;
    
    public FlatLayerInfo(final int integer, final Block bvr) {
        this.height = integer;
        this.blockState = bvr.defaultBlockState();
    }
    
    public int getHeight() {
        return this.height;
    }
    
    public BlockState getBlockState() {
        return this.blockState;
    }
    
    public int getStart() {
        return this.start;
    }
    
    public void setStart(final int integer) {
        this.start = integer;
    }
    
    @Override
    public String toString() {
        return ((this.height != 1) ? (this.height + "*") : "") + Registry.BLOCK.getKey(this.blockState.getBlock());
    }
    
    static {
        CODEC = RecordCodecBuilder.create(instance -> ((RecordCodecBuilder.Instance)instance).group((App)Codecs.intRange(0, 256).fieldOf("height").forGetter((Function)FlatLayerInfo::getHeight), (App)Registry.BLOCK.fieldOf("block").withDefault(Blocks.AIR).forGetter(cqz -> cqz.getBlockState().getBlock())).apply(instance, (BiFunction)FlatLayerInfo::new));
    }
}
