配方面板物品

[!INFO] 注册名 neirecipepanels:recipe_panel | 类 ItemRecipePanel | 源码 src/main/java/com/neirecipepanels/item/ItemRecipePanel.java

基本信息

属性 值
注册名 neirecipepanels:recipe_panel
物品类 ItemRecipePanel(继承 Item)
最大堆叠 16
创造标签 tabMisc
贴图 neirecipepanels:recipe_blueprint(与方块同一张图)
附魔适用 否(未覆写 getItemEnchantability() / canApplyAtEnchantingTable,基类 enchantability 为 0)
耐久度 无(未覆写 setMaxDamage,基类为 0)

功能

承载一份刻印下来的 NEI 配方。挂在墙上后,配方面板方块 会用 NEI 自己的绘制代码把这条配方渲染成一块平面贴图。

空白面板没有任何快照,onItemUse 直接返回 false,既不能贴也不能刻——它必须先由 NEI 配方界面的面板按钮刻印。

NBT 结构

物品根标签下有两个复合标签:

键 类型 说明
snapshot NBTTagCompound 配方快照,必需。缺失即为空白面板
cfg NBTTagCompound 显示设置,可选,空标签不会被写入

withData(snapshot, settings) 是唯一的服务端组装入口;withSnapshot(snapshot) 是它的 settings 为 null 的便捷重载。

静态读取方法

方法 作用
getSnapshot(stack) 取 snapshot 标签,无则 null
getSettings(stack) 取 cfg 标签,无则 null
getResult(stack) 解析出该配方当前的产物物品,用于 tooltip 与物品栏图标;空白面板返回 null

getResult 走 RecipeSnapshot.resolveDisplayResult,内部有一个 WeakHashMap 以 NBT 标签的对象身份为键缓存结果,避免悬停物品时每帧都做一次 NEI 查表。

使用方式

使用方式 触发条件 使用效果 条件/限制
右键点击方块 物品带 snapshot 在点击面的对面贴出 配方面板方块 并写入 NBT 需 snapshot 非空、玩家有编辑权限、点击面是实心、目标格是空气或可替换;创造模式不消耗

onItemUse 的完整判定顺序:

  1. getSnapshot(stack) == null → 返回 false(空白面板无法放置)
  2. dir = ForgeDirection.getOrientation(side),目标坐标 x + dir.offsetX 等
  3. player.canPlayerEdit(px, py, pz, side, stack) 与 world.isSideSolid(x, y, z, dir) 任一不满足 → false
  4. 目标格既不是空气也不可替换 → false
  5. 服务端 world.setBlock(px, py, pz, ModBlocks.recipePanel, side, 3),把 snapshot 与 settings 复制进 TileEntity
  6. 非创造模式 stack.stackSize--

显示名与提示

状态 显示名
空白(无 snapshot) item.recipePanel.name = Recipe Panel
已刻印 item.recipePanel.encoded.name = Encoded Recipe Blueprint

提示(addInformation):

  • 空白:深灰 tooltip.neirecipepanels.panel.blank = Blank - imprint it from an NEI recipe screen.
  • 已刻印:灰色 tooltip.neirecipepanels.panel.recipe = Recipe: %s,%s 填 getResult 的显示名;再追加深灰 tooltip.neirecipepanels.panel.hang = Right-click a wall to hang it.

合成配方

没有。ModItems.registerRecipes() 只注册了两条产出蓝图(Recipe Blueprint)的无序配方,没有任何配方产出本物品。它只能通过 刻印流程 从 NEI 配方界面获得。

相关条目