Links
Tags
Creators
Details
1.0.5
Compatibility
Required content
Changes
Enchant Enhancemen 1.0.5 for 1.21-1.21.3
一、服务器配置同步修复与完善
概述
修复 v1.0.4 中引入的 ServerPlayerJoinListener 崩溃问题(ConcurrentHashMap.entry.setValue 不支持),并完善配置同步机制。
文件变更
| 文件 | 修改 |
|---|---|
EnchantEnhancement.java |
移除内部类 EnchantEnhancementClient 和 EnchantEnhancementServer;onInitialize() 通过 ServerLifecycleEvents.SERVER_STARTING 统一处理专用服务器和 LAN 集成服务器初始化;注册 ServerTickEvents.END_SERVER_TICK 驱动延迟同步队列 |
EnchantEnhancementClient.java |
新建 — 独立客户端入口类:注册网络包接收器 + 加载本地配置 |
fabric.mod.json |
client entrypoint 增加 EnchantEnhancementClient;fabricloader 最低版本 >=0.16.10 |
ServerPlayerJoinListener.java |
ENTITY_LOAD → JOIN(ServerPlayConnectionEvents);40 tick 延迟队列使用 ConcurrentHashMap + Iterator 替代 removeIf;增加 DISCONNECT 清理;新增 syncToAllPlayers() 静态方法;新增 tickPendingSync() 驱动延迟队列 |
EnchantmentConfig.java |
syncConfigToAllPlayers() 调用 ServerPlayerJoinListener.syncToAllPlayers() 实现实际推送;syncConfig() 增加 if (isServer) return 防主机自锁;移除 save() 和 load() 中的 isConfigSynced 守卫;新增 saveConfigToFile(generalConfig, enchantmentsConfig) 方法;新增 getDefaultLevels() 方法 |
二、多人游戏配置 UI 行为优化
概述
多人游戏中配置界面始终可交互,玩家修改后可保存到本地配置文件,但游戏行为仍跟随服务器配置(不修改 EnchantmentConfig 内存值)。
实现原理
ConfigScreen 新增 9 个 UI 本地状态变量(uiMergeHighEnchantments 等),只读模式下所有 UI 修改仅更新本地副本。保存时通过 EnchantmentConfig.saveConfigToFile() 直接写入文件,不修改 EnchantmentConfig 内存值。
行为对照
| 场景 | UI 可操作 | 修改保存到本地文件 | 游戏行为跟随 |
|---|---|---|---|
| 单人游戏 | 是 | 是(更新内存+文件) | 本地配置 |
| 主机(LAN/集成服务器) | 是 | 是(更新内存+文件) | 主机配置 |
| 多人游戏客户端(已同步) | 是 | 是(仅写文件) | 服务器配置 |
文件变更
| 文件 | 修改 |
|---|---|
ConfigScreen.java |
新增 isReadOnly 标记和 9 个 uiXxx 本地状态变量;UI 始终可交互移除了 isDisabled 对输入框编辑/点击的限制;saveChanges() 根据 isReadOnly 走不同路径(直接写文件 vs 更新内存后保存);handleResetButton() 和 RestoreDefaultsEntry 在只读模式下仅重置 UI 本地状态 |
三、附魔等级分组视觉优化
- 分组内展开条目向右缩进 18px
- 展开条目名称颜色变灰(
0xFFAAAAAA) - 展开条目输入框缩小(64×16 vs 78×18)
文件变更
| 文件 | 修改 |
|---|---|
ConfigScreen.java |
EnchantmentEntry 新增 isIndented 属性;render 方法根据缩进状态调整偏移、颜色、输入框尺寸;updateListContent() 中展开的分组条目传入 isIndented=true |
四、依赖与环境修复
| 文件 | 修改 |
|---|---|
gradle.properties |
Fabric Loader 0.18.5 → 0.19.3;版本号 1.0.4 → 1.0.5 |
Projects on Modrinth are automatically available through a Maven repository for use with JVM build tools such as Gradle. To learn more about the Modrinth Maven API, click here.
Note: When available, you should use the creator's maven repo instead as it will have transitive dependency information that the Modrinth Maven API does not. You may also end up with duplicate dependencies if you use a mix of Modrinth and non-Modrinth Maven repositories for your dependencies, because the group identifier will be different when served through the Modrinth Maven API.
Maven coordinates:
Version ID:
build.gradle:
repositories {
exclusiveContent {
forRepository {
maven {
name = "Modrinth"
url = "https://api.modrinth.com/maven"
}
}
// forRepositories(fg.repository) // Uncomment when using ForgeGradle
filter {
includeGroup "maven.modrinth"
}
}
}
// Standard Gradle dependency
dependencies {
implementation "maven.modrinth:83ePyWr3:GyNeCh3l"
}
// Legacy Loom dependency
dependencies {
modImplementation "maven.modrinth:83ePyWr3:GyNeCh3l"
}

