22
33import com .google .gson .Gson ;
44import com .google .gson .GsonBuilder ;
5+ import i18nupdatemod .entity .GameMetaData ;
56import i18nupdatemod .util .FileUtil ;
67import i18nupdatemod .util .Log ;
78import org .apache .commons .io .IOUtils ;
@@ -32,7 +33,7 @@ public ResourcePackConverter(List<ResourcePack> resourcePack, String filename) {
3233 this .tmpFilePath = FileUtil .getTemporaryPath (filename );
3334 }
3435
35- public void convert (Integer packFormat , Integer minFormat , Integer maxFormat , String description ) throws Exception {
36+ public void convert (GameMetaData metaData , String description ) throws Exception {
3637 Set <String > fileList = new HashSet <>();
3738 try (ZipOutputStream zos = new ZipOutputStream (
3839 Files .newOutputStream (tmpFilePath ),
@@ -57,7 +58,7 @@ public void convert(Integer packFormat, Integer minFormat, Integer maxFormat, St
5758 InputStream is = zf .getInputStream (ze );
5859 if (name .equalsIgnoreCase ("pack.mcmeta" )) {
5960 //Convert pack.mcmeta
60- zos .write (convertPackMeta (is , packFormat , minFormat , maxFormat , description ));
61+ zos .write (convertPackMeta (is , metaData , description ));
6162 } else {
6263 //Copy other file
6364 IOUtils .copy (is , zos );
@@ -74,15 +75,15 @@ public void convert(Integer packFormat, Integer minFormat, Integer maxFormat, St
7475 }
7576 }
7677
77- private byte [] convertPackMeta (InputStream is , Integer packFormat , Integer minFormat , Integer maxFormat , String description ) {
78+ private byte [] convertPackMeta (InputStream is , GameMetaData metaData , String description ) {
7879 PackMeta meta = GSON .fromJson (new InputStreamReader (is , StandardCharsets .UTF_8 ), PackMeta .class );
7980 // 1.21.9+ 使用 min_format/max_format,不再使用 pack_format
80- if (minFormat != null && maxFormat != null ) {
81+ if (metaData . useNewFormat () ) {
8182 meta .pack .pack_format = null ;
82- meta .pack .min_format = minFormat ;
83- meta .pack .max_format = maxFormat ;
83+ meta .pack .min_format = metaData . minFormat ;
84+ meta .pack .max_format = metaData . maxFormat ;
8485 } else {
85- meta .pack .pack_format = packFormat ;
86+ meta .pack .pack_format = metaData . packFormat ;
8687 meta .pack .min_format = null ;
8788 meta .pack .max_format = null ;
8889 }
0 commit comments