Fix more bugs

This commit is contained in:
2021-02-23 02:45:46 +00:00
parent 4b97aaf739
commit d0bfed75dd
3 changed files with 21 additions and 13 deletions

View File

@@ -103,7 +103,7 @@ class Nbt(Type):
class Slot(Type):
def __init__(self, present, item_id, item_count, nbt):
def __init__(self, present, item_id=None, item_count=None, nbt=None):
self.present = present
self.item_id = item_id
self.item_count = item_count
@@ -112,8 +112,11 @@ class Slot(Type):
def __str__(self):
return str(self.__dict__)
def __repr__(self):
return 'Slot(present={}, item_id={}, item_count={}, nbt={}'.format(
self.present, self.item_id, self.item_count, self.nbt)
if self.present:
return 'Slot(present={}, item_id={}, item_count={}, nbt={}'.format(
self.present, self.item_id, self.item_count, self.nbt)
else:
return 'Slot(present={})'.format(self.present)
@staticmethod
def read(file_object):
@@ -131,9 +134,10 @@ class Slot(Type):
@staticmethod
def send(value, socket):
Boolean.send(value.present, socket)
VarInt.send(value.item_id, socket)
Byte.send(value.item_count, socket)
Byte.send(0x00, socket)
if value.present:
VarInt.send(value.item_id, socket)
Byte.send(value.item_count, socket)
Byte.send(0x00, socket)
class Entry(Type):