Skip to content

Commit

Permalink
Added support for old and new nbt versions (#37)
Browse files Browse the repository at this point in the history
* Added support for old and new nbt versions

* Reformatted
  • Loading branch information
gentlegiantJGC authored Sep 17, 2024
1 parent ee65d76 commit fe32145
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions minecraft_model_reader/api/amulet/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
from typing import Iterable, Union, Optional, Any
import amulet_nbt

if amulet_nbt.__major__ >= 4:
from amulet_nbt import read_snbt # type: ignore
else:
from amulet_nbt import from_snbt as read_snbt # type: ignore

PropertyValueType = Union[
amulet_nbt.TAG_Byte,
amulet_nbt.TAG_Short,
Expand Down Expand Up @@ -301,9 +306,7 @@ def parse_blockstate_string(
properties = {}

if snbt:
properties_dict = {
k: amulet_nbt.from_snbt(v) for k, v in sorted(properties.items())
}
properties_dict = {k: read_snbt(v) for k, v in sorted(properties.items())}
else:
properties_dict = {
k: amulet_nbt.TAG_String(v) for k, v in sorted(properties.items())
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ python_requires = ~=3.9
install_requires =
Pillow>=10.0.1
numpy>=1.17
amulet-nbt~=2.0
amulet-nbt >= 2.0, < 5.0
platformdirs~=3.1
[options.packages.find]
Expand Down

0 comments on commit fe32145

Please sign in to comment.