BaublesApi
基本信息
| 属性 | 值 |
|---|---|
| 路径 | baubles.api.BaublesApi |
| 类型 | class |
| 包名 | baubles.api |
方法
| 方法 | 返回值 | 描述 |
|---|---|---|
getBaubles(EntityPlayer player) |
IInventory |
通过反射调用 baubles.common.lib.PlayerHandler.getPlayerBaubles(EntityPlayer),返回指定玩家的饰品栏 IInventory |
功能
为依赖 Baubles 的其他 mod 提供一个轻量的入口类,避免外部 mod 直接耦合 Baubles 内部实现。
- 内部使用
Class.forName("baubles.common.lib.PlayerHandler").getMethod("getPlayerBaubles", ...),并缓存 Method 对象 - 反射调用失败时通过
FMLLog.warning记录,并返回null - 调用方在拿到
IInventory后可使用通用的IInventory方法访问槽位(如getSizeInventory、getStackInSlot、isItemValidForSlot等)
注意事项
- 该类与原版 Baubles 一致;扩展层并未直接修改其实现
- 跨 mod 调用应优先使用 IBaubleExpanded / BaubleExpandedSlots 的能力来检查类型与槽位匹配
相关条目
- PlayerHandler - 反射访问的实际目标
- InventoryBaubles - 实际 IInventory 实现
- BaubleExpandedSlots - 扩展槽位能力查询