Skip to content

Commit

Permalink
Added bedrock thumbnail
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlegiantJGC committed Oct 18, 2023
1 parent e488945 commit 62e09f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion amulet/level/base_level/_level/_disk_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

from abc import abstractmethod

from ._level import BaseLevel
from ._level import BaseLevel, metadata


class DiskLevel(BaseLevel):
"""A level base class for all levels with data on disk."""

__slots__ = ()

@metadata
@property
@abstractmethod
def path(self) -> str:
Expand Down
11 changes: 10 additions & 1 deletion amulet/level/bedrock_world/_level.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations

from typing import Any, Iterable, Optional, Union
from typing import Any, Optional, Union
import os
import shutil
import time

from PIL import Image
from leveldb import LevelDB
from amulet_nbt import CompoundTag, IntTag, ListTag, LongTag, StringTag

Expand Down Expand Up @@ -136,6 +137,14 @@ def level_name(self) -> str:
except Exception:
return "Unknown level name"

@metadata
@property
def thumbnail(self) -> Image.Image:
try:
return Image.open(os.path.join(self.path, "world_icon.jpg"))
except Exception:
return super().thumbnail

def dimensions(self) -> frozenset[DimensionID]:
return self.raw.dimensions()

Expand Down

0 comments on commit 62e09f4

Please sign in to comment.