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 BlobFoliagePlacer extends FoliagePlacer {
    public BlobFoliagePlacer(final int integer1, final int integer2) {
        super(integer1, integer2, FoliagePlacerType.BLOB_FOLIAGE_PLACER);
    }
    
    public <T> BlobFoliagePlacer(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) {
        for (int integer7 = integer4; integer7 >= integer5; --integer7) {
            final int integer8 = Math.max(integer6 - 1 - (integer7 - integer4) / 2, 0);
            this.placeLeavesRow(bkb, random, chi, integer4, fk, integer7, integer8, 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 && (random.nextInt(2) == 0 || integer4 == integer2);
    }
    
    @Override
    public int getTreeRadiusForHeight(final int integer1, final int integer2, final int integer3, final int integer4) {
        return (integer4 != 0) ? 1 : 0;
    }
}
