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

import java.util.Set;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.levelgen.feature.configurations.SmallTreeConfiguration;
import java.util.Random;
import net.minecraft.world.level.LevelSimulatedRW;
import com.mojang.datafixers.Dynamic;

public class AcaciaFoliagePlacer extends FoliagePlacer {
    public AcaciaFoliagePlacer(final int integer1, final int integer2) {
        super(integer1, integer2, FoliagePlacerType.ACACIA_FOLIAGE_PLACER);
    }
    
    public <T> AcaciaFoliagePlacer(final Dynamic<T> dynamic) {
        this(dynamic.get("radius").asInt(0), dynamic.get("radius_random").asInt(0));
    }
    
    @Override
    public void createFoliage(final LevelSimulatedRW bkb, final Random random, final SmallTreeConfiguration chi, final int integer4, final int integer5, final int integer6, final BlockPos fk, final Set<BlockPos> set) {
        chi.foliagePlacer.placeLeavesRow(bkb, random, chi, integer4, fk, 0, integer6, set);
        chi.foliagePlacer.placeLeavesRow(bkb, random, chi, integer4, fk, 1, 1, set);
        final BlockPos fk2 = fk.above();
        for (int integer7 = -1; integer7 <= 1; ++integer7) {
            for (int integer8 = -1; integer8 <= 1; ++integer8) {
                this.placeLeaf(bkb, random, fk2.offset(integer7, 0, integer8), chi, set);
            }
        }
        for (int integer7 = 2; integer7 <= integer6 - 1; ++integer7) {
            this.placeLeaf(bkb, random, fk2.east(integer7), chi, set);
            this.placeLeaf(bkb, random, fk2.west(integer7), chi, set);
            this.placeLeaf(bkb, random, fk2.south(integer7), chi, set);
            this.placeLeaf(bkb, random, fk2.north(integer7), chi, set);
        }
    }
    
    @Override
    public int foliageRadius(final Random random, final int integer2, final int integer3, final SmallTreeConfiguration chi) {
        return this.radius + random.nextInt(this.radiusRandom + 1);
    }
    
    @Override
    protected boolean shouldSkipLocation(final Random random, final int integer2, final int integer3, final int integer4, final int integer5, final int integer6) {
        return Math.abs(integer3) == integer6 && Math.abs(integer5) == integer6 && integer6 > 0;
    }
    
    @Override
    public int getTreeRadiusForHeight(final int integer1, final int integer2, final int integer3, final int integer4) {
        return (integer4 == 0) ? 0 : 2;
    }
}
