Skip to content

Commit 0f0cd0a

Browse files
🎨 Format code
1 parent 6820180 commit 0f0cd0a

2 files changed

Lines changed: 51 additions & 24 deletions

File tree

‎scripts/packer.py‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
logo = root / "logo.png"
1515
structures = root / "examples/out"
1616

17+
1718
def main() -> None:
1819
timestamp = datetime.now().strftime("%d.%m %H:%M")
1920
name = f"mcstructure pack - {timestamp}"
@@ -26,16 +27,8 @@ def main() -> None:
2627
"version": [1, 0, 0],
2728
"min_engine_version": [1, 21, 0],
2829
},
29-
"modules": [
30-
{
31-
"type": "data",
32-
"uuid": str(uuid4()),
33-
"version": [1, 0, 0]
34-
}
35-
],
36-
"metadata": {
37-
"product_type": "addon"
38-
}
30+
"modules": [{"type": "data", "uuid": str(uuid4()), "version": [1, 0, 0]}],
31+
"metadata": {"product_type": "addon"},
3932
}
4033
with TemporaryDirectory() as temp_dir_str:
4134
temp_dir = Path(temp_dir_str)
@@ -49,10 +42,13 @@ def main() -> None:
4942
destination = structures_dir / structure_path.name
5043
destination.write_bytes(structure_path.read_bytes())
5144
print(f"adding {structure_path}")
52-
with zipfile.ZipFile((root / name.replace(".", "_")).with_suffix(".mcpack"), "w") as archive:
45+
with zipfile.ZipFile(
46+
(root / name.replace(".", "_")).with_suffix(".mcpack"), "w"
47+
) as archive:
5348
for source_path in temp_dir.glob("**/*"):
5449
print(f"archiving {source_path}")
5550
archive.write(source_path, arcname=source_path.relative_to(temp_dir))
5651

52+
5753
if __name__ == "__main__":
5854
main()

‎src/mcstructure/__init__.py‎

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ def load(cls, file: BinaryIO) -> Self:
302302
struct._palette.extend(
303303
[
304304
Block(block["name"], **(block["states"]))
305-
for block in nbt_body["structure"]["palette"]["default"]["block_palette"]
305+
for block in nbt_body["structure"]["palette"]["default"][
306+
"block_palette"
307+
]
306308
]
307309
)
308310

@@ -426,12 +428,17 @@ def dump(self, file: BinaryIO) -> None:
426428
nbtx.TagList(
427429
name="",
428430
child_id=nbtx.TagInt.id(),
429-
value=[nbtx.TagInt("", i.item()) for i in self.structure.flatten()],
431+
value=[
432+
nbtx.TagInt("", i.item())
433+
for i in self.structure.flatten()
434+
],
430435
),
431436
nbtx.TagList(
432437
name="",
433438
child_id=nbtx.TagInt.id(),
434-
value=list(repeat(nbtx.TagInt("", -1), self.structure.size)),
439+
value=list(
440+
repeat(nbtx.TagInt("", -1), self.structure.size)
441+
),
435442
),
436443
],
437444
),
@@ -461,26 +468,46 @@ def dump(self, file: BinaryIO) -> None:
461468
name="states",
462469
value=[
463470
(
464-
nbtx.TagInt(state_name, state_value) if isinstance(state_value, int) else
465-
nbtx.TagString(state_name, state_value) if isinstance(state_value, str) else
466-
nbtx.TagByte(state_name, state_value) # TODO: confirm bools are stored as bytes
471+
nbtx.TagInt(
472+
state_name,
473+
state_value,
474+
)
475+
if isinstance(
476+
state_value, int
477+
)
478+
else (
479+
nbtx.TagString(
480+
state_name,
481+
state_value,
482+
)
483+
if isinstance(
484+
state_value,
485+
str,
486+
)
487+
else nbtx.TagByte(
488+
state_name,
489+
state_value,
490+
)
491+
) # TODO: confirm bools are stored as bytes
467492
)
468493
for state_name, state_value in block.states.items()
469-
]
494+
],
470495
),
471496
nbtx.TagInt(
472497
name="version",
473-
value=COMPABILITY_VERSION
498+
value=COMPABILITY_VERSION,
474499
),
475-
]
500+
],
476501
)
477502
for block in self._palette
478503
],
479504
),
480-
nbtx.TagCompound(name="block_position_data", value=[]),
481-
]
505+
nbtx.TagCompound(
506+
name="block_position_data", value=[]
507+
),
508+
],
482509
)
483-
]
510+
],
484511
),
485512
],
486513
),
@@ -650,7 +677,11 @@ def combine(self, other: Structure, position: Coordinate = (0, 0, 0)) -> Structu
650677

651678
# Calculate the new size needed to accommodate both structures
652679
end_pos = (ox + other._size[0], oy + other._size[1], oz + other._size[2])
653-
new_size = (max(self._size[0], end_pos[0]), max(self._size[1], end_pos[1]), max(self._size[2], end_pos[2]))
680+
new_size = (
681+
max(self._size[0], end_pos[0]),
682+
max(self._size[1], end_pos[1]),
683+
max(self._size[2], end_pos[2]),
684+
)
654685

655686
combined = Structure(new_size, None)
656687

0 commit comments

Comments
 (0)