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

import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.LevelWriter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.util.Mth;
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 EndIslandFeature extends Feature<NoneFeatureConfiguration> {
    public EndIslandFeature(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) {
        float float8 = (float)(random.nextInt(3) + 4);
        for (int integer9 = 0; float8 > 0.5f; float8 -= (float)(random.nextInt(2) + 0.5), --integer9) {
            for (int integer10 = Mth.floor(-float8); integer10 <= Mth.ceil(float8); ++integer10) {
                for (int integer11 = Mth.floor(-float8); integer11 <= Mth.ceil(float8); ++integer11) {
                    if (integer10 * integer10 + integer11 * integer11 <= (float8 + 1.0f) * (float8 + 1.0f)) {
                        this.setBlock(bqu, fu.offset(integer10, integer9, integer11), Blocks.END_STONE.defaultBlockState());
                    }
                }
            }
        }
        return true;
    }
}
