Fix: networking.types.Position.send() doesn't accept a Position.

This commit is contained in:
joo 2018-05-17 06:06:57 +01:00
commit c90afe4424
2 changed files with 4 additions and 3 deletions

View File

@ -29,8 +29,7 @@ class BlockChangePacket(Packet):
def write(self, socket, compression_threshold=None):
packet_buffer = PacketBuffer()
(x, y, z) = self.location
Position.send(x, y, z, packet_buffer)
Position.send(self.location, packet_buffer)
blockData = ((self.blockId << 4) | (self.blockMeta & 0xF))
VarInt.send(blockData)
self._write_buffer(socket, packet_buffer, compression_threshold)

View File

@ -263,7 +263,9 @@ class Position(Type, namedtuple('Position', ('x', 'y', 'z'))):
return Position(x=x, y=y, z=z)
@staticmethod
def send(x, y, z, socket):
def send(position, socket):
# 'position' can be either a tuple or Position object.
x, y, z = position
value = ((x & 0x3FFFFFF) << 38) | ((y & 0xFFF) << 26) | (z & 0x3FFFFFF)
UnsignedLong.send(value, socket)