package net.mcreator.cawezsmantletostratus.procedures;

import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.util.RandomSource;
import net.minecraft.util.Mth;
import net.minecraft.core.BlockPos;

public class CeilinglanternsAdditionalGenerationConditionProcedure {
	public static boolean execute(LevelAccessor world, double x, double y, double z) {
		for (int i = 1 ; i < 100 ; i++) {
			if (world.getBlockState(BlockPos.containing(x, y + i, z)).canOcclude()) {
				int height = Mth.nextInt(RandomSource.create(), -35, 0);
				for (int j = i ; j > i + height ; j--) {
					world.setBlock(BlockPos.containing(x, y + j, z), Blocks.CHAIN.defaultBlockState(), 3);
					if (world.getBlockState(BlockPos.containing(x, y + j - 1, z)).canOcclude()) {
						return true;
					}
				}
				world.setBlock(BlockPos.containing(x, y + i+height, z), Blocks.SOUL_LANTERN.defaultBlockState(), 3);

				return true;
			}
		}
		return true;
	}
}
