tweaks to item type
This commit is contained in:
parent
f35f9d5434
commit
65b42a2ed7
2 changed files with 10 additions and 2 deletions
|
@ -101,7 +101,7 @@ class Item:
|
|||
nbt : dict
|
||||
damage : int # This got removed past 1.12.2
|
||||
|
||||
def __init__(self, item:'Item' = None, id:int=0, count:int=0, nbt:dict=None, damage:int=0):
|
||||
def __init__(self, item:'Item' = None, id:int=0, count:int=1, nbt:dict=None, damage:int=0):
|
||||
self.id = id
|
||||
self.count = count
|
||||
self.nbt = nbt or {}
|
||||
|
@ -112,6 +112,14 @@ class Item:
|
|||
self.nbt = item.nbt
|
||||
self.damage = item.damage
|
||||
|
||||
def as_dict(self) -> dict:
|
||||
return {
|
||||
'id': self.id,
|
||||
'count': self.count,
|
||||
'nbt': self.nbt,
|
||||
'damage': self.damage,
|
||||
}
|
||||
|
||||
def __getitem__(self, key:str): # backwards compatibility
|
||||
return getattr(self, key)
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ class SlotType(Type):
|
|||
else:
|
||||
check_type.write(False if new_way else -1, buffer, ctx)
|
||||
|
||||
def read(self, buffer:io.BytesIO, ctx:Context) -> Any:
|
||||
def read(self, buffer:io.BytesIO, ctx:Context) -> Item:
|
||||
slot : Dict[Any, Any] = {}
|
||||
new_way = ctx._proto > 340
|
||||
check_type = Boolean if new_way else Short
|
||||
|
|
Loading…
Reference in a new issue