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

import java.util.Random;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager;
import net.minecraft.world.level.chunk.ChunkGenerator;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import com.google.common.collect.Lists;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.structure.SwamplandHutPiece;
import net.minecraft.world.level.levelgen.structure.StructurePiece;
import net.minecraft.world.level.levelgen.structure.StructureStart;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.LevelAccessor;
import com.mojang.datafixers.Dynamic;
import java.util.function.Function;
import net.minecraft.world.level.biome.Biome;
import java.util.List;
import net.minecraft.world.level.levelgen.feature.configurations.NoneFeatureConfiguration;

public class SwamplandHutFeature extends RandomScatteredFeature<NoneFeatureConfiguration> {
    private static final List<Biome.SpawnerData> SWAMPHUT_ENEMIES;
    private static final List<Biome.SpawnerData> SWAMPHUT_ANIMALS;
    
    public SwamplandHutFeature(final Function<Dynamic<?>, ? extends NoneFeatureConfiguration> function) {
        super(function);
    }
    
    @Override
    public String getFeatureName() {
        return "Swamp_Hut";
    }
    
    @Override
    public int getLookupRange() {
        return 3;
    }
    
    @Override
    public StructureStartFactory getStartFactory() {
        return FeatureStart::new;
    }
    
    @Override
    protected int getRandomSalt() {
        return 14357620;
    }
    
    @Override
    public List<Biome.SpawnerData> getSpecialEnemies() {
        return SwamplandHutFeature.SWAMPHUT_ENEMIES;
    }
    
    @Override
    public List<Biome.SpawnerData> getSpecialAnimals() {
        return SwamplandHutFeature.SWAMPHUT_ANIMALS;
    }
    
    public boolean isSwamphut(final LevelAccessor bjx, final BlockPos fk) {
        final StructureStart clv4 = this.getStructureAt(bjx, fk, true);
        if (clv4 == StructureStart.INVALID_START || !(clv4 instanceof FeatureStart) || clv4.getPieces().isEmpty()) {
            return false;
        }
        final StructurePiece clu5 = clv4.getPieces().get(0);
        return clu5 instanceof SwamplandHutPiece;
    }
    
    static {
        SWAMPHUT_ENEMIES = Lists.<Biome.SpawnerData>newArrayList(new Biome.SpawnerData(EntityType.WITCH, 1, 1, 1));
        SWAMPHUT_ANIMALS = Lists.<Biome.SpawnerData>newArrayList(new Biome.SpawnerData(EntityType.CAT, 1, 1, 1));
    }
    
    public static class FeatureStart extends StructureStart {
        public FeatureStart(final StructureFeature<?> cfl, final int integer2, final int integer3, final BoundingBox clb, final int integer5, final long long6) {
            super(cfl, integer2, integer3, clb, integer5, long6);
        }
        
        @Override
        public void generatePieces(final ChunkGenerator<?> caa, final StructureManager cmo, final int integer3, final int integer4, final Biome bkt) {
            final SwamplandHutPiece clw7 = new SwamplandHutPiece(this.random, integer3 * 16, integer4 * 16);
            this.pieces.add(clw7);
            this.calculateBoundingBox();
        }
    }
}
