-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from VM-Chinese-translate-group/1.21.x-v3tex
VMTU v3
- Loading branch information
Showing
51 changed files
with
1,924 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ classes/ | |
.metadata | ||
.vscode | ||
.settings | ||
*.launch | ||
*.launch | ||
/.architectury-transformer/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
# v3.0 更新日志 | ||
|
||
等待@TexBlock修复屏幕提示SuggestModScreen#L56-L59,新版本代码变动大,无法使用部分代码已被注释。文字不会换行,也没了背景 | ||
|
||
## 移除 | ||
|
||
- 移除指定玩家id称呼功能,包括`playerNameCheck`和`nameUrl`配置项 | ||
- 移除下载Modtinth汉化资源包功能 | ||
- 移除籽岷游戏id彩蛋 | ||
- 移除tips功能 | ||
|
||
# 新功能 | ||
|
||
- 现在自动切换语言(`autoSwitchLanguage`)功能默认为开启状态 | ||
- 支持1.21.4,中间版本1.20-1.21.1不支持,1.21.3未测试 | ||
- 未安装推荐模组时模组安装提示屏幕的“退出游戏”按钮改为“我知道我在做什么!”按钮,将不会退出游戏 | ||
- 模组安装提示屏幕现在仅会在简体中文时出现 | ||
- 重新添加资源包下载装载功能 (下载核心基于I18nUpdateMod3代码修改) | ||
|
||
# 修复 | ||
|
||
- 修复按esc键无法退出推荐模组安装提示屏幕的bug | ||
- 修复更新检测出现问题时提示两次的问题 | ||
|
||
# 优化 | ||
|
||
- 优化一些语言文件的内容表达 | ||
- 优化配置屏幕配置选项排布顺序,为`tipsMinutes`项加入滑块 | ||
- 优化网络请求,现在每次进入游戏只会发起一次获取tips的请求 | ||
- 繁体中文本地化改进 | ||
- 优化语言切换功能 (基于I18nUpdateMod3代码修改) | ||
- 优化CoreMod检测方式 | ||
|
||
## 核心开发 | ||
|
||
- 合并模组为多模组加载器版工具 forgix -> modfusioner | ||
- 更新所有依赖版本 | ||
- 修复GitHub CI 工作流 | ||
- 移除`util/NameUtil.java`合并代码至`ModEvents.java` | ||
- 简化代码 | ||
- 添加部分跨版本兼容代码 | ||
- 升级游戏版本为1.21.4 | ||
- 添加基于I18nUpdateMod3代码的下载核心 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 35 additions & 50 deletions
85
common/src/main/java/top/vmctcn/vmtranslationupdate/ModEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,59 @@ | ||
package top.vmctcn.vmtranslationupdate; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.screen.Screen; | ||
import net.minecraft.client.gui.screen.TitleScreen; | ||
import net.minecraft.server.network.ServerPlayerEntity; | ||
import net.minecraft.text.ClickEvent; | ||
import net.minecraft.text.HoverEvent; | ||
import net.minecraft.text.Style; | ||
import net.minecraft.text.Text; | ||
import net.minecraft.util.Formatting; | ||
import top.vmctcn.vmtranslationupdate.screen.SuggestModScreen; | ||
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil; | ||
import top.vmctcn.vmtranslationupdate.util.TipsUtil; | ||
import top.vmctcn.vmtranslationupdate.util.VersionCheckUtil; | ||
|
||
import java.util.Objects; | ||
import java.util.Random; | ||
import java.util.concurrent.CompletableFuture; | ||
import top.vmctcn.vmtranslationupdate.util.VersionCheckUtil; | ||
|
||
public class ModEvents { | ||
private static boolean isLoadedTips = false; // 标识Tips是否已经从网络加载 | ||
public static int tickCounter; | ||
public static Random random = new Random(); | ||
public static boolean firstTitleScreenShown = false; | ||
|
||
public static void playerJoinEvent(ServerPlayerEntity player) { | ||
String localVersion = ModConfigUtil.getConfig().modPackTranslationVersion; | ||
String onlineVersion = VersionCheckUtil.getOnlineVersion(); | ||
|
||
public static void clientTickEndEvent(MinecraftClient client) { | ||
tickCounter++; | ||
int tickInterval = 20 * 60 * TipsUtil.getTipsMinutes(); | ||
if (tickCounter >= tickInterval) { | ||
if (!isLoadedTips) { | ||
CompletableFuture.supplyAsync(() -> TipsUtil.getRandomMessageFromURLAsync(ModConfigUtil.getConfig().tipsUrl)) | ||
.thenAccept(message -> { | ||
isLoadedTips = true; | ||
if (message == null) return; | ||
String randomMessage = getRandomMessageFromCache(); | ||
if (randomMessage != null) { | ||
Objects.requireNonNull(client.player).sendMessage(Text.translatable(randomMessage), false); | ||
} | ||
}); | ||
} else { | ||
// 如果已经加载过提示信息,直接从缓存中获取随机消息 | ||
String randomMessage = getRandomMessageFromCache(); | ||
if (randomMessage != null) { | ||
Objects.requireNonNull(client.player).sendMessage(Text.translatable(randomMessage), false); | ||
} | ||
if (ModConfigUtil.getConfig().checkModPackTranslationUpdate) { | ||
if (onlineVersion.isEmpty()) { | ||
player.sendMessage(Text.translatable("vmtranslationupdate.message.error"), false); | ||
VMTranslationUpdate.LOGGER.warn("Error fetching modpack translation version"); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
private static String getRandomMessageFromCache() { | ||
if (!TipsUtil.messagesList.isEmpty()) { | ||
int index = random.nextInt(TipsUtil.messagesList.size()); | ||
return TipsUtil.messagesList.get(index); | ||
if (!localVersion.equals(onlineVersion)) { | ||
player.sendMessage(Text.translatable("vmtranslationupdate.message.update", localVersion, onlineVersion)); | ||
Text message = Text.translatable("vmtranslationupdate.message.update2") | ||
.append(Text.translatable(ModConfigUtil.getConfig().modPackTranslationUrl) | ||
.setStyle(Style.EMPTY | ||
.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, ModConfigUtil.getConfig().modPackTranslationUrl)) | ||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("vmtranslationupdate.message.hover"))) | ||
.withColor(Formatting.AQUA) | ||
)) | ||
.append(Text.translatable("vmtranslationupdate.message.update3")); | ||
player.sendMessage(message); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public static void playerJoinEvent(ServerPlayerEntity player) { | ||
String name = player.getName().getString(); | ||
String localVersion = ModConfigUtil.getConfig().modPackTranslationVersion; | ||
String onlineVersion = VersionCheckUtil.getOnlineVersion(player); | ||
public static void screenAfterInitEvent(Screen screen) { | ||
if (firstTitleScreenShown || !(screen instanceof TitleScreen)) { | ||
return; | ||
} | ||
|
||
if (ModConfigUtil.getConfig().checkModPackTranslationUpdate && !localVersion.equals(onlineVersion)) { | ||
player.sendMessage(Text.translatable("vmtranslationupdate.message.update", name, localVersion, onlineVersion)); | ||
Text message = Text.translatable("vmtranslationupdate.message.update2") | ||
.append(Text.translatable(ModConfigUtil.getConfig().modPackTranslationUrl) | ||
.setStyle(Style.EMPTY | ||
.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, ModConfigUtil.getConfig().modPackTranslationUrl)) | ||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.translatable("vmtranslationupdate.message.hover"))) | ||
.withColor(Formatting.AQUA) | ||
)) | ||
.append(Text.translatable("vmtranslationupdate.message.update3")); | ||
String language = MinecraftClient.getInstance().getLanguageManager().getLanguage(); | ||
|
||
player.sendMessage(message); | ||
if ("zh_cn".equals(language)) { | ||
MinecraftClient.getInstance().setScreen(new SuggestModScreen(screen)); | ||
} | ||
|
||
firstTitleScreenShown = true; | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
common/src/main/java/top/vmctcn/vmtranslationupdate/ModPlatform.java
This file was deleted.
Oops, something went wrong.
11 changes: 3 additions & 8 deletions
11
common/src/main/java/top/vmctcn/vmtranslationupdate/VMTranslationUpdate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
package top.vmctcn.vmtranslationupdate; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil; | ||
import top.vmctcn.vmtranslationupdate.util.ScreenUtil; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class VMTranslationUpdate { | ||
public static final String MOD_ID = "vmtranslationupdate"; | ||
static MinecraftClient client = MinecraftClient.getInstance(); | ||
public static final Logger LOGGER = LoggerFactory.getLogger("VMTranslationUpdateMod"); | ||
|
||
public static void init() { | ||
ScreenUtil.checkModsLoaded(); | ||
|
||
if (ModConfigUtil.getConfig().autoSwitchLanguage && ModConfigUtil.getConfig().switchLanguage != null) { | ||
client.options.language = ModConfigUtil.getConfig().switchLanguage; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
common/src/main/java/top/vmctcn/vmtranslationupdate/respack/GameOptionsSetter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package top.vmctcn.vmtranslationupdate.respack; | ||
|
||
import top.vmctcn.vmtranslationupdate.VMTranslationUpdate; | ||
import top.vmctcn.vmtranslationupdate.util.ModConfigUtil; | ||
import top.vmctcn.vmtucore.ModPlatform; | ||
import top.vmctcn.vmtucore.VMTUCore; | ||
import top.vmctcn.vmtucore.respack.GameOptionsWriter; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
|
||
public class GameOptionsSetter { | ||
public static void init(Path gamePath) { | ||
if (ModConfigUtil.getConfig().autoSwitchLanguage && ModConfigUtil.getConfig().switchLanguage != null) { | ||
try { | ||
GameOptionsWriter config = new GameOptionsWriter(gamePath.resolve("options.txt")); | ||
config.switchLanguage(ModConfigUtil.getConfig().switchLanguage); | ||
} catch (IOException e) { | ||
VMTranslationUpdate.LOGGER.warn("Failed to switch language: ", e); | ||
} | ||
} | ||
|
||
if (ModConfigUtil.getConfig().autoDownloadVMTranslationPack) { | ||
String gameVersion = ModPlatform.INSTANCE.getGameVersion(); | ||
ResPackSource resPackSource = ModConfigUtil.getConfig().translationPackSource; | ||
VMTUCore.init(gamePath, gameVersion, "VM汉化组模组汉化包1.20", resPackSource.getUrl()); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
common/src/main/java/top/vmctcn/vmtranslationupdate/respack/ResPackSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package top.vmctcn.vmtranslationupdate.respack; | ||
|
||
public enum ResPackSource { | ||
GITEE("https://gitee.com/Wulian233/vmtu/raw/main/resourcepack/"); | ||
|
||
private final String sourceUrl; | ||
|
||
ResPackSource(String sourceUrl) { | ||
this.sourceUrl = sourceUrl; | ||
} | ||
|
||
public String getUrl() { | ||
return this.sourceUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.