diff --git a/datapack/data/fetchr/functions/item_detection/special/clear_blue_trimmed_leather_boots.mcfunction b/datapack/data/fetchr/functions/item_detection/special/clear_blue_trimmed_leather_boots.mcfunction index a07acede..b47c7282 100644 --- a/datapack/data/fetchr/functions/item_detection/special/clear_blue_trimmed_leather_boots.mcfunction +++ b/datapack/data/fetchr/functions/item_detection/special/clear_blue_trimmed_leather_boots.mcfunction @@ -6,7 +6,7 @@ # @context # entity The player to check -#NEUN_SCRIPT since 33 +#NEUN_SCRIPT since 33 until 39 clear @s minecraft:leather_boots[minecraft:trim={pattern:"minecraft:coast",material:"minecraft:lapis"}] 1 clear @s minecraft:leather_boots[minecraft:trim={pattern:"minecraft:dune",material:"minecraft:lapis"}] 1 clear @s minecraft:leather_boots[minecraft:trim={pattern:"minecraft:eye",material:"minecraft:lapis"}] 1 diff --git a/datapack/data/fetchr/functions/item_detection/special/detect_blue_trimmed_leather_boots.mcfunction b/datapack/data/fetchr/functions/item_detection/special/detect_blue_trimmed_leather_boots.mcfunction index f859a93f..f075abfa 100644 --- a/datapack/data/fetchr/functions/item_detection/special/detect_blue_trimmed_leather_boots.mcfunction +++ b/datapack/data/fetchr/functions/item_detection/special/detect_blue_trimmed_leather_boots.mcfunction @@ -6,7 +6,7 @@ # @context # entity The player to check -#NEUN_SCRIPT since 33 +#NEUN_SCRIPT since 33 until 39 execute if items entity @s container.* minecraft:leather_boots[minecraft:trim={pattern:"minecraft:coast",material:"minecraft:lapis"}] run scoreboard players set @s fetchr.has_item 1 execute if items entity @s container.* minecraft:leather_boots[minecraft:trim={pattern:"minecraft:dune",material:"minecraft:lapis"}] run scoreboard players set @s fetchr.has_item 1 execute if items entity @s container.* minecraft:leather_boots[minecraft:trim={pattern:"minecraft:eye",material:"minecraft:lapis"}] run scoreboard players set @s fetchr.has_item 1 diff --git a/datapack/pack.mcmeta b/datapack/pack.mcmeta index 4cc11f9e..200d9e92 100644 --- a/datapack/pack.mcmeta +++ b/datapack/pack.mcmeta @@ -8,15 +8,15 @@ "entries": [ { "formats": {"min_inclusive": 28, "max_inclusive": 2147483647}, - "directory": "pack_format_28" + "directory": "pack_format_from_28" }, { "formats": {"min_inclusive": 33, "max_inclusive": 2147483647}, - "directory": "pack_format_33" + "directory": "pack_format_from_33" }, { "formats": {"min_inclusive": 37, "max_inclusive": 2147483647}, - "directory": "pack_format_37" + "directory": "pack_format_from_37" } ] } diff --git a/datapack/pack_format_28/data/fetchr/advancements/press_button.json b/datapack/pack_format_from_28/data/fetchr/advancements/press_button.json similarity index 100% rename from datapack/pack_format_28/data/fetchr/advancements/press_button.json rename to datapack/pack_format_from_28/data/fetchr/advancements/press_button.json diff --git a/datapack/pack_format_33/data/fetchr/advancements/press_button.json b/datapack/pack_format_from_33/data/fetchr/advancements/press_button.json similarity index 100% rename from datapack/pack_format_33/data/fetchr/advancements/press_button.json rename to datapack/pack_format_from_33/data/fetchr/advancements/press_button.json diff --git a/datapack/pack_format_33/data/fetchr/structures/card_generation.nbt b/datapack/pack_format_from_33/data/fetchr/structures/card_generation.nbt similarity index 100% rename from datapack/pack_format_33/data/fetchr/structures/card_generation.nbt rename to datapack/pack_format_from_33/data/fetchr/structures/card_generation.nbt diff --git a/datapack/pack_format_33/data/fetchr/structures/credits.nbt b/datapack/pack_format_from_33/data/fetchr/structures/credits.nbt similarity index 100% rename from datapack/pack_format_33/data/fetchr/structures/credits.nbt rename to datapack/pack_format_from_33/data/fetchr/structures/credits.nbt diff --git a/datapack/pack_format_33/data/fetchr/structures/tutorial.nbt b/datapack/pack_format_from_33/data/fetchr/structures/tutorial.nbt similarity index 100% rename from datapack/pack_format_33/data/fetchr/structures/tutorial.nbt rename to datapack/pack_format_from_33/data/fetchr/structures/tutorial.nbt diff --git a/datapack/pack_format_37/data/fetchr/dimension_type/default.json b/datapack/pack_format_from_37/data/fetchr/dimension_type/default.json similarity index 100% rename from datapack/pack_format_37/data/fetchr/dimension_type/default.json rename to datapack/pack_format_from_37/data/fetchr/dimension_type/default.json diff --git a/neunscript.config.json b/neunscript.config.json index db299d64..21850a89 100644 --- a/neunscript.config.json +++ b/neunscript.config.json @@ -1,10 +1,10 @@ { "name": "Fetchr", - "version": "5.1.2", + "version": "5.1.3", "mc": "1.20.2", "target": "dist", "vars": { - "version_long_name": "5.1.2", + "version_long_name": "5.1.3", "rp_version": "23", "realms": false }, @@ -28,7 +28,7 @@ "realms": { "vars": { "realms": true, - "version_long_name": "5.1.2 (Realms)" + "version_long_name": "5.1.3 (Realms)" } } }, diff --git a/neunscript.py b/neunscript.py index c00ceeb0..f724cc33 100644 --- a/neunscript.py +++ b/neunscript.py @@ -145,7 +145,7 @@ def main(): def iterate_files(config: dict, source: str, target: str, mc_version_info: dict | None): requested_rp_sha = [] - pack_formats_for_overlay = set() + pack_formats_for_overlay = [] remove_extensions = config.get("remove_file_types") versionDict: dict | None = config.get("versions") if versionDict == None: @@ -206,13 +206,18 @@ def iterate_files(config: dict, source: str, target: str, mc_version_info: dict file_content = minify_json_file(file_content) elif file_name.endswith(".mcfunction"): function_result = minify_function_file(file_content, version_config, 1) - for pack_format in function_result.get("pack_formats"): - pack_formats_for_overlay.add(pack_format) + pack_formats = sorted(function_result.get("pack_formats")) + for i in range(0, len(pack_formats)): + pack_format = pack_formats[i] + max_format = pack_formats[i+1] - 1 if i+1 < len(pack_formats) else None + pack_formats_for_overlay.append([pack_format, max_format]) overlay_content = minify_function_file(file_content, version_config, pack_format).get("content") - overlay_path = f"{out_root}{os.sep}pack_format_{pack_format}{os.sep}{relative_path}" - os.makedirs(overlay_path, exist_ok=True) - with open(f"{overlay_path}{os.sep}{file_name}", "w", encoding="utf-8") as file: - file.write(overlay_content) + + if overlay_content: + overlay_path = f"{out_root}{os.sep}pack_format_from_{pack_format}{f'_until_{max_format}' if max_format != None else ''}{os.sep}{relative_path}" + os.makedirs(overlay_path, exist_ok=True) + with open(f"{overlay_path}{os.sep}{file_name}", "w", encoding="utf-8") as file: + file.write(overlay_content) file_content: str = function_result.get("content") if override == None: global lines @@ -237,9 +242,11 @@ def iterate_files(config: dict, source: str, target: str, mc_version_info: dict entries = [] for pack_format in pack_formats_for_overlay: - overlay_name = f"pack_format_{pack_format}" + min_inc = pack_format[0] + max_inc = pack_format[1] if pack_format[1] != None else 2**31-1 + overlay_name = f"pack_format_from_{min_inc}{f'_until_{max_inc}' if max_inc != 2**31-1 else ''}" if not any (entry["directory"] == overlay_name for entry in entries): - entries.append({"formats": {"min_inclusive": pack_format, "max_inclusive": 2**31-1 }, "directory": overlay_name }) + entries.append({"formats": {"min_inclusive": min_inc, "max_inclusive": max_inc}, "directory": overlay_name }) overlays["entries"] = entries pack_def["overlays"] = overlays file.seek(0) @@ -320,7 +327,7 @@ def minify_function_file(file_content: str, config: dict, pack_format: int): output="" remove=0 uncomment=0 - pack_formats = [] + pack_formats = set() for line in file_content.splitlines(): line = line.strip() @@ -389,12 +396,12 @@ def minify_function_file(file_content: str, config: dict, pack_format: int): raise ValueError("until/since needs at least one argument") min_value = 1 max_value = None - pack_formats.append(int(command[1])) + pack_formats.add(int(command[1])) if command[0] == "since": min_value = int(command[1]) if len(command) >= 4 and command[2] == "until": max_value = int(command[3]) - pack_formats.append(max_value) + pack_formats.add(max_value) else: max_value = int(command[1]) if pack_format >= min_value and (max_value is None or pack_format < max_value):