Added surface and subsurface generation

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

View File

@ -215,13 +215,13 @@ class YTDServerProtocol(ServerProtocol):
# in-game, and does some logging.
ServerProtocol.player_joined(self)
self.buff_type = Buffer_1_18_2
self.view_distance = 5
self.view_distance = 8
self.player = Player(
self,
self.display_name, # type: ignore
0,
0, #325,
128, #325,
0,
0,
0,
@ -245,7 +245,8 @@ class YTDServerProtocol(ServerProtocol):
# Start sending "Keep Alive" packets
self.ticker.add_loop(20, self.update_keep_alive)
self.ticker.add_loop(.25/self.ticker.interval, self.manage_queue)
# self.ticker.add_loop(.25/self.ticker.interval, self.manage_queue)
self.ticker.add_loop(1, self.manage_queue)
# Announce player join to other players
self.factory.broadcast_player_join(self)
@ -484,20 +485,16 @@ class YTDServerFactory(ServerFactory):
@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)),
# ))
a = 100
b = 100
if x*x/a - z*z/b > y + 3:
return BLOCK_UNDERGROUND
elif x*x/a - z*z/b > y + 1:
return BLOCK_SUBSURFACE
elif x*x/a - z*z/b > y:
return BLOCK_SURFACE
else:
return BLOCK_EMPTY
def fix(self, x, z):
blocks = []
@ -516,9 +513,10 @@ class YTDServerFactory(ServerFactory):
for y, sec in enumerate(sections):
sec[0] = BLOCK_DEFAULT
for i, xi, yi, zi in chunk_range():
if self.chunk_func(x,y-4,z,xi,yi,zi):
sec[i] = self.chunk_func(x,y-12,z,xi,yi,zi)
# 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
# sec[i] = BLOCK_DEFAULT
# else:
# sec[i] = BLOCK_EMPTY
height_map = NBT.TagRoot({'':NBT.TagCompound({'MOTION_BLOCKING':NBT.TagLongArray(PackedArray.empty_height())})})