package net.minecraft.world.level.levelgen.feature; import com.mojang.serialization.Codec; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration; public class EndIslandFeature extends Feature { public EndIslandFeature(final Codec codec) { super(codec); } @Override public boolean place(final FeaturePlaceContext context) { WorldGenLevel level = context.level(); RandomSource random = context.random(); BlockPos origin = context.origin(); float size = random.nextInt(3) + 4.0F; for (int y = 0; size > 0.5F; y--) { for (int x = Mth.floor(-size); x <= Mth.ceil(size); x++) { for (int z = Mth.floor(-size); z <= Mth.ceil(size); z++) { if (x * x + z * z <= (size + 1.0F) * (size + 1.0F)) { this.setBlock(level, origin.offset(x, y, z), Blocks.END_STONE.defaultBlockState()); } } } size -= random.nextInt(2) + 0.5F; } return true; } }