我的世界【1.8】使用合成器接口进行原版模组开发
本模组包括五个数据包:
-
合成器(crafting_machine)
-
更多的合成(craftingpp)
-
更多的交易(tradepp)
-
更多实用功能(utilitypp)
-
空域开端(block_sky_domain)
其中“合成器”是“更多的合成”部分的前置,其中的机器设定和合成均在“合成器”数据包中。
开发者只需要将自己的数据包中,需要执行的合成判定添加至函数标签cm:craft即可。合成器实际上采用的是检测所在位置箱子的槽位物品并输出。检测合成的槽位为1,2,3,10,11,12,19,20,21,输出为16。开发者可以参考craftingppdatacppfunctionscrafttype文件进行检测,里面包括了如何检测有序和无序合成等内容,例如:
execute store result score @s cppValue run data get block ~ ~ ~ Items# 十字形execute as @s[scores={cppValue=23}] if block ~ ~ ~ chest{Items:[{Slot:2b},{Slot:10b},{Slot:11b},{Slot:12b},{Slot:20b}]} run function cpp:craft/cross# 无序合成execute as @s[scores={cppValue=27}] run function cpp:craft/shapeless9execute as @s[scores={cppValue=23}] run function cpp:craft/shapeless5execute as @s[scores={cppValue=22}] run function cpp:craft/shapeless4execute as @s[scores={cppValue=21}] run function cpp:craft/shapeless3execute as @s[scores={cppValue=20}] run function cpp:craft/shapeless2
之后,探测完毕输出时,可参考:
replaceitem block ~ ~ ~ container.16 minecraft:stone_sword{display:{Name:"{"translate":"item.cpp.black_hat"}"},id:"cpp:black_hat",Unbreakable:1b,Damage:90,HideFlags:63,AttributeModifiers:[{Operation:0,Amount:0,AttributeName:"generic.attackDamage",Name:"mainhand_attackDamage",UUIDLeast:10,UUIDMost:520,Slot:"mainhand"},{Operation:0,Amount:0,AttributeName:"generic.attackSpeed",Name:"mainhand_attackSpeed",UUIDLeast:11,UUIDMost:520,Slot:"mainhand"}]}execute unless block ~ ~ ~ chest{Items:[{Slot:1b}]} run replaceitem block ~ ~ ~ container.1 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:2b}]} run replaceitem block ~ ~ ~ container.2 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:3b}]} run replaceitem block ~ ~ ~ container.3 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:10b}]} run replaceitem block ~ ~ ~ container.10 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:11b}]} run replaceitem block ~ ~ ~ container.11 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:12b}]} run replaceitem block ~ ~ ~ container.12 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:19b}]} run replaceitem block ~ ~ ~ container.19 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:20b}]} run replaceitem block ~ ~ ~ container.20 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute unless block ~ ~ ~ chest{Items:[{Slot:21b}]} run replaceitem block ~ ~ ~ container.21 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}execute store result score #temp cppValue run data get block ~ ~ ~ Items[21].Countexecute store result block ~ ~ ~ Items[21].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[20].Countexecute store result block ~ ~ ~ Items[20].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[19].Countexecute store result block ~ ~ ~ Items[19].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[12].Countexecute store result block ~ ~ ~ Items[12].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[11].Countexecute store result block ~ ~ ~ Items[11].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[10].Countexecute store result block ~ ~ ~ Items[10].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[3].Countexecute store result block ~ ~ ~ Items[3].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[2].Countexecute store result block ~ ~ ~ Items[2].Count byte 1 run scoreboard players remove #temp cppValue 1execute store result score #temp cppValue run data get block ~ ~ ~ Items[1].Countexecute store result block ~ ~ ~ Items[1].Count byte 1 run scoreboard players remove #temp cppValue
此法,来进行材料-1。
标记机器的盔甲架,若添加有标签cm_machine,则可采用和合成器相同的背景清除函数。这包括使用漏斗吸取,玩家背包,漏斗矿车吸取,地面掉落这些情形的背景板清理。但这无法避免模组管道抽取。清理的物品标签为isMachineBg:1b。
合成器的透明背景板为 minecraft:wooden_hoe{isMachineBg:1b,HideFlags:63,Unbreakable:1b,Damage:59}
如要添加自定义机器,建议左上第一格为机器GUI,其余背景采用上述物品。