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

import net.minecraft.world.level.material.Fluid;
import java.util.Set;
import net.minecraft.world.level.block.state.BlockState;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.BitSet;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.chunk.ChunkAccess;
import java.util.Random;
import net.minecraft.world.level.material.FlowingFluid;
import net.minecraft.world.level.material.Fluids;
import com.google.common.collect.ImmutableSet;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.levelgen.feature.configurations.ProbabilityFeatureConfiguration;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;

public class HellCaveWorldCarver extends CaveWorldCarver {
    public HellCaveWorldCarver(final Function<Dynamic<?>, ? extends ProbabilityFeatureConfiguration> function) {
        super(function, 128);
        this.replaceableBlocks = ImmutableSet.<Block>of(Blocks.STONE, Blocks.GRANITE, Blocks.DIORITE, Blocks.ANDESITE, Blocks.DIRT, Blocks.COARSE_DIRT, new Block[] { Blocks.PODZOL, Blocks.GRASS_BLOCK, Blocks.NETHERRACK });
        this.liquids = ImmutableSet.of(Fluids.LAVA, Fluids.WATER);
    }
    
    @Override
    protected int getCaveBound() {
        return 10;
    }
    
    @Override
    protected float getThickness(final Random random) {
        return (random.nextFloat() * 2.0f + random.nextFloat()) * 2.0f;
    }
    
    @Override
    protected double getYScale() {
        return 5.0;
    }
    
    @Override
    protected int getCaveY(final Random random) {
        return random.nextInt(this.genHeight);
    }
    
    @Override
    protected boolean carveBlock(final ChunkAccess bzy, final Function<BlockPos, Biome> function, final BitSet bitSet, final Random random, final BlockPos.MutableBlockPos a5, final BlockPos.MutableBlockPos a6, final BlockPos.MutableBlockPos a7, final int integer8, final int integer9, final int integer10, final int integer11, final int integer12, final int integer13, final int integer14, final int integer15, final AtomicBoolean atomicBoolean) {
        final int integer16 = integer13 | integer15 << 4 | integer14 << 8;
        if (bitSet.get(integer16)) {
            return false;
        }
        bitSet.set(integer16);
        a5.set(integer11, integer14, integer12);
        if (this.canReplaceBlock(bzy.getBlockState(a5))) {
            BlockState byj19;
            if (integer14 <= 31) {
                byj19 = HellCaveWorldCarver.LAVA.createLegacyBlock();
            }
            else {
                byj19 = HellCaveWorldCarver.CAVE_AIR;
            }
            bzy.setBlockState(a5, byj19, false);
            return true;
        }
        return false;
    }
}
