From 0584fc4ebf4b2d2c0fba1337ab1b205a3d1b7bc0 Mon Sep 17 00:00:00 2001 From: James David Clarke Date: Wed, 10 Jan 2024 03:36:56 +0000 Subject: [PATCH] Fixed find_highest_minecraft_version, got rid of hardcoded major-minor version string. --- tools/libtextureconverter/utils.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/libtextureconverter/utils.py b/tools/libtextureconverter/utils.py index 8a7b28033..c6ff052e8 100644 --- a/tools/libtextureconverter/utils.py +++ b/tools/libtextureconverter/utils.py @@ -1,4 +1,5 @@ import shutil, csv, os, tempfile, sys, argparse, glob, re, zipfile +from .config import SUPPORTED_MINECRAFT_VERSION from PIL import Image from collections import Counter @@ -27,8 +28,8 @@ def colorize_alpha(colormap, source, colormap_pixel, texture_size, destination, colorize(colormap, source, colormap_pixel, texture_size, destination, tempfile2_name) os.system("composite -compose Dst_In "+source+" "+tempfile2_name+" -alpha Set "+destination) -def find_highest_minecraft_version(home): - version_pattern = re.compile(r"1\.20\.\d+") +def find_highest_minecraft_version(home, supported_version): + version_pattern = re.compile(re.escape(supported_version) + r"\.\d+") versions_dir = os.path.join(home, ".minecraft", "versions") highest_version = None if os.path.isdir(versions_dir): @@ -39,7 +40,7 @@ def find_highest_minecraft_version(home): return highest_version def handle_default_minecraft_texture(home, output_dir): - version = find_highest_minecraft_version(home) + version = find_highest_minecraft_version(home, SUPPORTED_MINECRAFT_VERSION) if not version: print("No suitable Minecraft version found.") sys.exit(1)