Baubles(主 mod 类)
基本信息
| 属性 | 值 |
|---|---|
| 路径 | baubles.common.Baubles |
| 类型 | class |
| 注解 | @Mod(modid="Baubles", name="Baubles", version=Baubles.VERSION) |
| 包名 | baubles.common |
静态字段
| 字段 | 值 | 用途 |
|---|---|---|
MODID |
"Baubles" |
Mod ID(注意:与 BaublesExpanded.MODID 不同) |
MODNAME |
"Baubles" |
显示名 |
VERSION |
Tags.VERSION(gradle 注入) |
mod 版本 |
proxy |
CommonProxy(@SidedProxy) |
客户端为 baubles.client.ClientProxy,服务端为 baubles.common.CommonProxy |
instance |
Baubles |
@Mod.Instance |
entityEventHandler |
EventHandlerEntity |
实体事件处理器实例 |
entityEventNetwork |
EventHandlerNetwork |
网络事件处理器实例 |
cleanupEventHandler |
EventHandlerCleanup |
缓存清理处理器实例 |
log |
Logger |
log4j logger,名为 "Baubles" |
GUI |
0 |
mod 拥有的 GUI ID(用于 openGui) |
itemDebugger |
ItemDebugger |
调试物品实例 |
生命周期事件
preInit(FMLPreInitializationEvent)
- 设置
modMetadata.parent = BaublesExpanded.MODID(让 mod 列表里本 mod 显示为 Baubles-Expanded 的子 mod) PacketHandler.init()- 创建并注册三个事件处理器(EventHandlerEntity、EventHandlerNetwork、EventHandlerCleanup)
- 调
proxy.registerHandlers()
init(FMLInitializationEvent)
- 故意延迟:
BaublesConfig.loadConfig(new Configuration(...Baubles.cfg))在 init 期间加载,目的是让其他 mod 在 preinit 注册扩展 bauble 类型后,本 mod 再读配置 NetworkRegistry.INSTANCE.registerGuiHandler(instance, proxy)proxy.registerKeyBindings()(客户端注册 KeyHandler 和 GuiEvents)GameRegistry.registerItem(itemDebugger, "bauble_slot_debug_tool", "Baubles")- 若 NEI 加载且
hideDebugItem=true:API.hideItem("bauble_slot_debug_tool")
onServerStopped(FMLServerStoppedEvent)
- 调
PlayerHandler.clearServerPlayerBaubles()清空服务端缓存
注意事项
MODID="Baubles"而非Baubles|Expanded;Baubles|Expanded是 BaublesExpanded 类 的 modid- 本 mod 实际上拥有
@Mod注解(即使名字带 “Expanded”,实际注册 id 是Baubles),这样做是为了让 Thaumcraft / 其他 mod 通过 modid"Baubles"检测到本 mod - 显示名
Baubles来自 mcmod.info 模板(gradle.properties 中的 modName = “Baubles Expanded” 仅用于模板)
相关条目
- BaublesExpanded(mod 容器) - parent modid 来源
- PacketHandler
- BaublesConfig
- ItemDebugger