feat: added repr and str to Item

This commit is contained in:
əlemi 2022-07-03 00:21:26 +02:00
parent 2e742dd40b
commit bf4d16c526
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -152,6 +152,12 @@ class Item:
def __getitem__(self, key:str): # backwards compatibility
return getattr(self, key)
def __str__(self) -> str:
return repr(self)
def __repr__(self) -> str:
return f"Item(id={self.id}, count={self.count}, damage={self.damage}, nbt={str(self.nbt)})"
@property
def durability(self) -> int:
# TODO make a map of durability for each item and subtract damage?