what_name

无序合成

最终效果:

教程图片

创建计分板

  1. /scoreboard objectives add CraftNeeds dummy 合成

名称: CraftNeeds

类型: dummy

显示名称: 合成

GIF中将5个皮革,1个铁锭丢到地上,合成了一个马鞍

所以要先检测有没有所需的物品

rcb(循环型命令方块)执行以下2条命令:

  1. /scoreboard players set @e[type=item] CraftNeeds 1 {Item:{id:"minecraft:leather",Count:5b,Damage:0s}}
  2. /scoreboard players set @e[type=item] CraftNeeds 2 {Item:{id:"minecraft:iron_ingot",Count:1b,Damage:0s}}

看上去有点长? 拆开慢慢看

第一条命令:

/scoreboard players set -- 这个就不用说了,有点计分板基础的都知道

@e[type=item] -- 所有实体中,类型是Item的实体,Item就是物品

CraftNeeds 1 -- 这个也是,有点计分板基础的都知道是什么意思

{Item:{id:"minecraft:leather",Count:5b,Damage:0s}}

蓝色:这个NBT是用来限制物品的

红色:物品必须是leather(皮革)

绿色:数量必须是5

紫色:数据必须是0(数据也叫数据值,损伤值,损害值,附加值

第二条命令:

/scoreboard players set @e[type=item] CraftNeeds 2 -- 这个部分和第一条命令的意思是一样的,只不过分数从1改为2

{Item:{id:"minecraft:iron_ingot",Count:1b,Damage:0s}}

蓝色:这个NBT是用来限制物品的

红色:物品必须是iron_ingot(铁锭)

绿色:数量必须是1

紫色:数据必须是0

上2条命令,起到的作用是给2种合成需要的物品一个编号,让之后的检测物品更加方便

然而这样就有一个问题,如果先丢一个铁锭,然后再丢一个,2个铁锭依旧可以合成(皮革也一样)

所以要在高频执行上方指令之前,高频执行:

  1. /scoreboard players reset @e[type=item,score_CraftNeeds_min=1] CraftNeeds

接下来是检测物品是否重叠,如果是,就清除材料,并且生成成品,如果不是,就什么也不做。

rcb(循环型命令方块)执行:

  1. execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /summon item ~ ~3 ~ {Item:{id:"minecraft:saddle",Count:1b,Damage:0s}}
  2. execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /particle fireworksSpark ~ ~2 ~ 0.2 0 0.2 0 50 force
  3. execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /kill @e[type=item,r=1]

看上去又长又复杂?拆开看看:

第一条命令:

execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ -- 检测是否有CraftNeeds分数=1的物品存在,如果有就执行后面的命令

execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ -- 检测周围1格内是否有CraftNeeds分数=2的物品存在,如果有,就执行后面的命令

/summon item ~ ~3 ~ {Item:{id:"minecraft:saddle",Count:1b,Damage:0s}} -- 在CraftNeeds分数=2的物品上方3格,生成一个物品,物品是saddle(鞍),数量为1,数据为0

第二条命令:

execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~

-- 与第一条命令的前面意义相同(难道你没发现都一模一样吗= =)

/particle fireworksSpark ~ ~2 ~ 0.2 0 0.2 0 50 force -- 在CraftNeeds分数=2的物品上方2格,播放粒子效果,粒子数量50,类型fireworksSpark

第三条命令:

execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~

-- 与第一条命令的前面意义相同(难道你还没发现都一模一样?!)

/kill @e[type=Item,r=1] -- 清除以CraftNeeds分数=2的物品为中心,周围1格的所有物品

OOC

展开/收起

1.11~1.11.2

  1. summon falling_block ~ ~1 ~ {Block:stone,Time:1,Passengers:[{id:falling_block,Block:redstone_block,Time:1,Passengers:[{id:falling_block,Block:activator_rail,Time:1,Passengers:[{id:commandblock_minecart,Command:"gamerule commandBlockOutput false"},{id:commandblock_minecart,Command:"/scoreboard objectives add CraftNeeds dummy 合成"},{id:commandblock_minecart,Command:"fill ~3 ~-2 ~ ~7 ~-2 ~1 chain_command_block 5"},{id:commandblock_minecart,Command:"setblock ~7 ~-2 ~1 chain_command_block 4"},{id:commandblock_minecart,Command:"setblock ~7 ~-2 ~ chain_command_block 3"},{id:commandblock_minecart,Command:"setblock ~3 ~-2 ~ repeating_command_block 5"},{id:commandblock_minecart,Command:"blockdata ~7 ~-2 ~1 {auto:1,Command:"execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /kill @e[type=item,r=1]"}"},{id:commandblock_minecart,Command:"blockdata ~7 ~-2 ~ {auto:1,Command:"execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /particle fireworksSpark ~ ~2 ~ 0.2 0 0.2 0 50 force"}"},{id:commandblock_minecart,Command:"blockdata ~6 ~-2 ~ {auto:1,Command:"execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /summon item ~ ~3 ~ {Item:{id:\\"minecraft:saddle\\",Count:1b,Damage:0s}}"}"},{id:commandblock_minecart,Command:"blockdata ~5 ~-2 ~ {auto:1,Command:"/scoreboard players set @e[type=item] CraftNeeds 2 {Item:{id:\\"minecraft:iron_ingot\\",Count:1b,Damage:0s}}"}"},{id:commandblock_minecart,Command:"blockdata ~4 ~-2 ~ {auto:1,Command:"/scoreboard players set @e[type=item] CraftNeeds 1 {Item:{id:\\"minecraft:leather\\",Count:5b,Damage:0s}}"}"},{id:commandblock_minecart,Command:"blockdata ~3 ~-2 ~ {auto:1,Command:"/scoreboard players reset @e[type=item,score_CraftNeeds_min=1] CraftNeeds"}"},{id:commandblock_minecart,Command:"setblock ~ ~ ~1 command_block 0 0 {Command:"fill ~ ~-3 ~-1 ~ ~ ~ air"}"},{id:commandblock_minecart,Command:"setblock ~ ~-1 ~1 redstone_block"},{id:commandblock_minecart,Command:"kill @e[type=commandblock_minecart,r=1]"}]}]}]}

1.12~1.12.2

  1. summon falling_block ~ ~1 ~ {Block:stone,Time:1,Passengers:[{id:falling_block,Block:redstone_block,Time:1,Passengers:[{id:falling_block,Block:activator_rail,Time:1,Passengers:[{id:commandblock_minecart,Command:"gamerule commandBlockOutput false"},{id:commandblock_minecart,Command:"/scoreboard objectives add CraftNeeds dummy 合成"},{id:commandblock_minecart,Command:"fill ~3 ~-2 ~ ~7 ~-2 ~1 chain_command_block 5"},{id:commandblock_minecart,Command:"setblock ~7 ~-2 ~1 chain_command_block 4"},{id:commandblock_minecart,Command:"setblock ~7 ~-2 ~ chain_command_block 3"},{id:commandblock_minecart,Command:"setblock ~3 ~-2 ~ repeating_command_block 5"},{id:commandblock_minecart,Command:"blockdata ~7 ~-2 ~1 {auto:1,Command:"execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /kill @e[type=item,r=1]"}"},{id:commandblock_minecart,Command:"blockdata ~7 ~-2 ~ {auto:1,Command:"execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /particle fireworksSpark ~ ~2 ~ 0.2 0 0.2 0 50 force"}"},{id:commandblock_minecart,Command:"blockdata ~6 ~-2 ~ {auto:1,Command:"execute @e[type=item,score_CraftNeeds_min=1,score_CraftNeeds=1] ~ ~ ~ execute @e[type=item,r=1,score_CraftNeeds_min=2,score_CraftNeeds=2] ~ ~ ~ /summon item ~ ~3 ~ {Item:{id:\\"minecraft:saddle\\",Count:1b,Damage:0s}}"}"},{id:commandblock_minecart,Command:"blockdata ~5 ~-2 ~ {auto:1,Command:"/scoreboard players set @e[type=item] CraftNeeds 2 {Item:{id:\\"minecraft:iron_ingot\\",Count:1b,Damage:0s}}"}"},{id:commandblock_minecart,Command:"blockdata ~4 ~-2 ~ {auto:1,Command:"/scoreboard players set @e[type=item] CraftNeeds 1 {Item:{id:\\"minecraft:leather\\",Count:5b,Damage:0s}}"}"},{id:commandblock_minecart,Command:"blockdata ~3 ~-2 ~ {auto:1,Command:"/scoreboard players reset @e[type=item,score_CraftNeeds_min=1] CraftNeeds"}"},{id:commandblock_minecart,Command:"setblock ~ ~ ~1 command_block 0 0 {Command:"fill ~ ~-3 ~-1 ~ ~ ~ air"}"},{id:commandblock_minecart,Command:"setblock ~ ~-1 ~1 redstone_block"},{id:commandblock_minecart,Command:"kill @e[type=commandblock_minecart,r=1]"}]}]}]}
  • what_name2018-04-12

                        

Copyright © what_name