Skip to content

Commit

Permalink
port 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
Wulian233 authored Jun 15, 2024
1 parent 6db39e8 commit d04134e
Show file tree
Hide file tree
Showing 16 changed files with 242 additions and 38 deletions.
10 changes: 1 addition & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,11 @@ jobs:
.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'build.gradle') }}
- uses: gradle/actions/wrapper-validation@v3
- name: Build
run: |
chmod +x gradlew
./gradlew build
- name: Merge jars
run: |
chmod +x gradlew
./gradlew mergeJars
- name: Publish mod
run: |
chmod +x gradlew
./gradlew publishMod --stacktrace -Porg.gradle.parallel.threads=4
env:
CURSEFORGE_TOKEN: ${{ secrets.CURSEFORGE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
28 changes: 19 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,36 @@
<div align="center">
<img height="100px" width="100px" alt="logo" src="./common/src/main/resources/icon.png"/>
<h1>VM Translation Update</h1>
</div>

<a href="https://modrinth.com/project/vmupdate/">
<img alt="modrinth" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/available/modrinth_vector.svg">
</a>
<a href="https://www.curseforge.com/minecraft/mc-mods/vmtranslationupdate">
<img alt="curseforge" height="56" src="https://cdn.jsdelivr.net/npm/@intergrav/devins-badges@3/assets/cozy/available/curseforge_vector.svg">
</a>

[MC百科](https://www.mcmod.cn/class/11203.html)
</div>

## 功能
1. 对比最新版汉化版本号与本地配置文件中的版本号,在汉化发布新版本时会在游戏里通知玩家去下载更新。
2. 默认每25分钟在聊天栏发送一条知识。内容包括但不限于汉化组冷知识,汉字易错读音和MC冷知识等。
3. 每次启动时自动下载VM汉化组通用模组汉化资源包
1. 在汉化发布新版本时会在游戏里通知玩家去下载更新。
2. 可配置默认每25分钟在聊天栏发送一条知识。内容包括但不限于汉化组冷知识,汉字易错读音和MC冷知识等。
3. 可配置每次启动时自动下载并启用VM汉化组通用模组汉化资源包
4. 如果玩家已经下载资源包且发生错误未启用,会在聊天框提示玩家在选项->资源包中手动启用。
5. 如果玩家名是Zi__Min,会在每次进入世界时发送`欢迎来到籽岷的Minecraft游戏世界!`,且称呼改为岷叔。
6. 自动修改游戏语言,当安装Stenographer模组后不修改
6. 可配置自动修改游戏语言,当安装[Stenographer](https://modrinth.com/mod/stenographer)模组后将禁用

## 使用与配置文件

**发布汉化时,请特别注意。在汉化更新时改一下模组配置里的版本号**
VM汉化组汉化人员请注意:**发布汉化时,请在汉化更新时改一下模组配置里的版本号**

详见:[VMTranslationUpdateMod/wiki/Configs](https://github.com/VM-Chinese-translate-group/VMTranslationUpdateMod/wiki/Configs)
详见:[https://beta.vmct-cn.top/others/vmtu/config](https://beta.vmct-cn.top/others/vmtu/config)

---
## 支持版本
详见:[VMTranslationUpdateMod/wiki/Support-versions](https://github.com/VM-Chinese-translate-group/VMTranslationUpdateMod/wiki/Support-versions)
详见:[https://beta.vmct-cn.top/others/vmtu/support](https://beta.vmct-cn.top/others/vmtu/support)

## 其他
特别感谢TexTrue跨加载器重构,以及Lichiiiiiii修复部分bug!
作者:Wulian233(捂脸)、TexTrue。以及Lichiiiiiii修复部分bug!

本模组使用MIT许可证
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ publisher {
versionType = "release"
changelog = file("CHANGELOG.md").getText('UTF-8')
version = "$rootProject.version"
displayName = "VM Translation Update 1.20.5 - 1.20.6 $rootProject.version"
gameVersions = ["1.20.5", "1.20.6"]
displayName = "VM Translation Update 1.21.x $rootProject.version"
gameVersions = ["1.21"]
curseEnvironment = "client"
loaders = ["fabric", "neoforge"]
artifact = file(forgix.getOutputDir() + "/" + forgix.getMergedJarName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import net.minecraft.client.MinecraftClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import top.vmctcn.vmtranslationupdate.util.ScreenUtil;
import top.vmctcn.vmtranslationupdate.util.*;

import java.util.Random;
Expand All @@ -17,6 +18,8 @@ public class VMTranslationUpdate {
private static final boolean isStenographerLoaded = ModPlatform.isModLoaded("stenographer"); // Stenographer 兼容

public static void init() {
ScreenUtil.checkModsLoaded();

if (ModConfigUtil.getConfig().autoSwitchLanguage && !isStenographerLoaded && ModConfigUtil.getConfig().switchLanguage != null) {
client.options.language = ModConfigUtil.getConfig().switchLanguage;
}
Expand All @@ -25,4 +28,4 @@ public static void init() {
PackDownloadUtil.downloadResPack();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ public class ModConfigs implements ConfigData {
public boolean autoInstallVMTranslationPack = true;
public boolean displayTips = true;
public boolean playerNameCheck = true;
public boolean i18nUpdateModCheck = true;
public boolean vaultPatcherCheck = false;

public String switchLanguage = "zh_cn";
public String modPackTranslationUpdateCheckUrl = "https://vmct-cn.top/modpacks/example/update.txt";
public String modPackTranslationUrl = "https://vmct-cn.top/modpacks/example/";
Expand All @@ -22,4 +25,4 @@ public class ModConfigs implements ConfigData {
public String translationPackName = "VM汉化组模组汉化包1.20";
public String translationPackUrl= "https://cdn.modrinth.com/data/IDWIdXwS/versions/V5YtW17O/";
public String nameUrl = "https://vmct-cn.top/name.json";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package top.vmctcn.vmtranslationupdate.screen;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil;
import top.vmctcn.vmtranslationupdate.util.ScreenUtil;

public class SuggestModScreen extends Screen {
public final Screen lastScreen;
private int ticksUntilEnable = 20 * 10;

private static final int HEADER_HEIGHT = 40;
private static final int FOOTER_HEIGHT = 50;
private static final int BORDER = 40;

public SuggestModScreen(Screen lastScreen) {
super(ScreenUtil.getSuggestScreenTitle().copy().formatted(Formatting.RED).formatted(Formatting.BOLD));
this.lastScreen = lastScreen;
}

@Override
protected void init() {
int centerX = this.width / 2;

super.init();

this.addDrawableChild(ButtonWidget.builder(ScreenUtil.downloadButtonText, buttonWidget -> {
if (ModConfigUtil.getConfig().i18nUpdateModCheck && !ScreenUtil.i18nUpdateModPresent) {
ScreenUtil.openUrlOnScreen(this.client, this, "https://modrinth.com/mod/i18nupdatemod");
} else if (ModConfigUtil.getConfig().vaultPatcherCheck && !ScreenUtil.vaultPatcherPresent) {
ScreenUtil.openUrlOnScreen(this.client, this, "https://modrinth.com/mod/vault-patcher");
}
}).dimensions(centerX - 5 - 150, this.height - (FOOTER_HEIGHT / 2) - 10, 150, 20).build());
this.addDrawableChild(ButtonWidget.builder(ScreenUtil.quitButtonText, buttonWidget -> this.client.scheduleStop()).dimensions(centerX + 5, this.height - (FOOTER_HEIGHT / 2) - 10, 150, 20).build());
}

@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
super.render(context, mouseX, mouseY, delta);

context.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, (HEADER_HEIGHT / 2) - (this.textRenderer.fontHeight / 2), -1);
context.drawCenteredTextWithShadow(this.textRenderer, ScreenUtil.getSuggestScreenText(), this.width / 2, 70, -1);
}

@Override
public void renderBackground(DrawContext context, int mouseX, int mouseY, float partial) {

super.renderBackground(context, mouseX, mouseY, partial);

//Render header and footer separators
RenderSystem.enableBlend();
ScreenUtil.resetShaderColor(context);
Identifier identifier = MinecraftClient.getInstance().world == null ? Screen.HEADER_SEPARATOR_TEXTURE : Screen.INWORLD_HEADER_SEPARATOR_TEXTURE;
Identifier identifier2 = MinecraftClient.getInstance().world == null ? Screen.FOOTER_SEPARATOR_TEXTURE : Screen.INWORLD_FOOTER_SEPARATOR_TEXTURE;
context.drawTexture(identifier, 0, 40 - 2, 0.0F, 0.0F, this.width, 2, 32, 2);
context.drawTexture(identifier2, 0, this.height - 50, 0.0F, 0.0F, this.width, 2, 32, 2);
ScreenUtil.resetShaderColor(context);

}

@Override
public boolean shouldCloseOnEsc() {
return this.ticksUntilEnable <= 0;
}

@Override
public void close() {
MinecraftClient.getInstance().setScreen(this.lastScreen);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package top.vmctcn.vmtranslationupdate.util;

import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ConfirmLinkScreen;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.text.Text;
import net.minecraft.util.Util;
import org.apache.commons.lang3.StringUtils;
import top.vmctcn.vmtranslationupdate.screen.SuggestModScreen;

public class ScreenUtil {
public static boolean i18nUpdateModPresent = false;
public static boolean vaultPatcherPresent = false;
public static boolean firstTitleScreenShown = false;
public static final Text downloadButtonText = Text.translatable("vmtranslationupdate.warn.download.button");
public static final Text quitButtonText = Text.translatable("vmtranslationupdate.warn.quit.button");

public static void screenAfterInitEvent(Screen screen) {
if (firstTitleScreenShown || !(screen instanceof TitleScreen)) {
return;
}

MinecraftClient.getInstance().setScreen(new SuggestModScreen(screen));

firstTitleScreenShown = true;
}

public static void checkModsLoaded() {
try {
Class.forName("i18nupdatemod.I18nUpdateMod");
i18nUpdateModPresent = true;
} catch (ClassNotFoundException e) {
i18nUpdateModPresent = false;
} try {
Class.forName("me.fengming.vaultpatcher_asm.VaultPatcher");
vaultPatcherPresent = true;
} catch (ClassNotFoundException e) {
vaultPatcherPresent = false;
}
}

public static void openUrlOnScreen(MinecraftClient client, Screen screen, String url) {
if (StringUtils.isNotBlank(url) && client != null) {
client.setScreen(new ConfirmLinkScreen(yes -> {
if (yes) {
Util.getOperatingSystem().open(url);
}
client.setScreen(screen);
}, url, true));
}
}

public static void resetShaderColor(DrawContext context) {
context.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}

public static Text getSuggestScreenTitle() {
Text titleText = Text.empty();

if (ModConfigUtil.getConfig().i18nUpdateModCheck && !i18nUpdateModPresent) {
titleText = Text.translatable("vmtranslationupdate.warn.title", "I18nUpdateMod");
} else if (ModConfigUtil.getConfig().vaultPatcherCheck && !vaultPatcherPresent) {
titleText = Text.translatable("vmtranslationupdate.warn.title", "VaultPatcher");
} else if ((ModConfigUtil.getConfig().i18nUpdateModCheck && !i18nUpdateModPresent) && (ModConfigUtil.getConfig().vaultPatcherCheck && !vaultPatcherPresent)) {
titleText = Text.translatable("vmtranslationupdate.warn.text", "I18nUpdateMod & VaultPatcher");
}
return titleText;
}

public static Text getSuggestScreenText() {
Text context = Text.empty();

if (ModConfigUtil.getConfig().i18nUpdateModCheck && !i18nUpdateModPresent) {
context = Text.translatable("vmtranslationupdate.warn.text", "I18nUpdateMod");
} else if (ModConfigUtil.getConfig().vaultPatcherCheck && !vaultPatcherPresent) {
context = Text.translatable("vmtranslationupdate.warn.text", "VaultPatcher");
} else if ((ModConfigUtil.getConfig().i18nUpdateModCheck && !i18nUpdateModPresent) && (ModConfigUtil.getConfig().vaultPatcherCheck && !vaultPatcherPresent)) {
context = Text.translatable("vmtranslationupdate.warn.text", "I18nUpdateMod & VaultPatcher");
}
return context;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@
"vmtranslationupdate.message.zimin": "Welcome to ZiMin's Minecraft world!",
"vmtranslationupdate.message.pack": "VM Chinese Update auto enable localization failed! Please enable \"%s\" pack manually in \"Options -> Resource Packs\".",

"vmtranslationupdate.warn.title": "%s not detected",
"vmtranslationupdate.warn.text": "%s is not yet installed, which may result in incomplete localization of some mods! Please click the button below to jump to the download page.",
"vmtranslationupdate.warn.download.button": "Download",
"vmtranslationupdate.warn.quit.button": "Quit game",


"text.autoconfig.vmtranslationupdate.title": "VM Translation Update Config",
"text.autoconfig.vmtranslationupdate.option.autoSwitchLanguage": "Auto switch language",
"text.autoconfig.vmtranslationupdate.option.checkModPackTranslationUpdate": "Auto-detect modpack translation version update",
"text.autoconfig.vmtranslationupdate.option.autoDownloadVMTranslationPack": "Automatically download VM Chinese Resource pack",
"text.autoconfig.vmtranslationupdate.option.autoInstallVMTranslationPack": "Automatically install the VM Chinese Resource pack",
"text.autoconfig.vmtranslationupdate.option.displayTips": "Display knowledge",
"text.autoconfig.vmtranslationupdate.option.playerNameCheck": "Detecting player name",
"text.autoconfig.vmtranslationupdate.option.i18nUpdateModCheck": "Detecting if I18nUpdateMod is already installed",
"text.autoconfig.vmtranslationupdate.option.vaultPatcherCheck": "Detect if VaultPatcher is installed",

"text.autoconfig.vmtranslationupdate.option.switchLanguage": "Switch language to",
"text.autoconfig.vmtranslationupdate.option.modPackTranslationUpdateCheckUrl": "Update link",
"text.autoconfig.vmtranslationupdate.option.modPackTranslationUrl": "Download link",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
"vmtranslationupdate.message.zimin": "欢迎来到籽岷的Minecraft游戏世界!",
"vmtranslationupdate.message.pack": "VM汉化更新自动启用汉化失败!请在 “选项 -> 资源包” 中手动启用 “%s” 资源包",

"vmtranslationupdate.warn.title": "未检测到 %s 模组",
"vmtranslationupdate.warn.text": "%s 尚未安装,这可能导致某些模组§c汉化不完全§r!请点击下面的按钮跳转到下载页面。",
"vmtranslationupdate.warn.download.button": "下载",
"vmtranslationupdate.warn.quit.button": "退出游戏",

"text.autoconfig.vmtranslationupdate.title": "VM汉化更新检测配置",
"text.autoconfig.vmtranslationupdate.option.autoSwitchLanguage": "自动切换语言",
"text.autoconfig.vmtranslationupdate.option.checkModPackTranslationUpdate": "自动检测整合包汉化版本更新",
"text.autoconfig.vmtranslationupdate.option.autoDownloadVMTranslationPack": "自动下载VM汉化资源包",
"text.autoconfig.vmtranslationupdate.option.autoInstallVMTranslationPack": "自动安装VM汉化资源包",
"text.autoconfig.vmtranslationupdate.option.displayTips": "显示知识内容",
"text.autoconfig.vmtranslationupdate.option.playerNameCheck": "检测玩家名称",
"text.autoconfig.vmtranslationupdate.option.i18nUpdateModCheck": "检测I18nUpdateMod是否已经安装",
"text.autoconfig.vmtranslationupdate.option.vaultPatcherCheck": "检测VaultPatcher是否已经安装",

"text.autoconfig.vmtranslationupdate.option.switchLanguage": "切换语言为",
"text.autoconfig.vmtranslationupdate.option.modPackTranslationUpdateCheckUrl": "更新检测链接",
"text.autoconfig.vmtranslationupdate.option.modPackTranslationUrl": "下载链接",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"comment_mod_info": "NeoForge/Fabric 模组信息翻译",
"comment_mod_info": "NeoForge/Fabric 模組信息翻譯",
"fml.menu.mods.info.displayname.vmtranslationupdate": "VM漢化更新",
"fml.menu.mods.info.description.vmtranslationupdate": "一個用於檢查VM漢化組的漢化補丁更新和自動下載資源包的模組。",
"modmenu.nameTranslation.vmtranslationupdate": "VM漢化更新",
Expand All @@ -13,13 +13,21 @@
"vmtranslationupdate.message.zimin": "歡迎來到籽岷的Minecraft遊戲世界!",
"vmtranslationupdate.message.pack": "VM漢化更新自動啟用漢化失敗!請在 「選項 -> 資源包」 中手動啟用 「%s」 資源包",

"vmtranslationupdate.warn.i18nupdatemod.title": "未檢測到 %s 模組",
"vmtranslationupdate.warn.i18nupdatemod.text": "%s 尚未安裝,這可能導致某些模組§c漢化不完全§r!請點擊下面的按鈕跳轉到下載頁面。",
"vmtranslationupdate.warn.download.button": "下載模組",
"vmtranslationupdate.warn.quit.button": "退出遊戲",

"text.autoconfig.vmtranslationupdate.title": "VM漢化更新檢測配寘",
"text.autoconfig.vmtranslationupdate.option.autoSwitchLanguage": "自動切換語言",
"text.autoconfig.vmtranslationupdate.option.checkModPackTranslationUpdate": "自動檢測整合包版本更新",
"text.autoconfig.vmtranslationupdate.option.autoDownloadVMTranslationPack": "自動下載VM漢化資源包",
"text.autoconfig.vmtranslationupdate.option.autoInstallVMTranslationPack": "自動安裝VM漢化資源包",
"text.autoconfig.vmtranslationupdate.option.displayTips": "顯示知識內容",
"text.autoconfig.vmtranslationupdate.option.playerNameCheck": "檢測玩家名稱",
"text.autoconfig.vmtranslationupdate.option.i18nUpdateModCheck": "檢測I18nUpdateMod是否已經安裝",
"text.autoconfig.vmtranslationupdate.option.vaultPatcherCheck": "檢測VaultPatcher是否已經安裝",

"text.autoconfig.vmtranslationupdate.option.switchLanguage": "切換語言为",
"text.autoconfig.vmtranslationupdate.option.modPackTranslationUpdateCheckUrl": "更新檢測鏈接",
"text.autoconfig.vmtranslationupdate.option.modPackTranslationUrl": "下載鏈接",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import top.vmctcn.vmtranslationupdate.ModEvents;
import top.vmctcn.vmtranslationupdate.VMTranslationUpdate;
import top.vmctcn.vmtranslationupdate.util.ScreenUtil;
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil;

public class VMTranslationUpdateClientFabric implements ClientModInitializer {
Expand All @@ -16,5 +18,9 @@ public void onInitializeClient() {
ModEvents.clientTickEndEvent(client);
}
});

ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
ScreenUtil.screenAfterInitEvent(screen);
});
}
}
}
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
],
"depends": {
"fabric": "*",
"minecraft": ">=1.20.5",
"minecraft": ">=1.21",
"cloth-config": "*"
}
}
Loading

0 comments on commit d04134e

Please sign in to comment.