Utmost-Happiness-Planet / pyCraft-UHP

Minecraft-client networking library in Python
Other
4 stars 0 forks source link

struct.error: unpack requires a buffer of 1 bytes #1

Closed ninthseason closed 2 years ago

ninthseason commented 2 years ago

连接至服务器后立马报错。

Exception in thread Networking Thread:
Traceback (most recent call last):
  File "C:\Python39\lib\threading.py", line 973, in _bootstrap_inner
    self.run()
  File "D:\Project Python\pyCraft-UHP\minecraft\networking\connection.py", line 596, in run
    self.connection._handle_exception(e, sys.exc_info())
  File "D:\Project Python\pyCraft-UHP\minecraft\networking\connection.py", line 539, in _handle_exception
    raise exc_value.with_traceback(exc_tb)
  File "D:\Project Python\pyCraft-UHP\minecraft\networking\connection.py", line 592, in run
    self._run()
  File "D:\Project Python\pyCraft-UHP\minecraft\networking\connection.py", line 625, in _run
    packet = self.connection.reactor.read_packet(
  File "D:\Project Python\pyCraft-UHP\minecraft\networking\connection.py", line 696, in read_packet
    packet.read(packet_data)
  File "D:\Project Python\pyCraft-UHP\minecraft\networking\packets\clientbound\play\map_packet.py", line 108, in read
    self.width = UnsignedByte.read(file_object)
  File "D:\Project Python\pyCraft-UHP\minecraft\networking\types\basic.py", line 67, in read
    return struct.unpack('>B', file_object.read(1))[0]
struct.error: unpack requires a buffer of 1 bytes
ninthseason commented 2 years ago

@SakuraPuare @mccube2000 Please fix the bug.

SakuraPuare commented 2 years ago

wtf

ninthseason commented 2 years ago

connection.py文件中屏蔽地图包的接收。得以暂时解决问题。

695   if packet.packet_name == 'map':
696       return None
SakuraPuare commented 2 years ago

Currently unclear the data struct of this packet, but now let us just drop it

SakuraPuare commented 2 years ago
file_object.get_writable()
>b"\x00'\xaa\x02\x00\x00\x00\x00"
mccube2000 commented 2 years ago

在basic.py中修改UnsignedByte.read

    def read(file_object):
        data = file_object.read(1)
        if len(data):
            return struct.unpack('>B', data)[0]
        else:
            return 0

暂时防止报错