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 PineFoliagePlacer extends FoliagePlacer {
    public PineFoliagePlacer(final int integer1, final int integer2) {
        super(integer1, integer2, FoliagePlacerType.PINE_FOLIAGE_PLACER);
    }
    
    public <T> PineFoliagePlacer(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) {
        int integer7 = 0;
        for (int integer8 = integer4; integer8 >= integer5; --integer8) {
            this.placeLeavesRow(bkb, random, chi, integer4, fk, integer8, integer7, set);
            if (integer7 >= 1 && integer8 == integer5 + 1) {
                --integer7;
            }
            else if (integer7 < integer6) {
                ++integer7;
            }
        }
    }
    
    @Override
    public int foliageRadius(final Random random, final int integer2, final int integer3, final SmallTreeConfiguration chi) {
        return this.radius + random.nextInt(this.radiusRandom + 1) + random.nextInt(integer3 - integer2 + 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 <= 1) ? 0 : 2;
    }
}
