Skip to content

Commit

Permalink
Do not restrict size
Browse files Browse the repository at this point in the history
See also: #12
  • Loading branch information
phoenixr-codes committed Aug 22, 2023
1 parent e0fe04f commit 069e8fa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 8 additions & 6 deletions src/mcstructure/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
"""

STRUCTURE_MAX_SIZE: tuple[int, int, int] = (64, 384, 64)
"""The maximum size a structure can have."""
"""
The maximum size a structure can have. This does not apply for
structures created externally.
"""


# TODO: cover all tags
Expand Down Expand Up @@ -101,8 +104,10 @@ def is_valid_structure_name(name: str, *, with_prefix: bool = False) -> bool:
return all((char.isalnum() and char in "-_") for char in name)


def has_valid_size(size: tuple[int, int, int]) -> bool:
"""Returns ``False`` if ``size`` is too big.
def has_suitable_size(size: tuple[int, int, int]) -> bool:
"""
Returns ``False`` if ``size`` is greater than the size of
structures that can be created within Minecraft.
.. seealso:: :const:`STRUCTURE_MAX_SIZE`
"""
Expand Down Expand Up @@ -275,9 +280,6 @@ def __init__(
``'minecraft:air'`` is used as default.
"""
if not has_valid_size(size):
raise ValueError(f"structure too large, max size: {STRUCTURE_MAX_SIZE}")

self.structure: NDArray[np.intc]

self._size = size
Expand Down
8 changes: 3 additions & 5 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from mcstructure import Structure, STRUCTURE_MAX_SIZE
import pytest
from mcstructure import has_suitable_size, STRUCTURE_MAX_SIZE


def test_oversized() -> None:
Structure(STRUCTURE_MAX_SIZE)
with pytest.raises(ValueError):
Structure((65, 0, 0))
assert has_suitable_size(STRUCTURE_MAX_SIZE)
assert not has_suitable_size((65, 0, 0))

0 comments on commit 069e8fa

Please sign in to comment.