Skip to content

Commit be3273b

Browse files
committed
fix: 更新 packFormat 字段为可选
1 parent 28eaac9 commit be3273b

3 files changed

Lines changed: 12 additions & 12 deletions

File tree

src/main/java/i18nupdatemod/core/ResourcePackConverter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public ResourcePackConverter(List<ResourcePack> resourcePack, String filename) {
3232
this.tmpFilePath = FileUtil.getTemporaryPath(filename);
3333
}
3434

35-
public void convert(int packFormat, Integer minFormat, Integer maxFormat, String description) throws Exception {
35+
public void convert(Integer packFormat, Integer minFormat, Integer maxFormat, String description) throws Exception {
3636
Set<String> fileList = new HashSet<>();
3737
try (ZipOutputStream zos = new ZipOutputStream(
3838
Files.newOutputStream(tmpFilePath),
@@ -74,13 +74,13 @@ public void convert(int packFormat, Integer minFormat, Integer maxFormat, String
7474
}
7575
}
7676

77-
private byte[] convertPackMeta(InputStream is, int packFormat, Integer minFormat, Integer maxFormat, String description) {
77+
private byte[] convertPackMeta(InputStream is, Integer packFormat, Integer minFormat, Integer maxFormat, String description) {
7878
PackMeta meta = GSON.fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), PackMeta.class);
79-
// 从 pack_format 69 (1.21.9) 开始,只用 min_format/max_format,不再使用 pack_format
80-
if (packFormat >= 69) {
79+
// 1.21.9+ 使用 min_format/max_format,不再使用 pack_format
80+
if (minFormat != null && maxFormat != null) {
8181
meta.pack.pack_format = null;
82-
meta.pack.min_format = minFormat != null ? minFormat : packFormat;
83-
meta.pack.max_format = maxFormat != null ? maxFormat : packFormat;
82+
meta.pack.min_format = minFormat;
83+
meta.pack.max_format = maxFormat;
8484
} else {
8585
meta.pack.pack_format = packFormat;
8686
meta.pack.min_format = null;

src/main/java/i18nupdatemod/entity/GameAssetDetail.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
public class GameAssetDetail {
66
public List<AssetDownloadDetail> downloads;
7-
public Integer covertPackFormat;
8-
public Integer minFormat; // pack.mcmeta min_format,用于 pack_format >= 69
9-
public Integer maxFormat; // pack.mcmeta max_format,用于 pack_format >= 69
7+
public Integer covertPackFormat; // 旧格式 pack_format
8+
public Integer minFormat; // 新格式 min_format
9+
public Integer maxFormat; // 新格式 max_format
1010
public String covertFileName;
1111

1212
public static class AssetDownloadDetail {

src/main/java/i18nupdatemod/entity/GameMetaData.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
public class GameMetaData {
66
public String gameVersions;
7-
public int packFormat;
8-
public Integer minFormat; // 可选,用于 pack_format >= 69 的版本范围
9-
public Integer maxFormat; // 可选,用于 pack_format >= 69 的版本范围
7+
public Integer packFormat; // 旧格式,用于 1.21.8 及之前
8+
public Integer minFormat; // 新格式,用于 1.21.9 及之后
9+
public Integer maxFormat; // 新格式,用于 1.21.9 及之后
1010
public List<String> convertFrom;
1111
}

0 commit comments

Comments
 (0)