Worked on loading chunks
This commit is contained in:
parent
3cd72ef89b
commit
9f8366711f
|
@ -0,0 +1 @@
|
|||
generate_data/
|
|
@ -9,10 +9,16 @@ from typing import List
|
|||
from twisted.internet import reactor
|
||||
from quarry.net.server import ServerFactory, ServerProtocol
|
||||
from quarry.types.uuid import UUID
|
||||
from quarry.types.chunk import BlockArray, PackedArray
|
||||
from quarry.types.registry import LookupRegistry
|
||||
import quarry.types.nbt as NBT
|
||||
from quarry.data.data_packs import data_packs, dimension_types
|
||||
|
||||
|
||||
FOREST_BIOME_DATA_PACK_ID = 7
|
||||
# java -DbundlerMainClass=net.minecraft.data.Main -jar minecraft_server.jar --reports
|
||||
REGISTRY = LookupRegistry.from_json(r'generate_data\generated\reports')
|
||||
CHUNKS_TALL = 28
|
||||
|
||||
|
||||
class YTDServerProtocol(ServerProtocol):
|
||||
|
@ -47,6 +53,8 @@ class YTDServerProtocol(ServerProtocol):
|
|||
# Send full player list
|
||||
self.factory.send_player_list_add(self, self.factory.players)
|
||||
|
||||
self.send_chunk(0,0)
|
||||
|
||||
def send_join_game(self):
|
||||
# Build up fields for "Join Game" packet
|
||||
entity_id = 0
|
||||
|
@ -109,22 +117,24 @@ class YTDServerProtocol(ServerProtocol):
|
|||
|
||||
buff.discard()
|
||||
|
||||
def send_chunk(self, x, z, full, heightmap, sections, biomes):
|
||||
# sections = self.factory.generate(x,z)
|
||||
sections_data = self.bt.pack_chunk(sections)
|
||||
# def send_chunk(self, x, z, full, heightmap, sections, biomes):
|
||||
def send_chunk(self, x, z):
|
||||
sections, heightmap = self.factory.generate(x,z)
|
||||
sections_data = self.buff_type.pack_chunk(sections)
|
||||
self.send_packet(
|
||||
'unload_chunk',
|
||||
self.bt.pack('ii', x, z),
|
||||
self.buff_type.pack('ii', x, z),
|
||||
)
|
||||
self.send_packet(
|
||||
'chunk_data',
|
||||
self.bt.pack('ii?', x, z, full),
|
||||
self.bt.pack_chunk_bitmask(sections),
|
||||
self.bt.pack_nbt(heightmap),
|
||||
self.bt.pack_array('I', biomes) if full else b'',
|
||||
self.bt.pack_varint(len(sections_data)),
|
||||
self.buff_type.pack('ii', x, z),
|
||||
# # self.buff_type.pack('ii?', x, z, full),
|
||||
# # self.buff_type.pack_chunk_bitmask(sections),
|
||||
self.buff_type.pack_nbt(heightmap),
|
||||
# # self.buff_type.pack_array('I', biomes) if full else b'',
|
||||
self.buff_type.pack_varint(len(sections_data)),
|
||||
sections_data,
|
||||
self.bt.pack_varint(0), # Always zero block entities
|
||||
self.buff_type.pack_varint(0), # Always zero block entities
|
||||
)
|
||||
|
||||
|
||||
|
@ -208,6 +218,18 @@ class YTDServerFactory(ServerFactory):
|
|||
player.buff_type.pack_varint(1), # Player entry count
|
||||
player.buff_type.pack_uuid(removed.uuid)) # Player UUID
|
||||
|
||||
def generate(self, x, z):
|
||||
sections = []
|
||||
for _ in range(CHUNKS_TALL):
|
||||
sections.append((BlockArray.empty(REGISTRY),None,None))
|
||||
for sec in sections:
|
||||
sec[0][0] = {'name': 'minecraft:grass_block', 'snowy': 'false'}
|
||||
# height_map = NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})
|
||||
# height_map = NBT.TagRoot(NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())}))
|
||||
# height_map = NBT.TagRoot({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})
|
||||
height_map = NBT.TagRoot({'':NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})})
|
||||
return sections, height_map
|
||||
|
||||
|
||||
def main(argv):
|
||||
# Parse options
|
||||
|
|
Loading…
Reference in New Issue