-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pasting rotated Java schematic 180 degrees in .mcstructure causes 1 block of air on X-edge #252
Comments
This is a problem stemming from rotating a structure with a mixture of even and odd lengths. This code should solve your problem. import glob
import os
from math import floor
import amulet
from amulet.level.formats.mcstructure import MCStructureFormatWrapper
from amulet.api.selection import SelectionGroup
from amulet.api.selection import SelectionBox
def process_schematics(schematic_dir: str, output_dir: str):
for schematic_path in glob.glob(os.path.join(glob.escape(schematic_dir), "**/*.schem"), recursive=True):
schematic = amulet.load_level(schematic_path)
# Get bounds of schematic
bounds = schematic.bounds("main")
x_size = bounds.max_x - bounds.min_x
y_size = bounds.max_y - bounds.min_y
z_size = bounds.max_z - bounds.min_z
# Get basename of structure
basename = os.path.basename(schematic_path)[:-len(".schem")].replace(" ", "_")
x_mid = x_size // 2
y_mid = y_size // 2
z_mid = z_size // 2
for rotation, shape, paste_pos in (
(0, (x_size, y_size, z_size), (x_mid, y_mid, z_mid)),
(90, (z_size, y_size, x_size), (z_mid, floor(y_mid), x_size - x_mid)),
(180, (x_size, y_size, z_size), (x_size - x_mid, floor(y_mid), z_size - z_mid)),
(270, (z_size, y_size, x_size), (z_size - z_mid, y_mid, x_mid)),
):
mcstructure_path = os.path.join(output_dir, f"{basename}_{rotation}.mcstructure")
mcstructure_wrapper = MCStructureFormatWrapper(mcstructure_path)
# Create new mcstructure file with correct bounds
mcstructure_wrapper.create_and_open(
"bedrock", (1, 20, 0),
SelectionGroup(SelectionBox((0, 0, 0), shape)),
True
)
mcstructure_wrapper.save()
mcstructure_wrapper.close()
# Paste the schematic in the mcstructure
mcstructure_level = amulet.load_level(mcstructure_path)
mcstructure_level.paste(schematic, "main", bounds, "main", paste_pos, (1.0, 1.0, 1.0), (0.0, rotation, 0.0))
mcstructure_level.save()
mcstructure_level.close()
def main():
# Place schematics & create mcstructures
process_schematics("schematics", "out")
if __name__ == '__main__':
main() |
Describe the bug
I have a script that takes in .schem files from Java, and converts them to Bedrock .mcstructure.
I have managed to get the code working for rotations [0, 90, 270], however 180 is not working. There is an air gap on the X-most edge, where my structure is cut off. It pastes air, meaning the blank structure size is correct. The Z-edge is fine. What could be causing the X-edge to be air?
To Reproduce
Steps to reproduce the behavior:
.schem
in./schematics/category/file.schem
.mcstructures
in./output
Expected behavior
The generated
.mcstructure
for rotation 180 includes the full structure, and does not have the single axis air gap towards the X direction.Screenshots
![ApplicationFrameHost_cK28dpqdGx](https://private-user-images.githubusercontent.com/21283721/255349206-4b8a4234-6cb0-4f0d-b2b6-91fb6536a681.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkxNTI5MTMsIm5iZiI6MTczOTE1MjYxMywicGF0aCI6Ii8yMTI4MzcyMS8yNTUzNDkyMDYtNGI4YTQyMzQtNmNiMC00ZjBkLWIyYjYtOTFmYjY1MzZhNjgxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDAxNTY1M1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlhZjZmNWQ0YTU5NTMwNmRhZTMwYjZkNzUwOTZkMmYwZGFhMjIzNzE1ZTA2NTc4MTUxMWUwNWU1MDhhMjUxNDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.Bp0H0qhG1irQvJqvAtz--6vOJZTKJyhXfFfN16uHgwU)
Desktop (please complete the following information):
Additional context
Download
.schem
: https://drive.google.com/file/d/1yStCN8vAfiQXQm7wfSJiHESWKcxiuFPZ/view?usp=sharingThe text was updated successfully, but these errors were encountered: