調整參數位置

修复远程客户端无法加载Cap同步管理器和Compat问题
This commit is contained in:
叁玖领域 2026-01-16 18:15:30 +08:00
parent ea753c4f7d
commit ac0db34a0b
12 changed files with 53 additions and 33 deletions

View File

@ -33,7 +33,7 @@ mod_name=3944Realms 's Lib Mod
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=0.1.5
mod_version=0.1.7
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

View File

@ -1,2 +1,2 @@
// 1.20.1 2026-01-15T15:44:47.1536248 Languages: zh_tw
6d602ad25d759a9ba000c70138fb5e5090ac6657 assets/lib39/lang/zh_tw.json
// 1.20.1 2026-01-16T18:15:18.0777323 Languages: zh_tw
bd0f71ef9ae49f69627d3122efa3b426a89ecbdf assets/lib39/lang/zh_tw.json

View File

@ -1,2 +1,2 @@
// 1.20.1 2026-01-15T15:44:47.1536248 Languages: zh_cn
1d2d816efcddaf84eced9ad85f1efeba650843e7 assets/lib39/lang/zh_cn.json
// 1.20.1 2026-01-16T18:15:18.0777323 Languages: zh_cn
5d897b4cc975c19532c77ec60fd1eb487820a69d assets/lib39/lang/zh_cn.json

View File

@ -1,2 +1,2 @@
// 1.20.1 2026-01-15T15:44:47.1536248 Languages: lzh
7540c6cec408f79a64dce3d60997e54cbf833035 assets/lib39/lang/lzh.json
// 1.20.1 2026-01-16T18:15:18.0777323 Languages: lzh
4116ca2d84d4244b49a9ff8190c2faf0f2e57dc4 assets/lib39/lang/lzh.json

View File

@ -1,2 +1,2 @@
// 1.20.1 2026-01-15T15:44:47.1536248 Languages: en_us
1b6024d50222f8672f22c27645fc035cce0f7a1c assets/lib39/lang/en_us.json
// 1.20.1 2026-01-16T18:15:18.0777323 Languages: en_us
c2a9985bbad60c04fbd5e085bd25bfd00aa8a529 assets/lib39/lang/en_us.json

View File

@ -54,7 +54,7 @@
"item.lib39.fabric": "Fabric",
"item.lib39.forge": "Forge",
"item.lib39.neoforge": "NeoForge",
"sound.lib39.duck_doll": "Duck Doll Sound",
"sound.lib39.subtitle.duck_toy": "Duck Doll Sound",
"tooltip.lib39.content.doll.hover.1": "§eSkinOwner §7:§a %s ",
"tooltip.lib39.content.doll.hover.2": "§7Rename with a player name in an anvil to change skin"
}

View File

@ -54,7 +54,7 @@
"item.lib39.fabric": "織",
"item.lib39.forge": "砧",
"item.lib39.neoforge": "狸",
"sound.lib39.duck_doll": "偶音",
"sound.lib39.subtitle.duck_toy": "偶音",
"tooltip.lib39.content.doll.hover.1": "§e膚主§7:§a%s",
"tooltip.lib39.content.doll.hover.2": "§7鐵砧之上更名以易膚"
}

View File

@ -54,7 +54,7 @@
"item.lib39.fabric": "织布",
"item.lib39.forge": "铁砧",
"item.lib39.neoforge": "小狐狸",
"sound.lib39.duck_doll": "玩偶声音",
"sound.lib39.subtitle.duck_toy": "玩偶声音",
"tooltip.lib39.content.doll.hover.1": "§e皮肤所有者§7:§a%s",
"tooltip.lib39.content.doll.hover.2": "§7在铁砧上可通过重命名对应玩家名来改变皮肤"
}

View File

@ -54,7 +54,7 @@
"item.lib39.fabric": "織布",
"item.lib39.forge": "铁砧",
"item.lib39.neoforge": "狐狸",
"sound.lib39.duck_doll": "玩偶聲音",
"sound.lib39.subtitle.duck_toy": "玩偶聲音",
"tooltip.lib39.content.doll.hover.1": "§e皮膚所有者§7:§a%s",
"tooltip.lib39.content.doll.hover.2": "§7在鐵砧上可通過重命名對應玩家名來改變皮膚"
}

View File

@ -5,6 +5,7 @@ import org.jetbrains.annotations.Unmodifiable;
import top.r3944realms.lib39.Lib39;
import top.r3944realms.lib39.content.register.Lib39Blocks;
import top.r3944realms.lib39.content.register.Lib39Items;
import top.r3944realms.lib39.content.register.Lib39SoundEvents;
import top.r3944realms.lib39.datagen.value.ILangKeyValueCollection;
import top.r3944realms.lib39.datagen.value.LangKeyValue;
import top.r3944realms.lib39.datagen.value.ModPartEnum;
@ -117,7 +118,7 @@ public enum Lib39LangKey implements ILangKeyValueCollection {
);
public static final LangKeyValue DOLL_SOUND = addAndRet(
LangKeyValue.ofKey(
ModPartEnum.SOUND.getFullKey(Lib39.MOD_ID, "duck_doll"), ModPartEnum.SOUND,
Lib39SoundEvents.getSubTitleTranslateKey("duck_toy"), ModPartEnum.SOUND,
"Duck Doll Sound",
"玩偶声音",
"玩偶聲音",

View File

@ -2,6 +2,7 @@ package top.r3944realms.lib39.core.event;
import com.mojang.authlib.GameProfile;
import net.minecraft.Util;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
@ -11,6 +12,7 @@ import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.SkullBlockEntity;
import net.minecraftforge.common.MinecraftForge;
@ -88,23 +90,40 @@ public class CommonEventHandler {
*/
@SubscribeEvent
public static void onWorldLoad(LevelEvent.Load event) {
if (event.getLevel().isClientSide() || !(event.getLevel() instanceof ServerLevel serverLevel)) return;
// 只处理主世界避免多次初始化
if (!serverLevel.dimension().equals(Level.OVERWORLD)) return;
synchronized (Game.class) {
if (!isSync2MInitialized) {
syncData2Manager = new SyncData2Manager();
MinecraftForge.EVENT_BUS.post(new SyncManagerRegisterEvent(syncData2Manager));
isSync2MInitialized = true;
sl = serverLevel;
Lib39.LOGGER.info("SyncData2Manager initialized on world load");
LevelAccessor level = event.getLevel();
if(level instanceof ServerLevel serverLevel) {
// 只处理主世界避免多次初始化
if (!serverLevel.dimension().equals(Level.OVERWORLD)) return;
synchronized (Game.class) {
if (!isSync2MInitialized) {
syncData2Manager = new SyncData2Manager();
MinecraftForge.EVENT_BUS.post(new SyncManagerRegisterEvent(syncData2Manager));
isSync2MInitialized = true;
sl = serverLevel;
Lib39.LOGGER.info("SyncData2Manager initialized on Sever load");
}
if (!isCompatInitialized) {
MinecraftForge.EVENT_BUS.post(new RegisterCompatEvent(Mod.compatManager));
Mod.compatManager.initializeAll();
isCompatInitialized = true;
}
}
if (!isCompatInitialized) {
MinecraftForge.EVENT_BUS.post(new RegisterCompatEvent(Mod.compatManager));
Mod.compatManager.initializeAll();
isCompatInitialized = true;
} else if (level instanceof ClientLevel clientLevel) {
synchronized (Game.class) {
if (!clientLevel.dimension().equals(Level.OVERWORLD)) return;
if (!isSync2MInitialized) {
syncData2Manager = new SyncData2Manager();
MinecraftForge.EVENT_BUS.post(new SyncManagerRegisterEvent(syncData2Manager));
Lib39.LOGGER.info("SyncData2Manager initialized on Client load");
}
if (!isCompatInitialized) {
MinecraftForge.EVENT_BUS.post(new RegisterCompatEvent(Mod.compatManager));
Mod.compatManager.initializeAll();
isCompatInitialized = true;
}
}
}
}
/**

View File

@ -579,7 +579,7 @@ public class NBTWriter {
* @return the nbt writer
*/
// 条件添加方法
public NBTWriter stringIf(String key, Supplier<String> value, boolean condition) {
public NBTWriter stringIf(String key, boolean condition, Supplier<String> value) {
if (condition && value != null) {
root.putString(key, value.get());
}
@ -594,7 +594,7 @@ public class NBTWriter {
* @param condition the condition
* @return the nbt writer
*/
public NBTWriter intValueIf(String key, Supplier<Integer> value, boolean condition) {
public NBTWriter intValueIf(String key, boolean condition, Supplier<Integer> value) {
if (condition && value != null) {
root.putInt(key, value.get());
}
@ -609,7 +609,7 @@ public class NBTWriter {
* @param condition the condition
* @return the nbt writer
*/
public NBTWriter longValueIf(String key, Supplier<Long> value, boolean condition) {
public NBTWriter longValueIf(String key, boolean condition, Supplier<Long> value) {
if (condition && value != null) {
root.putLong(key, value.get());
}
@ -624,7 +624,7 @@ public class NBTWriter {
* @param condition the condition
* @return the nbt writer
*/
public NBTWriter uuidValueIf(String key, Supplier<UUID> value, boolean condition) {
public NBTWriter uuidValueIf(String key, boolean condition, Supplier<UUID> value) {
if (condition && value != null) {
root.putUUID(key, value.get());
}
@ -639,7 +639,7 @@ public class NBTWriter {
* @param condition the condition
* @return the nbt writer
*/
public NBTWriter booleanValueIf(String key, Supplier<Boolean> value, boolean condition) {
public NBTWriter booleanValueIf(String key, boolean condition, Supplier<Boolean> value) {
if (condition && value != null) {
root.putBoolean(key, value.get());
}