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 java.util.Iterator;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.WallTorchBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.core.Direction;
import net.minecraft.world.level.LevelWriter;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.core.Vec3i;
import java.util.Random;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.StructureFeatureManager;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;

public class EndPodiumFeature extends Feature<NoneFeatureConfiguration> {
    public static final BlockPos END_PODIUM_LOCATION;
    private final boolean active;
    
    public EndPodiumFeature(final boolean boolean1) {
        super(NoneFeatureConfiguration.CODEC);
        this.active = boolean1;
    }
    
    @Override
    public boolean place(final WorldGenLevel bqu, final StructureFeatureManager bqq, final ChunkGenerator cha, final Random random, final BlockPos fu, final NoneFeatureConfiguration coa) {
        for (final BlockPos fu2 : BlockPos.betweenClosed(new BlockPos(fu.getX() - 4, fu.getY() - 1, fu.getZ() - 4), new BlockPos(fu.getX() + 4, fu.getY() + 32, fu.getZ() + 4))) {
            final boolean boolean10 = fu2.closerThan(fu, 2.5);
            if (boolean10 || fu2.closerThan(fu, 3.5)) {
                if (fu2.getY() < fu.getY()) {
                    if (boolean10) {
                        this.setBlock(bqu, fu2, Blocks.BEDROCK.defaultBlockState());
                    }
                    else {
                        if (fu2.getY() >= fu.getY()) {
                            continue;
                        }
                        this.setBlock(bqu, fu2, Blocks.END_STONE.defaultBlockState());
                    }
                }
                else if (fu2.getY() > fu.getY()) {
                    this.setBlock(bqu, fu2, Blocks.AIR.defaultBlockState());
                }
                else if (!boolean10) {
                    this.setBlock(bqu, fu2, Blocks.BEDROCK.defaultBlockState());
                }
                else if (this.active) {
                    this.setBlock(bqu, new BlockPos(fu2), Blocks.END_PORTAL.defaultBlockState());
                }
                else {
                    this.setBlock(bqu, new BlockPos(fu2), Blocks.AIR.defaultBlockState());
                }
            }
        }
        for (int integer8 = 0; integer8 < 4; ++integer8) {
            this.setBlock(bqu, fu.above(integer8), Blocks.BEDROCK.defaultBlockState());
        }
        final BlockPos fu3 = fu.above(2);
        for (final Direction fz10 : Direction.Plane.HORIZONTAL) {
            this.setBlock(bqu, fu3.relative(fz10), ((StateHolder<O, BlockState>)Blocks.WALL_TORCH.defaultBlockState()).<Comparable, Direction>setValue((Property<Comparable>)WallTorchBlock.FACING, fz10));
        }
        return true;
    }
    
    static {
        END_PODIUM_LOCATION = BlockPos.ZERO;
    }
}
