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

import net.minecraft.world.level.block.state.AbstractStateHolder;
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.levelgen.ChunkGeneratorSettings;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.LevelAccessor;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;

public class SnowAndFreezeFeature extends Feature<NoneFeatureConfiguration> {
    public SnowAndFreezeFeature(final Function<Dynamic<?>, ? extends NoneFeatureConfiguration> function) {
        super(function);
    }
    
    @Override
    public boolean place(final LevelAccessor bjx, final ChunkGenerator<? extends ChunkGeneratorSettings> caa, final Random random, final BlockPos fk, final NoneFeatureConfiguration cgv) {
        final BlockPos.MutableBlockPos a7 = new BlockPos.MutableBlockPos();
        final BlockPos.MutableBlockPos a8 = new BlockPos.MutableBlockPos();
        for (int integer9 = 0; integer9 < 16; ++integer9) {
            for (int integer10 = 0; integer10 < 16; ++integer10) {
                final int integer11 = fk.getX() + integer9;
                final int integer12 = fk.getZ() + integer10;
                final int integer13 = bjx.getHeight(Heightmap.Types.MOTION_BLOCKING, integer11, integer12);
                a7.set(integer11, integer13, integer12);
                a8.set(a7).move(Direction.DOWN, 1);
                final Biome bkt14 = bjx.getBiome(a7);
                if (bkt14.shouldFreeze(bjx, a8, false)) {
                    bjx.setBlock(a8, Blocks.ICE.defaultBlockState(), 2);
                }
                if (bkt14.shouldSnow(bjx, a7)) {
                    bjx.setBlock(a7, Blocks.SNOW.defaultBlockState(), 2);
                    final BlockState byj15 = bjx.getBlockState(a8);
                    if (byj15.<Comparable>hasProperty((Property<Comparable>)SnowyDirtBlock.SNOWY)) {
                        bjx.setBlock(a8, ((AbstractStateHolder<O, BlockState>)byj15).<Comparable, Boolean>setValue((Property<Comparable>)SnowyDirtBlock.SNOWY, true), 2);
                    }
                }
            }
        }
        return true;
    }
}
