<commit_before>﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using Alex.API.Utils;
using Alex.API.World;
using Alex.Blocks;
using Alex.Blocks.State;
using Alex.Worlds.Abstraction;
using Alex.Worlds.Chunks;
using Microsoft.Xna.Framework;
using MathF = System.MathF;


namespace Alex.Worlds.Singleplayer.Generators
{
    public class DebugWorldGenerator : IWorldGenerator
    {
	    private List<BlockState> ALL_VALID_STATES = new List<BlockState>();
	   // private BlockState AIR = BlockFactory.GetBlockState("minecraft:air");

		private readonly int GRID_WIDTH;
	    private readonly int GRID_HEIGHT;

	    public DebugWorldGenerator()
	    {
		    foreach (var state in BlockFactory.AllBlockstatesByName.OrderByDescending(
			    x => x.Value.GetVariants().Any(xx => xx.Block.Animated)))
		    {
			    foreach (var variant in state.Value.GetVariants())
			    {
				    ALL_VALID_STATES.Add(variant);
			    }
		    }

		    GRID_WIDTH = (int)MathF.Ceiling(MathF.Sqrt(ALL_VALID_STATES.Count));
		    GRID_HEIGHT = (int)MathF.Ceiling((float)ALL_VALID_STATES.Count / GRID_WIDTH);
	    }
	    
	    private ConcurrentDictionary<ChunkCoordinates, ChunkColumn> _cache = new ConcurrentDictionary<ChunkCoordinates, ChunkColumn>();
	    
		public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
		{
			return _cache.GetOrAdd(
				chunkCoordinates, (cc) =>
				{
					ChunkColumn chunk = new ChunkColumn(chunkCoordinates.X, chunkCoordinates.Z);
					for (int x = 0; x < 16; x++)
					{
						for (int z = 0; z < 16; z++)
						{
							int rx = (chunkCoordinates.X * 16) + x;
							int rz = (chunkCoordinates.Z * 16) + z;

							BlockState iblockstate = GetBlockStateFor(rx, rz);

							if (iblockstate != null)
							{
								chunk.SetBlockState(x, 1, z, iblockstate);
								//chunk.Height[((z << 4) + (x))] = 70;
							}

							// chunk.SetSkyLight(x, 70, z, 15);
							//  chunk.SetSkyLight(x, 71, z, 15);
							//  chunk.SetSkyLight(x, 69, z, 15);
						}
					}
					
					//chunk.CalculateHeight();
					return chunk;
				});
		}<commit_msg>Fix debug world skylight<commit_after>﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using Alex.API.Utils;
using Alex.API.World;
using Alex.Blocks;
using Alex.Blocks.State;
using Alex.Worlds.Abstraction;
using Alex.Worlds.Chunks;
using Microsoft.Xna.Framework;
using MathF = System.MathF;


namespace Alex.Worlds.Singleplayer.Generators
{
    public class DebugWorldGenerator : IWorldGenerator
    {
	    private List<BlockState> ALL_VALID_STATES = new List<BlockState>();
	   // private BlockState AIR = BlockFactory.GetBlockState("minecraft:air");

		private readonly int GRID_WIDTH;
	    private readonly int GRID_HEIGHT;

	    public DebugWorldGenerator()
	    {
		    foreach (var state in BlockFactory.AllBlockstatesByName.OrderByDescending(
			    x => x.Value.GetVariants().Any(xx => xx.Block.Animated)))
		    {
			    foreach (var variant in state.Value.GetVariants())
			    {
				    ALL_VALID_STATES.Add(variant);
			    }
		    }

		    GRID_WIDTH = (int)MathF.Ceiling(MathF.Sqrt(ALL_VALID_STATES.Count));
		    GRID_HEIGHT = (int)MathF.Ceiling((float)ALL_VALID_STATES.Count / GRID_WIDTH);
	    }
	    
	    private ConcurrentDictionary<ChunkCoordinates, ChunkColumn> _cache = new ConcurrentDictionary<ChunkCoordinates, ChunkColumn>();
	    
		public ChunkColumn GenerateChunkColumn(ChunkCoordinates chunkCoordinates)
		{
			return _cache.GetOrAdd(
				chunkCoordinates, (cc) =>
				{
					ChunkColumn chunk = new ChunkColumn(chunkCoordinates.X, chunkCoordinates.Z);
					for (int x = 0; x < 16; x++)
					{
						for (int z = 0; z < 16; z++)
						{
							int rx = (chunkCoordinates.X * 16) + x;
							int rz = (chunkCoordinates.Z * 16) + z;

							BlockState iblockstate = GetBlockStateFor(rx, rz);

							if (iblockstate != null)
							{
								chunk.SetBlockState(x, 1, z, iblockstate);
								//chunk.Height[((z << 4) + (x))] = 70;
							}

							chunk.SetSkyLight(x, 2, z, 15);
							//  chunk.SetSkyLight(x, 71, z, 15);
							//  chunk.SetSkyLight(x, 69, z, 15);
						}
					}
					
					//chunk.CalculateHeight();
					return chunk;
				});
		}
{'fraction_non_alphanumeric': 0.11910902696365767, 'fraction_numerical': 0.011957796014067995, 'mean_word_length': 2.953660797034291, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3226663', 'n_tokens_mistral': 1768, 'n_tokens_neox': 1371, 'n_words': 289}