Functions Rendering
This commit is contained in:
parent
1d9dafe0bd
commit
c5eed3b918
|
@ -50,6 +50,7 @@ BLOCK_EMPTY = {'name': 'minecraft:air'}
|
|||
BLOCK_SURFACE = {'name': 'minecraft:grass_block', 'snowy': 'false'}
|
||||
BLOCK_SUBSURFACE = {'name': 'minecraft:dirt'}
|
||||
BLOCK_UNDERGROUND = {'name': 'minecraft:stone'}
|
||||
BLOCK_DEFAULT = {'name': 'minecraft:cobblestone'}
|
||||
|
||||
|
||||
class Buffer_1_18_2(Buffer1_14):
|
||||
|
@ -220,7 +221,7 @@ class YTDServerProtocol(ServerProtocol):
|
|||
self,
|
||||
self.display_name, # type: ignore
|
||||
0,
|
||||
325,
|
||||
0, #325,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@ -244,7 +245,7 @@ class YTDServerProtocol(ServerProtocol):
|
|||
|
||||
# Start sending "Keep Alive" packets
|
||||
self.ticker.add_loop(20, self.update_keep_alive)
|
||||
self.ticker.add_loop(.5/self.ticker.interval, self.manage_queue)
|
||||
self.ticker.add_loop(.25/self.ticker.interval, self.manage_queue)
|
||||
|
||||
# Announce player join to other players
|
||||
self.factory.broadcast_player_join(self)
|
||||
|
@ -357,6 +358,13 @@ class YTDServerProtocol(ServerProtocol):
|
|||
|
||||
buff.discard()
|
||||
|
||||
def send_block_change(self, x, y, z, block):
|
||||
self.send_packet(
|
||||
'block_change',
|
||||
self.buff_type.pack_position(x,y,z),
|
||||
self.buff_type.pack_varint(REGISTRY.encode_block(block)),
|
||||
)
|
||||
|
||||
def send_unload_chunk(self, x, z):
|
||||
self.send_packet(
|
||||
'unload_chunk',
|
||||
|
@ -383,6 +391,8 @@ class YTDServerProtocol(ServerProtocol):
|
|||
self.buff_type.pack_varint(0), # Sky Light Array Length
|
||||
self.buff_type.pack_varint(0), # Block Light Array Length
|
||||
)
|
||||
for i in self.factory.fix(x,z):
|
||||
self.send_block_change(*i,BLOCK_EMPTY)
|
||||
|
||||
|
||||
class YTDServerFactory(ServerFactory):
|
||||
|
@ -466,11 +476,35 @@ class YTDServerFactory(ServerFactory):
|
|||
player.buff_type.pack_uuid(removed.uuid)) # Player UUID
|
||||
|
||||
@staticmethod
|
||||
def func(cx, cy, cz, xi, yi, zi):
|
||||
def chunk_func(cx, cy, cz, xi, yi, zi):
|
||||
x = cx * 16 + xi
|
||||
y = cy * 16 + yi
|
||||
z = cz * 16 + zi
|
||||
return x*x/20 + y*y/10 <= z*z/30
|
||||
return YTDServerFactory.func(x,y,z)
|
||||
|
||||
@staticmethod
|
||||
def func(x, y, z):
|
||||
# return x + z == y
|
||||
return x*x/20 - z*z/20 > y
|
||||
# f = lambda x,z,y: x*x/20 - y*y/20 - z
|
||||
# s = lambda x: math.copysign(1, x)
|
||||
# v = s(f(x,y,z))
|
||||
# return sum((
|
||||
# v == s(f(x,y,z+1)),
|
||||
# v == s(f(x,+1,z)),
|
||||
# v == s(f(x,y+1,z+1)),
|
||||
# v == s(f(+1,y,z)),
|
||||
# v == s(f(x+1,y,z+1)),
|
||||
# v == s(f(x+1,y+1,z)),
|
||||
# v == s(f(x+1,y+1,z+1)),
|
||||
# ))
|
||||
|
||||
def fix(self, x, z):
|
||||
blocks = []
|
||||
for y in range(-64,325,16):
|
||||
if not self.func(x*16,y,z*16):
|
||||
blocks.append((x*16,y,z*16))
|
||||
return blocks
|
||||
|
||||
def generate(self, x, z):
|
||||
# array[y][z][x]
|
||||
|
@ -480,9 +514,13 @@ class YTDServerFactory(ServerFactory):
|
|||
for _ in range(CHUNKS_TALL):
|
||||
sections.append(BlockArray.empty(REGISTRY))
|
||||
for y, sec in enumerate(sections):
|
||||
sec[0] = BLOCK_DEFAULT
|
||||
for i, xi, yi, zi in chunk_range():
|
||||
if self.func(x,y%3,z,xi,yi,zi):
|
||||
sec[i] = BLOCK_UNDERGROUND
|
||||
if self.chunk_func(x,y-4,z,xi,yi,zi):
|
||||
# print(x * 16 + xi,(y-4) * 16 + yi,z * 16 + zi)
|
||||
sec[i] = BLOCK_DEFAULT
|
||||
# else:
|
||||
# sec[i] = BLOCK_EMPTY
|
||||
height_map = NBT.TagRoot({'':NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})})
|
||||
return sections, height_map
|
||||
|
||||
|
|
Loading…
Reference in New Issue