Experimenting with chunk generation

This commit is contained in:
Kyler 2024-04-17 23:03:19 -06:00
parent f1cefdce0b
commit 84a69905a6
1 changed files with 17 additions and 3 deletions

View File

@ -44,6 +44,11 @@ if not os.path.exists("generate_data"): bootstrap_server_data()
REGISTRY = LookupRegistry.from_json(r'generate_data\generated\reports')
CHUNKS_TALL = 28
BLOCK_EMPTY = {'name': 'minecraft:air'}
BLOCK_SURFACE = {'name': 'minecraft:grass_block', 'snowy': 'false'}
BLOCK_SUBSURFACE = {'name': 'minecraft:dirt'}
BLOCK_UNDERGROUND = {'name': 'minecraft:stone'}
class Buffer_1_18_2(Buffer1_14):
@ -295,13 +300,22 @@ class YTDServerFactory(ServerFactory):
player.buff_type.pack_uuid(removed.uuid)) # Player UUID
def generate(self, x, z):
# array[y][z][x]
array = lambda x, y, z: (y * 16 * 16) + (z * 16) + x
chunk_range = lambda: [(array(x,y,z), x,y,z) for x in range(16) for y in range(16) for z in range(16)]
sections = []
for _ in range(CHUNKS_TALL):
sections.append(BlockArray.empty(REGISTRY))
for sec in sections:
sec[0] = {'name': 'minecraft:grass_block', 'snowy': 'false'}
for i in range(1,16*16*16):
sec[i] = {'name': 'minecraft:air'}
for i, xi, yi, zi in chunk_range():
if xi == yi and yi == zi:
sec[i] = BLOCK_SURFACE
elif xi == (yi+1)%16 and (yi+1)%16 == zi:
sec[i] = BLOCK_SUBSURFACE
elif xi == (yi+2)%16 and (yi+2)%16 == zi:
sec[i] = BLOCK_UNDERGROUND
else:
sec[i] = BLOCK_EMPTY
height_map = NBT.TagRoot({'':NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})})
return sections, height_map