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 FlippedmushroomAdditionalGenerationConditionProcedure {
	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 = i * 3 / 4;
				for (int j = 0; j < height ; j++) {

					if (world.getBlockState(BlockPos.containing(x, y+i-j-1, z)).canOcclude()) { return true;}

					world.setBlock(BlockPos.containing(x, y + i-j, z), Blocks.MUSHROOM_STEM.defaultBlockState(), 3);

					if (Mth.nextInt(RandomSource.create(), 1, 4)==2){
						world.setBlock(BlockPos.containing(x+1, y + i-j, z), Blocks.RED_MUSHROOM_BLOCK.defaultBlockState(), 3);
						world.setBlock(BlockPos.containing(x-1, y + i-j, z), Blocks.RED_MUSHROOM_BLOCK.defaultBlockState(), 3);
						world.setBlock(BlockPos.containing(x, y + i-j, z+1), Blocks.RED_MUSHROOM_BLOCK.defaultBlockState(), 3);
						world.setBlock(BlockPos.containing(x, y + i-j, z-1), Blocks.RED_MUSHROOM_BLOCK.defaultBlockState(), 3);
					}
					
					if (Mth.nextInt(RandomSource.create(), 1, 5)==2){
						world.setBlock(BlockPos.containing(x+1, y + i-j, z), Blocks.BROWN_MUSHROOM_BLOCK.defaultBlockState(), 3);
						world.setBlock(BlockPos.containing(x-1, y + i-j, z), Blocks.BROWN_MUSHROOM_BLOCK.defaultBlockState(), 3);
						world.setBlock(BlockPos.containing(x, y + i-j, z+1), Blocks.BROWN_MUSHROOM_BLOCK.defaultBlockState(), 3);
						world.setBlock(BlockPos.containing(x, y + i-j, z-1), Blocks.BROWN_MUSHROOM_BLOCK.defaultBlockState(), 3);
					}

				}
				world.setBlock(BlockPos.containing(x, y + i-height, z), Blocks.SHROOMLIGHT.defaultBlockState(), 3);

				return true;
			}
			
		}
		return true;
	}
}
