Skip to content

Commit

Permalink
Added new test world save and exports from jmc2obj and mineways
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDuckCow committed Jun 25, 2024
1 parent 0d65ffd commit 0afc1c9
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
*.mtl filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
24 changes: 14 additions & 10 deletions MCprep_addon/commonmcobj_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,34 +214,38 @@ def clean_and_extract(line: str) -> Tuple[str, str]:

return header


def parse_header(f: TextIO) -> Optional[CommonMCOBJ]:
"""
Parses a file and returns a CommonMCOBJ object if
the header exists.
Parses a file and returns a CommonMCOBJ object if the header exists.
f: TextIO
File object
Returns:
- CommonMCOBJ object if header exists
- None otherwise
"""

header: List[str] = []
found_header = False

# Read in the header
for l in f:
tl = " ".join(l.rstrip().split())
if tl == "# COMMON_MC_OBJ_START":
lines_read = 0
for _l in f:
tl = " ".join(_l.rstrip().split())
lines_read += 1
if lines_read > 100 and tl and not tl.startswith("#"):
break # no need to parse further than the true header area
elif tl == "# COMMON_MC_OBJ_START":
header.append(tl)
found_header = True
found_header = True
continue
elif tl == "# COMMON_MC_OBJ_END":
header.append(tl)
break
if not found_header or tl == "#":
continue
continue
header.append(tl)
if not len(header):
return None
Expand Down
3 changes: 3 additions & 0 deletions test_files/test_data/jmc2obj_test_1_21.mtl
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/test_data/jmc2obj_test_1_21.obj
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/test_data/mineways_test_combined_1_21.mtl
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/test_data/mineways_test_combined_1_21.obj
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/test_data/mineways_test_separated_1_21.mtl
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/test_data/mineways_test_separated_1_21.obj
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/world_saves/Test MCprep 1.14.4.zip
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/world_saves/Test MCprep 1.15.2.zip
Git LFS file not shown
3 changes: 3 additions & 0 deletions test_files/world_saves/Test MCprep 1.21.zip
Git LFS file not shown

0 comments on commit 0afc1c9

Please sign in to comment.