Skip to content

Commit

Permalink
nbtlibからamulet-nbtに
Browse files Browse the repository at this point in the history
  • Loading branch information
Lapis256 committed Feb 8, 2022
1 parent 280e63f commit f49dafd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions map_extractor/extractor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from io import BytesIO

from nbtlib import Compound
from PIL import Image
import numpy as np
import amulet_nbt


__all__ = (
Expand All @@ -19,14 +19,14 @@ def iter_colors_from_world(world):
if not key.startswith(b"map_"):
continue

compound = Compound.parse(BytesIO(value), "little")[""]
compound = amulet_nbt.load(value, compressed=False, little_endian=True)
colors = compound["colors"]
if len(set(colors)) <= 1:
continue
yield compound["mapId"].unpack(), colors
yield compound["mapId"].value, colors


def generate_map_image(colors):
array = np.uint8(np.fromiter(colors, int))
array = np.fromiter(colors, np.uint8)
image = array.reshape((MAP_WIDTH, MAP_HEIGHT, 4))
return Image.fromarray(image)
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

setup(
name="map-extractor",
version="1.1.0",
version="1.2.0",
install_requires=[
"Pillow>=9.0.1,<9.1.0",
"nbtlib>=2.0.4,<2.1.0",
"amulet-nbt>=1.0.3.10,<1.1.0.0",
"tqdm>=4.62.3,<4.63.0"
],
extras_require={
Expand Down

0 comments on commit f49dafd

Please sign in to comment.