Skip to content

Commit b3d5dc3

Browse files
committed
Merge remote-tracking branch 'origin/main' into mkdocs
2 parents 075a1c1 + b0fca20 commit b3d5dc3

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

mcproto/types/chat.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ def __eq__(self, other: object) -> bool:
6969

7070
return self.raw == other.raw
7171

72+
@override
73+
def __hash__(self) -> int:
74+
return hash(self.raw)
75+
7276
@override
7377
def serialize_to(self, buf: Buffer) -> None:
7478
txt = json.dumps(self.raw)

mcproto/types/nbt.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@ def __repr__(self) -> str:
447447
return f"{type(self).__name__}[{self.name!r}]({self.payload!r})"
448448
return f"{type(self).__name__}({self.payload!r})"
449449

450+
@override
451+
def __hash__(self) -> int:
452+
return hash((type(self), self.name, self.payload))
453+
450454
@override
451455
def to_nbt(self, name: str = "") -> NBTag:
452456
"""Convert the object to an NBT tag.
@@ -995,6 +999,10 @@ def __eq__(self, other: object) -> bool:
995999
return False
9961000
return all(tag in other.payload for tag in self.payload)
9971001

1002+
# Hash implementation is consistent with the parent class, even though
1003+
# we're overriding __eq__
1004+
__hash__ = NBTag.__hash__
1005+
9981006
@property
9991007
@override
10001008
def value(self) -> dict[str, PayloadType]:

poetry.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)