From 0afc1c9e0f8656124a1beae033bc8ff5fa87ef65 Mon Sep 17 00:00:00 2001 From: "Patrick W. Crawford" Date: Mon, 24 Jun 2024 21:57:14 -0700 Subject: [PATCH] Added new test world save and exports from jmc2obj and mineways --- .gitattributes | 1 + MCprep_addon/commonmcobj_parser.py | 24 +++++++++++-------- test_files/test_data/jmc2obj_test_1_21.mtl | 3 +++ test_files/test_data/jmc2obj_test_1_21.obj | 3 +++ .../test_data/mineways_test_combined_1_21.mtl | 3 +++ .../test_data/mineways_test_combined_1_21.obj | 3 +++ .../mineways_test_separated_1_21.mtl | 3 +++ .../mineways_test_separated_1_21.obj | 3 +++ test_files/world_saves/Test MCprep 1.14.4.zip | 3 +++ test_files/world_saves/Test MCprep 1.15.2.zip | 3 +++ test_files/world_saves/Test MCprep 1.21.zip | 3 +++ 11 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 test_files/test_data/jmc2obj_test_1_21.mtl create mode 100644 test_files/test_data/jmc2obj_test_1_21.obj create mode 100644 test_files/test_data/mineways_test_combined_1_21.mtl create mode 100644 test_files/test_data/mineways_test_combined_1_21.obj create mode 100644 test_files/test_data/mineways_test_separated_1_21.mtl create mode 100644 test_files/test_data/mineways_test_separated_1_21.obj create mode 100644 test_files/world_saves/Test MCprep 1.14.4.zip create mode 100644 test_files/world_saves/Test MCprep 1.15.2.zip create mode 100644 test_files/world_saves/Test MCprep 1.21.zip diff --git a/.gitattributes b/.gitattributes index 63ea2676..1d8939fd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/MCprep_addon/commonmcobj_parser.py b/MCprep_addon/commonmcobj_parser.py index 94ff5d4d..43346e24 100644 --- a/MCprep_addon/commonmcobj_parser.py +++ b/MCprep_addon/commonmcobj_parser.py @@ -214,14 +214,14 @@ 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 @@ -229,19 +229,23 @@ def parse_header(f: TextIO) -> Optional[CommonMCOBJ]: 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 diff --git a/test_files/test_data/jmc2obj_test_1_21.mtl b/test_files/test_data/jmc2obj_test_1_21.mtl new file mode 100644 index 00000000..8c6ebc7d --- /dev/null +++ b/test_files/test_data/jmc2obj_test_1_21.mtl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7155824abda1552da03233e2320dc89b3f1776a62470ab2a515f489269f9ff53 +size 82370 diff --git a/test_files/test_data/jmc2obj_test_1_21.obj b/test_files/test_data/jmc2obj_test_1_21.obj new file mode 100644 index 00000000..d7961ecf --- /dev/null +++ b/test_files/test_data/jmc2obj_test_1_21.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5032b39a22db60ecd3346a40c93b2b1f5871566e49496f04cdd846a934adc681 +size 409323 diff --git a/test_files/test_data/mineways_test_combined_1_21.mtl b/test_files/test_data/mineways_test_combined_1_21.mtl new file mode 100644 index 00000000..c81ef376 --- /dev/null +++ b/test_files/test_data/mineways_test_combined_1_21.mtl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06ef918eb7f9a84e3f33e2fe5970d58ea19e3376462161e62c0c1a05f6c1ab42 +size 133438 diff --git a/test_files/test_data/mineways_test_combined_1_21.obj b/test_files/test_data/mineways_test_combined_1_21.obj new file mode 100644 index 00000000..33504499 --- /dev/null +++ b/test_files/test_data/mineways_test_combined_1_21.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3f0b89937501e34913009f4e9c656674cb33fadded977589253f813b1c910d8 +size 583757 diff --git a/test_files/test_data/mineways_test_separated_1_21.mtl b/test_files/test_data/mineways_test_separated_1_21.mtl new file mode 100644 index 00000000..44029d93 --- /dev/null +++ b/test_files/test_data/mineways_test_separated_1_21.mtl @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bbe8a7093f0c7799b7919509316eb18146ad423c252852fcb0687dbfe56c08ac +size 147361 diff --git a/test_files/test_data/mineways_test_separated_1_21.obj b/test_files/test_data/mineways_test_separated_1_21.obj new file mode 100644 index 00000000..4c2e3b1e --- /dev/null +++ b/test_files/test_data/mineways_test_separated_1_21.obj @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0f4b8e1742ef87a28b105330990628c6a6bc30d095a0cb87dcf0d3bdc90a250 +size 445809 diff --git a/test_files/world_saves/Test MCprep 1.14.4.zip b/test_files/world_saves/Test MCprep 1.14.4.zip new file mode 100644 index 00000000..4ab192fa --- /dev/null +++ b/test_files/world_saves/Test MCprep 1.14.4.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c7aaa259299eefd6f97640f842a40a22c7655cb2207b49cae16686fcb15f90a6 +size 933854 diff --git a/test_files/world_saves/Test MCprep 1.15.2.zip b/test_files/world_saves/Test MCprep 1.15.2.zip new file mode 100644 index 00000000..6ef09189 --- /dev/null +++ b/test_files/world_saves/Test MCprep 1.15.2.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09a96a83293e40d581d6b3fb28496b5f3f1d59487e7fdfe0128b285355bec1cb +size 1057610 diff --git a/test_files/world_saves/Test MCprep 1.21.zip b/test_files/world_saves/Test MCprep 1.21.zip new file mode 100644 index 00000000..44c71bd8 --- /dev/null +++ b/test_files/world_saves/Test MCprep 1.21.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:117c5856616b825e2f5b6c34d4f6cf79efc1014cc2e2e4395ca243f3132449f0 +size 2647829