Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=3.7.0
minecraft=1.6.1,1.6.2,1.6.4,1.7.2,1.7.10,1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9,1.21.10
version=3.7.1
minecraft=1.6.1,1.6.2,1.6.4,1.7.2,1.7.10,1.8,1.8.8,1.8.9,1.9,1.9.4,1.10,1.10.2,1.11,1.11.2,1.12,1.12.1,1.12.2,1.13.2,1.14,1.14.1,1.14.2,1.14.3,1.14.4,1.15,1.15.1,1.15.2,1.16,1.16.1,1.16.2,1.16.3,1.16.4,1.16.5,1.17,1.17.1,1.18,1.18.1,1.18.2,1.19,1.19.1,1.19.2,1.19.3,1.19.4,1.20,1.20.1,1.20.2,1.20.3,1.20.4,1.20.5,1.20.6,1.21,1.21.1,1.21.2,1.21.3,1.21.4,1.21.5,1.21.6,1.21.7,1.21.8,1.21.9,1.21.10,1.21.11
curseforge=NeoForge,Forge,Fabric,Quilt,Client,Java 8,Java 9,Java 10,Java 11,Java 12,Java 13,Java 14,Java 15,Java 16,Java 17,Java 18
4 changes: 3 additions & 1 deletion src/main/java/i18nupdatemod/I18nUpdateMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import i18nupdatemod.core.ResourcePack;
import i18nupdatemod.core.ResourcePackConverter;
import i18nupdatemod.entity.GameAssetDetail;
import i18nupdatemod.entity.GameMetaData;
import i18nupdatemod.util.FileUtil;
import i18nupdatemod.util.Log;

Expand Down Expand Up @@ -74,8 +75,9 @@ public static void init(Path minecraftPath, String minecraftVersion, String load
if (!convertNotNeed) {
FileUtil.setTemporaryDirPath(Paths.get(localStorage, "." + MOD_ID, minecraftVersion));
applyFileName = assets.covertFileName;
GameMetaData metaData = I18nConfig.getPackFormat(minecraftVersion);
ResourcePackConverter converter = new ResourcePackConverter(languagePacks, applyFileName);
converter.convert(assets.covertPackFormat, getResourcePackDescription(assets.downloads));
converter.convert(metaData, getResourcePackDescription(assets.downloads));
}

//Apply resource pack
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/i18nupdatemod/core/I18nConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,15 @@ public static GameAssetDetail getAssetDetail(String minecraftVersion, String loa
ret.downloads = createDownloadDetails(convert, loader, assetRoot);
}

ret.covertPackFormat = convert.packFormat;
ret.covertFileName =
String.format("Minecraft-Mod-Language-Modpack-Converted-%s.zip", minecraftVersion);
return ret;
}

public static GameMetaData getPackFormat(String minecraftVersion) {
return getGameMetaData(minecraftVersion);
}

private static List<GameAssetDetail.AssetDownloadDetail> createDownloadDetails(GameMetaData convert, String loader, String assetRoot) {
return convert.convertFrom.stream().map(it -> getAssetMetaData(it, loader)).map(it -> {
GameAssetDetail.AssetDownloadDetail adi = new GameAssetDetail.AssetDownloadDetail();
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/i18nupdatemod/core/ResourcePackConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import i18nupdatemod.entity.GameMetaData;
import i18nupdatemod.util.FileUtil;
import i18nupdatemod.util.Log;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -32,7 +33,7 @@ public ResourcePackConverter(List<ResourcePack> resourcePack, String filename) {
this.tmpFilePath = FileUtil.getTemporaryPath(filename);
}

public void convert(int packFormat, String description) throws Exception {
public void convert(GameMetaData metaData, String description) throws Exception {
Set<String> fileList = new HashSet<>();
try (ZipOutputStream zos = new ZipOutputStream(
Files.newOutputStream(tmpFilePath),
Expand All @@ -57,7 +58,7 @@ public void convert(int packFormat, String description) throws Exception {
InputStream is = zf.getInputStream(ze);
if (name.equalsIgnoreCase("pack.mcmeta")) {
//Convert pack.mcmeta
zos.write(convertPackMeta(is, packFormat, description));
zos.write(convertPackMeta(is, metaData, description));
} else {
//Copy other file
IOUtils.copy(is, zos);
Expand All @@ -74,9 +75,11 @@ public void convert(int packFormat, String description) throws Exception {
}
}

private byte[] convertPackMeta(InputStream is, int packFormat, String description) {
private byte[] convertPackMeta(InputStream is, GameMetaData metaData, String description) {
PackMeta meta = GSON.fromJson(new InputStreamReader(is, StandardCharsets.UTF_8), PackMeta.class);
meta.pack.pack_format = packFormat;
meta.pack.pack_format = metaData.useNewFormat() ? null : metaData.packFormat;
meta.pack.min_format = metaData.useNewFormat() ? metaData.minFormat : null;
meta.pack.max_format = metaData.useNewFormat() ? metaData.maxFormat : null;
meta.pack.description = description;
return GSON.toJson(meta).getBytes(StandardCharsets.UTF_8);
}
Expand All @@ -85,7 +88,9 @@ private static class PackMeta {
Pack pack;

private static class Pack {
int pack_format;
Integer pack_format; // 改为 Integer,支持 null
Integer min_format;
Integer max_format;
String description;
}
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/i18nupdatemod/entity/GameAssetDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

public class GameAssetDetail {
public List<AssetDownloadDetail> downloads;
public Integer covertPackFormat;
public String covertFileName;

public static class AssetDownloadDetail {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/i18nupdatemod/entity/GameMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public class GameMetaData {
public String gameVersions;
public int packFormat;
public Integer packFormat, minFormat, maxFormat;
public List<String> convertFrom;

public boolean useNewFormat() { return minFormat != null && maxFormat != null; }
}
7 changes: 4 additions & 3 deletions src/main/resources/i18nMetaData.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,10 @@
]
},
{
"gameVersions": "[1.21.9,1.21.10]",
"packFormat": 69,
"convertFrom": [
"gameVersions": "[1.21.9,1.21.11]",
"minFormat": 69,
"maxFormat": 75,
"convertFrom":[
"1.21",
"1.20",
"1.19"
Expand Down