配方蓝图

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

基本信息

属性 值
注册名 neirecipepanels:recipe_blueprint
物品类 ItemRecipeBlueprint(继承 Item)
最大堆叠 64
创造标签 tabMisc
贴图 neirecipepanels:recipe_blueprint
附魔适用 否(未覆写 getItemEnchantability(),基类 enchantability 为 0)
耐久度 无

功能

一次性的刻印消耗品:在 NEI 配方界面上点面板按钮刻一条配方进 配方面板物品 时扣掉一个。

本物品没有任何使用逻辑:类里只覆写了构造器与 addInformation,没有 onItemUse、onItemUseFirst、onRightClick 之类。扣除动作完全发生在服务端 MakeRecipePanelMessage.Handler.consumeBlueprint 里。

提示文字

addInformation 追加两行灰色(EnumChatFormatting.GRAY)文本:

键 文本
tooltip.neirecipepanels.blueprint.1 Open a recipe in NEI Recipe Panels
tooltip.neirecipepanels.blueprint.2 and click the Panel button to imprint it.

合成配方

ModItems.registerRecipes() 在 Config.registerBlueprintRecipe 为 true 时注册两条无序合成(X = 任意):

产出 材料 数量 备注
1 × 配方蓝图 纸 + 纸 + 红石 各 1 Items.paper, Items.paper, Items.redstone
1 × 配方蓝图 配方面板 1 任意 NBT 都行

第二条是关键:Minecraft 的无序合成匹配忽略 NBT,所以把刻好配方的面板丢回合成栏会还原成空白蓝图,实现面板的回收再利用。

把 recipe.registerBlueprintRecipe 设为 false 可以关掉这两条配方,方便整合包用脚本(tweaker)自己定义。

消耗规则

服务端的扣除逻辑(MakeRecipePanelMessage.Handler.grant):

  • spend = !creative || Config.consumeInCreative
  • spend 为真时才检查并扣除,顺序是:先 player.inventory.consumeInventoryItem(recipeBlueprint),失败再看光标上(inventory.getItemStack())是否是蓝图,是就减一
  • 两者都没有则回一条 neirecipepanels.chat.needBlueprint = You need a Recipe Blueprint to do that.

因此默认配置(consumeInCreative = false)下,创造模式玩家刻印完全不消耗蓝图;生存模式一定会扣,扣不到就提示。

相关条目

  • 配方面板物品 - 本物品刻出来的东西,也是本物品的回收来源
  • 配置文件 - recipe.registerBlueprintRecipe 与 server.consumeInCreative
  • 刻印流程 - 扣除蓝图、发放面板的完整服务端流程