33# /// script
44# requires-python = ">=3.12"
55# ///
6- __version__ = '0.2.5 '
6+ __version__ = '0.2.6 '
77__v_type__ = 'release'
88__author__ = 'Slackow'
99__license__ = 'MIT'
1313modified_by = ''
1414# # # # # # # # # # # # # # # # # # # # # #
1515
16- latest_mc_version = '1.21.10 '
16+ latest_mc_version = '26.1 '
1717
1818import textwrap , argparse , json , re , sys , shutil , tempfile
1919from os import chdir
@@ -27,6 +27,8 @@ def ver(base_version, start, end, *, pf):
2727PF = int | tuple [int , int ]
2828pack_formats : dict [str , PF ] = {
2929 'future' : (9001 , 0 ),
30+ '26.1' : (101 , 1 ),
31+ '1.21.11' : (94 , 1 ),
3032 '1.21.10' : (88 , 0 ), '1.21.9' : (88 , 0 ),
3133 '1.21.8' : 81 , '1.21.7' : 81 ,
3234 '1.21.6' : 80 ,
@@ -73,17 +75,23 @@ def right_most_function(contents: str) -> int:
7375
7476
7577def version_or_pf (s : str , default : PF | None = ...) -> PF :
78+ prefix = s [:1 ]
79+ if prefix not in 'pv' :
80+ prefix = None
81+ else :
82+ s = s [1 :]
7683 res = pack_formats .get (s )
77- if res is not None :
84+ if res is not None and prefix != 'p' :
7885 return res
7986 try :
8087 dot = s .index ('.' )
8188 pf = int (s [:dot ]), int (s [dot :])
82- if major_pf (pf ) < DECIMATED_PF : raise ValueError ("Unknown pack format/version" )
89+ if major_pf (pf ) < DECIMATED_PF or prefix == 'v' : raise ValueError ("Unknown pack format/version" , s )
8390 return pf
8491 except ValueError :
8592 try :
8693 pf = int (s )
94+ if prefix == 'v' : raise ValueError ("Unknown pack format/version" , s )
8795 return pf if pf < DECIMATED_PF else with_minor (pf )
8896 except ValueError as e :
8997 if default is not ...:
@@ -349,7 +357,7 @@ def comp_pack(output_folder: Path, pack_format: int, source: bool, verbose: bool
349357 other_path .write_text (content )
350358
351359
352- def comp (* , input : str , output : str , verbose : bool , source : bool , ** _ ):
360+ def compile (* , input : str , output : str , verbose : bool , source : bool , ** _ ):
353361 input : Path = Path (input or '.' ).absolute ()
354362 has_datapack = (input / 'data' ).is_dir ()
355363
@@ -406,7 +414,7 @@ def config(loc: str, *, dst='', mkdirs=False, dirs_exist_ok=False) -> bool:
406414 comp_pack (temp_output , pack_format , source , verbose )
407415 if has_overlays :
408416 registered_overlays = pack_meta .setdefault ('overlays' , {}).setdefault ('entries' , [])
409- overlay_re = re .compile (r'([\d.]+)-([\d.]+|future)' )
417+ overlay_re = re .compile (r'([pv]?[ \d.]+)-([pv]? [\d.]+|future)' )
410418 for overlay in sorted ((input / 'overlays' ).iterdir ()):
411419 if overlay .name in (reg ['directory' ] for reg in registered_overlays ):
412420 continue
@@ -422,6 +430,7 @@ def config(loc: str, *, dst='', mkdirs=False, dirs_exist_ok=False) -> bool:
422430 'min_format' : with_minor (min ), 'max_format' : with_minor (max ),
423431 'directory' : overlay .name ,
424432 }
433+
425434 if with_minor (pack_meta .get ('pack' , {}).get ('min_format' , 0 )) >= (DECIMATED_PF , 0 ):
426435 del overlay_value ['formats' ]
427436 registered_overlays .insert (0 , overlay_value )
@@ -574,6 +583,7 @@ def init_template(*, name: str, description: str, pack_format: PF, output: str,
574583 init_modded_template (name , description , output , namespace )
575584
576585
586+ # <editor-fold defaultstate="collapsed" desc="def update_pack_format(): ...">
577587def update_pack_format (* , input : str , target : str , min : str , max : str , ** _ ) -> None :
578588 input : Path = Path (input ).absolute ()
579589 pack_meta = read_pack_meta (input )
@@ -616,7 +626,7 @@ def c(s: str) -> str:
616626 print (c (f"{ 'target pack_format:' :<20} { target !s:>9} { versions_of (target )} " ))
617627 if min :
618628 print (c (f"{ 'min pack_format:' :<20} { min !s:>9} { versions_of (min )} " ))
619-
629+ # </editor-fold>
620630
621631# <editor-fold defaultstate="collapsed" desc="def update(): ...">
622632def get_data_from_url (url : str , max_redirects = 10 ):
@@ -753,7 +763,7 @@ def main():
753763 elif args .command is None :
754764 parser .print_help ()
755765 elif args .command .startswith ('c' ):
756- comp (** args_dict )
766+ compile (** args_dict )
757767 elif args .command .startswith ('p' ):
758768 update_pack_format (** args_dict )
759769 elif args .command .startswith ('u' ):
0 commit comments