Chunks loading correctly
This commit is contained in:
parent
45a1166aee
commit
f1cefdce0b
|
@ -12,6 +12,7 @@ from quarry.net.server import ServerFactory, ServerProtocol
|
||||||
from quarry.types.uuid import UUID
|
from quarry.types.uuid import UUID
|
||||||
from quarry.types.chunk import BlockArray, PackedArray
|
from quarry.types.chunk import BlockArray, PackedArray
|
||||||
from quarry.types.registry import LookupRegistry
|
from quarry.types.registry import LookupRegistry
|
||||||
|
from quarry.types.buffer.v1_14 import Buffer1_14
|
||||||
import quarry.types.nbt as NBT
|
import quarry.types.nbt as NBT
|
||||||
from quarry.data.data_packs import data_packs, dimension_types
|
from quarry.data.data_packs import data_packs, dimension_types
|
||||||
|
|
||||||
|
@ -37,19 +38,52 @@ def bootstrap_server_data():
|
||||||
process = subprocess.Popen(command, shell=True, cwd="generate_data")
|
process = subprocess.Popen(command, shell=True, cwd="generate_data")
|
||||||
process.wait()
|
process.wait()
|
||||||
|
|
||||||
FOREST_BIOME_DATA_PACK_ID = 7
|
BIOME_ID = 7 # Forest Data ID
|
||||||
# java -DbundlerMainClass=net.minecraft.data.Main -jar minecraft_server.jar --reports
|
# java -DbundlerMainClass=net.minecraft.data.Main -jar minecraft_server.jar --reports
|
||||||
if not os.path.exists("generate_data"): bootstrap_server_data()
|
if not os.path.exists("generate_data"): bootstrap_server_data()
|
||||||
REGISTRY = LookupRegistry.from_json(r'generate_data\generated\reports')
|
REGISTRY = LookupRegistry.from_json(r'generate_data\generated\reports')
|
||||||
CHUNKS_TALL = 28
|
CHUNKS_TALL = 28
|
||||||
|
|
||||||
|
|
||||||
|
class Buffer_1_18_2(Buffer1_14):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def pack_chunk(cls, sections):
|
||||||
|
data = b""
|
||||||
|
for section in sections:
|
||||||
|
if section and not section.is_empty():
|
||||||
|
data += cls.pack_chunk_section(section)
|
||||||
|
return data
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def pack_chunk_section(cls, blocks, block_lights=None, sky_lights=None):
|
||||||
|
"""
|
||||||
|
Packs a chunk section. The supplied argument should be an instance of
|
||||||
|
``quarry.types.chunk.BlockArray``.
|
||||||
|
"""
|
||||||
|
|
||||||
|
out = cls.pack('HB', blocks.non_air, blocks.storage.value_width)
|
||||||
|
out += cls.pack_chunk_section_palette(blocks.palette)
|
||||||
|
out += cls.pack_chunk_section_array(blocks.to_bytes())
|
||||||
|
out += cls.pack('B', 0) # Biome Bits Per Entry
|
||||||
|
out += cls.pack_varint(BIOME_ID) # Biome Palette
|
||||||
|
out += cls.pack_varint(0) # Biome Data Array Length
|
||||||
|
return out
|
||||||
|
|
||||||
|
def unpack_chunk(self, bitmask, overworld=True):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def unpack_chunk_section(self, overworld=True):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
class YTDServerProtocol(ServerProtocol):
|
class YTDServerProtocol(ServerProtocol):
|
||||||
|
|
||||||
def player_joined(self):
|
def player_joined(self):
|
||||||
# Call super. This switches us to "play" mode, marks the player as
|
# Call super. This switches us to "play" mode, marks the player as
|
||||||
# in-game, and does some logging.
|
# in-game, and does some logging.
|
||||||
ServerProtocol.player_joined(self)
|
ServerProtocol.player_joined(self)
|
||||||
|
self.buff_type = Buffer_1_18_2
|
||||||
|
|
||||||
# Send join game packet
|
# Send join game packet
|
||||||
self.send_join_game()
|
self.send_join_game()
|
||||||
|
@ -263,11 +297,11 @@ class YTDServerFactory(ServerFactory):
|
||||||
def generate(self, x, z):
|
def generate(self, x, z):
|
||||||
sections = []
|
sections = []
|
||||||
for _ in range(CHUNKS_TALL):
|
for _ in range(CHUNKS_TALL):
|
||||||
sections.append((BlockArray.empty(REGISTRY),None,None))
|
sections.append(BlockArray.empty(REGISTRY))
|
||||||
for sec in sections:
|
for sec in sections:
|
||||||
sec[0][0] = {'name': 'minecraft:grass_block', 'snowy': 'false'}
|
sec[0] = {'name': 'minecraft:grass_block', 'snowy': 'false'}
|
||||||
for i in range(1,16*16*16):
|
for i in range(1,16*16*16):
|
||||||
sec[0][i] = {'name': 'minecraft:air'}
|
sec[i] = {'name': 'minecraft:air'}
|
||||||
height_map = NBT.TagRoot({'':NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})})
|
height_map = NBT.TagRoot({'':NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})})
|
||||||
return sections, height_map
|
return sections, height_map
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue