package eu.mhsl.minenet.minigames.world.generator.structures.generatable;

import eu.mhsl.minenet.minigames.world.BlockPallet;
import eu.mhsl.minenet.minigames.world.generator.structures.Structure;
import net.minestom.server.coordinate.Point;
import net.minestom.server.instance.block.Block;

public class PeakRock extends Structure {
    private final Point position;
    private final BlockPallet blockPallet;
    public PeakRock(Point position, BlockPallet blockPallet) {
        this.position = position;
        this.blockPallet = blockPallet;
    }

    @Override
    public void generateStructure(Block.Setter setter) {
        for (int stoneX = -4; stoneX < 4; stoneX++) {
            for (int stoneZ = -4; stoneZ < 4; stoneZ++) {

                double distanceToCenter = position.add(stoneX, 0, stoneZ).distance(position);
                if(distanceToCenter > 3) continue;

                for (int stoneY = 0; stoneY < 10-(int) distanceToCenter * rnd.nextDouble(2, 5); stoneY++) {
                    Point blockPos = position.add(stoneX, stoneY, stoneZ);
                    setter.setBlock(blockPos, this.blockPallet.rnd());
                }
            }
        }
    }
}
