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 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.levelgen.ChunkGeneratorSettings;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.LevelAccessor;
import java.util.function.Function;
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::deserialize);
        this.active = boolean1;
    }
    
    @Override
    public boolean place(final LevelAccessor bjx, final ChunkGenerator<? extends ChunkGeneratorSettings> caa, final Random random, final BlockPos fk, final NoneFeatureConfiguration cgv) {
        for (final BlockPos fk2 : BlockPos.betweenClosed(new BlockPos(fk.getX() - 4, fk.getY() - 1, fk.getZ() - 4), new BlockPos(fk.getX() + 4, fk.getY() + 32, fk.getZ() + 4))) {
            final boolean boolean9 = fk2.closerThan(fk, 2.5);
            if (boolean9 || fk2.closerThan(fk, 3.5)) {
                if (fk2.getY() < fk.getY()) {
                    if (boolean9) {
                        this.setBlock(bjx, fk2, Blocks.BEDROCK.defaultBlockState());
                    }
                    else {
                        if (fk2.getY() >= fk.getY()) {
                            continue;
                        }
                        this.setBlock(bjx, fk2, Blocks.END_STONE.defaultBlockState());
                    }
                }
                else if (fk2.getY() > fk.getY()) {
                    this.setBlock(bjx, fk2, Blocks.AIR.defaultBlockState());
                }
                else if (!boolean9) {
                    this.setBlock(bjx, fk2, Blocks.BEDROCK.defaultBlockState());
                }
                else if (this.active) {
                    this.setBlock(bjx, new BlockPos(fk2), Blocks.END_PORTAL.defaultBlockState());
                }
                else {
                    this.setBlock(bjx, new BlockPos(fk2), Blocks.AIR.defaultBlockState());
                }
            }
        }
        for (int integer7 = 0; integer7 < 4; ++integer7) {
            this.setBlock(bjx, fk.above(integer7), Blocks.BEDROCK.defaultBlockState());
        }
        final BlockPos fk3 = fk.above(2);
        for (final Direction fp9 : Direction.Plane.HORIZONTAL) {
            this.setBlock(bjx, fk3.relative(fp9), ((AbstractStateHolder<O, BlockState>)Blocks.WALL_TORCH.defaultBlockState()).<Comparable, Direction>setValue((Property<Comparable>)WallTorchBlock.FACING, fp9));
        }
        return true;
    }
    
    static {
        END_PODIUM_LOCATION = BlockPos.ZERO;
    }
}
