Skip to content

Commit

Permalink
Merge pull request #178 from Amulet-Team/impl-rotation
Browse files Browse the repository at this point in the history
Added block rotation
  • Loading branch information
gentlegiantJGC authored Mar 30, 2022
2 parents e6dafea + 36768eb commit f641e23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion amulet/api/level/base_level/clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def clone(

# TODO: I don't know if this is feasible for large boxes: get the intersection of the source and destination selections and iterate over that to minimise work
if any(rotation) or any(s != 1 for s in scale):
# if the selection needs transforming
rotation_radians = tuple(numpy.radians(rotation))
transform = numpy.matmul(
transform_matrix(scale, rotation_radians, location),
Expand Down Expand Up @@ -198,10 +199,14 @@ def clone(
mask = block_ids == block_id
dst_blocks_ = dst_blocks[mask]

transformed_block = src_structure.translation_manager.transform_universal_block(
block, transform
)

dst_chunk.blocks.get_sub_chunk(dst_cy)[
tuple(dst_blocks_.T % 16)
] = dst_chunk.block_palette.get_add_block(
block
transformed_block
)

src_blocks_ = src_blocks[mask]
Expand Down Expand Up @@ -250,6 +255,7 @@ def clone(
sum_progress += volumes[box_index]

else:
# the selection can be cloned as is
# the transform from the structure location to the world location
offset = numpy.asarray(location).astype(int) - rotation_point
moved_min_location = src_selection.min_array + offset
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements-main.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
numpy>=1.17.4
amulet-nbt~=1.0.3
pymctranslate~=1.0.0
amulet-nbt~=1.0.4
pymctranslate~=1.1.0

0 comments on commit f641e23

Please sign in to comment.