苹果需洗净吃

By MCSugar_cane    2018/06/02

本来想在六一做一个趣味性的小玩意,结果被拉出去玩了,所以就搁在了今天,希望能喜欢。

代码适用版本为1.11.2-1.12,逻辑支持1.8.x以上版本


我的世界苹果需洗净吃

图片就介绍到这里,下面是详情以及代码部分~


详情:

首先我们需要区分干净的苹果和不干净的苹果,这里可以考虑用检测手持,当玩家拿着干净的苹果并吃下时(useItem),则触发相应的命令。区分肯定就不能用给苹果改名了,否则玩家就能愉快的用铁砧洗苹果啦。这里我用的自定义物品NBT,如{ItemInfo:Nothing},那么用{ItemInfo:Nothing}或{tag:{ItemInfo:Nothing}}就能检测到该NBT。洗净前的苹果获取途径有很多,不好处理,就加在洗净后的上,当玩家手持的苹果有指定NBT则为干净的苹果,否则不干净。


代码:

基础部分:

  1. /give @p minecraft:spawn_egg 1 0 {EntityTag:{id:"minecraft:bat",CustomName:"CleanSetup",CustomNameVisible:false,Invulnerable:true,NoAI:true,Silent:true,CanPickUpLoot:false,ActiveEffects:[{Id:14,Duration:2147483640,Amplifier:255,ShowParticles:0b}]},display:{Name:"水槽安装",Lore:["对放置点右键即可"]}}
  2. /scoreboard objectives add appleClean dummy
  3. /scoreboard objectives add eatApple stat.useItem.minecraft.apple
  4. /scoreboard objectives add cleanRC stat.talkedToVillager

吃下处理:[高频循环]

  1. scoreboard players set @a appleClean 0 {SelectedItem:{id:"minecraft:apple",Damage:0s}}
  2. scoreboard players set @a appleClean 1 {SelectedItem:{id:"minecraft:apple",Damage:0s,tag:{Clean:true}}}
  3. tellraw @a[score_appleClean_min=0,score_appleClean=0,score_eatApple_min=1] ["\u00a77\u00a7l[提示] \u00a7c苹果需要洗干净才能吃哦,请拿着脏苹果对着\u00a7a\u00a7l洗槽\u00a7c右键。"]
  4. effect @a[score_appleClean_min=0,score_appleClean=0,score_eatApple_min=1] poison 10 0 true
  5. scoreboard players reset @a[score_eatApple_min=1] eatApple

水槽安装:[高频循环]

  1. execute @e[type=bat,name=CleanSetup] ~ ~ ~ setblock ~ ~ ~ minecraft:cauldron 3
  2. execute @e[type=bat,name=CleanSetup] ~ ~ ~ summon minecraft:villager ~ ~ ~ {CustomName:"dirtyClean",CustomNameVisible:false,Invulnerable:true,NoAI:true,Silent:true,NoGravity:true,CanPickUpLoot:false,PersistenceRequired:true,Profession:5,ActiveEffects:[{Id:14,Duration:2147483640,Amplifier:255,ShowParticles:0b}]}
  3. kill @e[type=bat,name=CleanSetup]

洗苹果处理:[高频循环]

  1. scoreboard players tag @a[tag=isApple] remove isApple
  2. scoreboard players tag @a add isApple {SelectedItem:{id:"minecraft:apple",Damage:0s}}
  3. execute @e[type=villager,name=dirtyClean] ~ ~ ~ clear @a[tag=isApple,score_cleanRC_min=1] apple 0 1
  4. execute @e[type=villager,name=dirtyClean] ~ ~ ~ give @a[tag=isApple,score_cleanRC_min=1] apple 1 0 {display:{Lore:["洗净的苹果"]},Clean:true}
  5. execute @a[tag=isApple,score_cleanRC_min=1] ~ ~ ~ execute @e[type=villager,name=dirtyClean,c=1] ~ ~ ~ particle happyVillager ~ ~0.5 ~ 0.3 0.2 0.3 0 20 force
  6. scoreboard players reset @a[score_cleanRC_min=1] cleanRC


OOC:

v1.11.2-v1.12.2
展开


欢迎加群交流划水:481528679