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

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.BeardedStructureStart;
import net.minecraft.world.level.levelgen.feature.configurations.FeatureConfiguration;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.world.level.biome.BiomeSource;
import net.minecraft.world.level.chunk.ChunkGenerator;
import com.mojang.serialization.Codec;
import net.minecraft.world.level.levelgen.feature.configurations.MultiJigsawConfiguration;

public class BastionFeature extends StructureFeature<MultiJigsawConfiguration> {
    public BastionFeature(final Codec<MultiJigsawConfiguration> codec) {
        super(codec);
    }
    
    @Override
    protected boolean isFeatureChunk(final ChunkGenerator cha, final BiomeSource brh, final long long3, final WorldgenRandom ciy, final int integer5, final int integer6, final Biome bre, final ChunkPos bph, final MultiJigsawConfiguration cnx) {
        return ciy.nextInt(5) >= 2;
    }
    
    @Override
    public StructureStartFactory<MultiJigsawConfiguration> getStartFactory() {
        return FeatureStart::new;
    }
    
    public static class FeatureStart extends BeardedStructureStart<MultiJigsawConfiguration> {
        public FeatureStart(final StructureFeature<MultiJigsawConfiguration> cml, final int integer2, final int integer3, final BoundingBox ctd, final int integer5, final long long6) {
            super(cml, integer2, integer3, ctd, integer5, long6);
        }
        
        @Override
        public void generatePieces(final ChunkGenerator cha, final StructureManager cva, final int integer3, final int integer4, final Biome bre, final MultiJigsawConfiguration cnx) {
            final BlockPos fu8 = new BlockPos(integer3 * 16, 33, integer4 * 16);
            BastionPieces.addPieces(cha, cva, fu8, this.pieces, this.random, cnx);
            this.calculateBoundingBox();
        }
    }
}
