在我的世界游戲中,巧克力咖啡機(jī)是一種非常實(shí)用和有趣的裝置,可以為玩家提供美味的咖啡和巧克力。下面是一個(gè)簡單的巧克力咖啡機(jī)代碼:

1. 在地面上放置一個(gè)命令塊,并在其內(nèi)部鍵入以下命令:
/summon armor_stand ~ ~1 ~ {Invisible:1, NoGravity:1, Tags:["CoffeeMachine"], Small:1}
這個(gè)命令創(chuàng)建了一個(gè)隱形的、不受重力影響的裝甲架,其名稱為“CoffeeMachine”。
2. 然后,您需要放置幾個(gè)物品框(item frame)作為設(shè)備界面,添加咖啡豆和可可粉到它們里面作為原材料。鼠標(biāo)右鍵單擊每一個(gè)物品框,將其調(diào)整為適當(dāng)?shù)慕嵌群臀恢谩?/p>
3. 接下來,需要在命令塊內(nèi)編寫以下代碼,以創(chuàng)造一些提示文本并處理咖啡和巧克力的制作過程。
scoreboard objectives add Chocolate dummy Chocolate
scoreboard objectives add Coffee dummy Coffee
scoreboard objectives add Timer dummy Timer
scoreboard objectives setdisplay sidebar Chocolate
scoreboard objectives setdisplay sidebar Coffee
scoreboard objectives setdisplay sidebar Timer
scoreboard players set @a Coffee 0
scoreboard players set @a Chocolate 0
scoreboard players set @a Timer 0
scoreboard players set @e[type=armor_stand,tag=CoffeeMachine] Timer 0
execute as @a[scores={Coffee=1..}] run scoreboard players add @e[type=armor_stand,tag=CoffeeMachine] Coffee 1
execute as @a[scores={Chocolate=1..}] run scoreboard players add @e[type=armor_stand,tag=CoffeeMachine] Chocolate 1
execute as @e[type=armor_stand,tag=CoffeeMachine,scores={Coffee=2,Chocolate=2,Timer=0}] run scoreboard players set @e[type=armor_stand,tag=CoffeeMachine] Timer 60
execute as @e[type=armor_stand,tag=CoffeeMachine,scores={Timer=1..}] run playsound minecraft:block.anvil.land master @a ~ ~ ~ 10.0
execute as @e[type=armor_stand,tag=CoffeeMachine,scores={Timer=1..}] run scoreboard players remove @e[type=armor_stand,tag=CoffeeMachine] Timer 1
execute as @e[type=armor_stand,tag=CoffeeMachine,scores={Timer=1..}] run summon minecraft:item ~ ~ ~ {Item:{id:"minecraft:potion",Count:1b,tag:{HideFlags:32,CustomPotionEffects:[{Id:5b,Duration:600,Amplifier:0b}]}}}
execute as @e[type=armor_stand,tag=CoffeeMachine,scores={Timer=1..}] run scoreboard players remove @a Coffee 2
execute as @e[type=armor_stand,tag=CoffeeMachine,scores={Timer=1..}] run scoreboard players remove @a Chocolate 2
以上代碼使得玩家可以右鍵單擊物品框添加咖啡豆和可可粉,然后等待60個(gè)游戲刻度(大約3秒鐘)制作咖啡或巧克力。在這段時(shí)間內(nèi),玩家將聽到鐵砧落地的聲音,表示制作過程在進(jìn)行。一旦計(jì)時(shí)器到達(dá)60,咖啡或巧克力飲料將被生成并出現(xiàn)在咖啡機(jī)上。
這個(gè)代碼只是一個(gè)基本框架,您可以添加更多的功能和定制,使咖啡機(jī)更加有趣和實(shí)用。


























