fix: disabled multi block change, refactored
This commit is contained in:
parent
989731574a
commit
56065d62f8
1 changed files with 25 additions and 17 deletions
|
@ -90,25 +90,33 @@ class GameWorld(Scaffold):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.cfg.getboolean("process_world", fallback=False):
|
if not self.cfg.getboolean("process_world", fallback=False):
|
||||||
self.world = World()
|
return
|
||||||
|
|
||||||
@self.on_packet(PacketMapChunk)
|
self.world = World()
|
||||||
async def map_chunk_cb(packet:PacketMapChunk):
|
|
||||||
assert isinstance(packet.bitMap, int)
|
|
||||||
c = Chunk(packet.x, packet.z, packet.bitMap, packet.groundUp, json.dumps(packet.blockEntities)) # TODO a solution which is not jank!
|
|
||||||
c.read(packet.chunkData)
|
|
||||||
self.world.put(c, packet.x, packet.z, not packet.groundUp)
|
|
||||||
|
|
||||||
@self.on_packet(PacketBlockChange)
|
@self.on_packet(PacketMapChunk)
|
||||||
async def block_change_cb(packet:PacketBlockChange):
|
async def map_chunk_cb(packet:PacketMapChunk):
|
||||||
self.world.put_block(packet.location[0], packet.location[1], packet.location[2], packet.type)
|
assert isinstance(packet.bitMap, int)
|
||||||
|
c = Chunk(packet.x, packet.z, packet.bitMap, packet.groundUp, json.dumps(packet.blockEntities)) # TODO a solution which is not jank!
|
||||||
|
c.read(packet.chunkData)
|
||||||
|
self.world.put(c, packet.x, packet.z, not packet.groundUp)
|
||||||
|
|
||||||
@self.on_packet(PacketMultiBlockChange)
|
@self.on_packet(PacketBlockChange)
|
||||||
async def multi_block_change_cb(packet:PacketMultiBlockChange):
|
async def block_change_cb(packet:PacketBlockChange):
|
||||||
|
self.world.put_block(packet.location[0], packet.location[1], packet.location[2], packet.type)
|
||||||
|
|
||||||
|
@self.on_packet(PacketMultiBlockChange)
|
||||||
|
async def multi_block_change_cb(packet:PacketMultiBlockChange):
|
||||||
|
return # holy shit this is LAME!
|
||||||
|
if hasattr(packet, "chunkCoordinates"):
|
||||||
|
chunk_x_off = (packet.chunkCoordinates & 0b1111111111111111111111) * 16
|
||||||
|
chunk_z_off = ((packet.chunkCoordinates >> 22) & 0b1111111111111111111111) * 16
|
||||||
|
chunk_y_off = ((packet.chunkCoordinates >> 44) & 0b11111111111111111111) * 16
|
||||||
|
else:
|
||||||
chunk_x_off = packet.chunkX * 16
|
chunk_x_off = packet.chunkX * 16
|
||||||
chunk_z_off = packet.chunkZ * 16
|
chunk_z_off = packet.chunkZ * 16
|
||||||
for entry in packet.records:
|
for entry in packet.records:
|
||||||
x_off = (entry['horizontalPos'] >> 4 ) & 15
|
x_off = (entry['horizontalPos'] >> 4 ) & 15
|
||||||
z_off = entry['horizontalPos'] & 15
|
z_off = entry['horizontalPos'] & 15
|
||||||
self.world.put_block(x_off + chunk_x_off, entry['y'], z_off + chunk_z_off, entry['blockId'])
|
self.world.put_block(x_off + chunk_x_off, entry['y'], z_off + chunk_z_off, entry['blockId'])
|
||||||
|
|
Loading…
Reference in a new issue