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

import net.minecraft.world.level.block.state.StateHolder;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.SnowyDirtBlock;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.LevelReader;
import net.minecraft.core.Direction;
import net.minecraft.core.Vec3i;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.core.BlockPos;
import java.util.Random;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
import com.mojang.serialization.Codec;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;

public class SnowAndFreezeFeature extends Feature<NoneFeatureConfiguration> {
    public SnowAndFreezeFeature(final Codec<NoneFeatureConfiguration> codec) {
        super(codec);
    }
    
    @Override
    public boolean place(final WorldGenLevel bqu, final StructureFeatureManager bqq, final ChunkGenerator cha, final Random random, final BlockPos fu, final NoneFeatureConfiguration coa) {
        final BlockPos.MutableBlockPos a8 = new BlockPos.MutableBlockPos();
        final BlockPos.MutableBlockPos a9 = new BlockPos.MutableBlockPos();
        for (int integer10 = 0; integer10 < 16; ++integer10) {
            for (int integer11 = 0; integer11 < 16; ++integer11) {
                final int integer12 = fu.getX() + integer10;
                final int integer13 = fu.getZ() + integer11;
                final int integer14 = bqu.getHeight(Heightmap.Types.MOTION_BLOCKING, integer12, integer13);
                a8.set(integer12, integer14, integer13);
                a9.set(a8).move(Direction.DOWN, 1);
                final Biome bre15 = bqu.getBiome(a8);
                if (bre15.shouldFreeze(bqu, a9, false)) {
                    bqu.setBlock(a9, Blocks.ICE.defaultBlockState(), 2);
                }
                if (bre15.shouldSnow(bqu, a8)) {
                    bqu.setBlock(a8, Blocks.SNOW.defaultBlockState(), 2);
                    final BlockState cfj16 = bqu.getBlockState(a9);
                    if (cfj16.<Comparable>hasProperty((Property<Comparable>)SnowyDirtBlock.SNOWY)) {
                        bqu.setBlock(a9, ((StateHolder<O, BlockState>)cfj16).<Comparable, Boolean>setValue((Property<Comparable>)SnowyDirtBlock.SNOWY, true), 2);
                    }
                }
            }
        }
        return true;
    }
}
