僵尸出生动画及破坏方块

By MCSugar_cane    2017/10/20

在我的世界僵尸自然生成的基础上,当玩家靠近僵尸自然生成点时,僵尸才出没并执行动画,并且僵尸可以破坏方块,加强了游戏难度以及观赏性,代码适用版本为1.11.2

僵尸出生动画&方块破坏演示地图


僵尸出生动画动态图

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


整体思路:

先说僵尸生成动画,其实这就是将新生成的僵尸传送到地表下,为了防止僵尸窒息这里我在僵尸地表下位置的方块处替换为了空气。当玩家附近存在在地表下的僵尸时,便使僵尸上升直到其处在地表上。

僵尸破坏方块就比较简单了,只需要一个计时和纵向的检测即可。为了降低难度,如果僵尸在破坏方块(计时增长)的过程中受到伤害,则该僵尸需重新破坏方块(计时)。

顺带一提,如果要使僵尸可以更加灵活,可以使其可以搭建方块以触及在上方的玩家。只需要延迟定时执行:如果玩家下方有僵尸,便将僵尸升高一定距离时在僵尸处放置一个方块。具体代码见文章结尾处。


僵尸出生动画:

创建变量:

  1. /scoreboard objectives add ZombieBorn dummy

高频部分:

  1. /scoreboard players add @e[type=Zombie] ZombieBorn 0
  2. /entitydata @e[type=Zombie,score_ZombieBorn_min=0,score_ZombieBorn=0] {NoAI:1,Silent:1,Invulnerable:1}
  3. /tp @e[type=Zombie,score_ZombieBorn_min=0,score_ZombieBorn=0] ~ ~-3 ~
  4. /scoreboard players set @e[type=Zombie,score_ZombieBorn_min=0,score_ZombieBorn=0] ZombieBorn 1
  5. /execute @a ~ ~ ~ scoreboard players set @e[type=Zombie,score_ZombieBorn_min=1,score_ZombieBorn=1,r=7] ZombieBorn 2
  6. /tp @e[type=Zombie,score_ZombieBorn_min=2,score_ZombieBorn=2] ~ ~0.4 ~
  7. /entitydata @e[type=Zombie,score_ZombieBorn_min=-1,score_ZombieBorn=-1] {NoAI:0,Silent:0,Invulnerable:0}
  8. /execute @e[type=Zombie,score_ZombieBorn_min=2,score_ZombieBorn=2] ~ ~ ~ /particle blockcrack ~ ~.5 ~ 0.3 0.2 0.3 0 4 normal @a 2
  9. /execute @e[type=Zombie,score_ZombieBorn_min=2,score_ZombieBorn=2] ~ ~ ~ detect ~ ~ ~ minecraft:air 0 /scoreboard players set @e[type=Zombie,r=0,c=1] ZombieBorn -1

僵尸出生动画OOC:

v1.11.2
  1. /summon falling_block ~ ~1.5 ~ {Time:1,Block:minecraft:redstone_block,Motion:[0d,-1d,0d],Passengers:[{id:falling_block,Time:1,Block:minecraft:activator_rail,Passengers:[{id:commandblock_minecart,Command:blockdata ~ ~-2 ~ {auto:0b,Command:""}},{id:commandblock_minecart,Command:setblock ~11 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[type=Zombie,score_ZombieBorn_min=2,score_ZombieBorn=2] ~ ~ ~ detect ~ ~ ~ minecraft:air 0 /scoreboard players set @e[type=Zombie,r=0,c=1] ZombieBorn -1",auto:1b}},{id:commandblock_minecart,Command:setblock ~10 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @e[type=Zombie,score_ZombieBorn_min=2,score_ZombieBorn=2] ~ ~ ~ /particle blockcrack ~ ~.5 ~ 0.3 0.2 0.3 0 4 normal @a 2",auto:1b}},{id:commandblock_minecart,Command:setblock ~9 ~-2 ~0 chain_command_block 5 replace {Command:"/entitydata @e[type=Zombie,score_ZombieBorn_min=-1,score_ZombieBorn=-1] {NoAI:0,Silent:0,Invulnerable:0}",auto:1b}},{id:commandblock_minecart,Command:setblock ~8 ~-2 ~0 chain_command_block 5 replace {Command:"/tp @e[type=Zombie,score_ZombieBorn_min=2,score_ZombieBorn=2] ~ ~0.4 ~",auto:1b}},{id:commandblock_minecart,Command:setblock ~7 ~-2 ~0 chain_command_block 5 replace {Command:"/execute @a ~ ~ ~ scoreboard players set @e[type=Zombie,score_ZombieBorn_min=1,score_ZombieBorn=1,r=7] ZombieBorn 2",auto:1b}},{id:commandblock_minecart,Command:setblock ~6 ~-2 ~0 chain_command_block 5 replace {Command:"/scoreboard players set @e[type=Zombie,score_ZombieBorn_min=0,score_ZombieBorn=0] ZombieBorn 1",auto:1b}},{id:commandblock_minecart,Command:setblock ~5 ~-2 ~0 chain_command_block 5 replace {Command:"/tp @e[type=Zombie,score_ZombieBorn_min=0,score_ZombieBorn=0] ~ ~-3 ~",auto:1b}},{id:commandblock_minecart,Command:setblock ~4 ~-2 ~0 chain_command_block 5 replace {Command:"/entitydata @e[type=Zombie,score_ZombieBorn_min=0,score_ZombieBorn=0] {NoAI:1,Silent:1,Invulnerable:1}",auto:1b}},{id:commandblock_minecart,Command:setblock ~2 ~-2 ~0 command_block 5 replace {auto:1b,Command:/scoreboard objectives add ZombieBorn dummy}},{id:commandblock_minecart,Command:setblock ~3 ~-2 ~0 repeating_command_block 5 replace {Command:"/scoreboard players add @e[type=Zombie] ZombieBorn 0",auto:1b}},{id:commandblock_minecart,Command:setblock ~ ~1 ~ command_block 0 replace {auto:1b,Command:fill ~ ~ ~ ~ ~-2 ~ air}},{id:commandblock_minecart,Command:kill @e[type=commandblock_minecart,r=1]}]}]}

僵尸破坏方块:

创建变量:

  1. /scoreboard objectives add BrokeTimer dummy
  2. /scoreboard objectives add ZHurt dummy

基础高频:

  1. /execute @a ~ ~ ~ scoreboard players add @e[type=Zombie,r=8] ZHurt 1 {HurtTime:10s}
  2. /scoreboard players reset @e[type=Zombie,score_ZHurt_min=1] BrokeTimer
  3. /scoreboard players set @e[type=Zombie,score_ZHurt_min=1] ZHurt 0
  4. /execute @a[m=0] ~ ~ ~ scoreboard players add @e[type=Zombie,r=10] BrokeTimer 1
  5. /scoreboard players set @e[type=Zombie,score_BrokeTimer_min=201] BrokeTimer 50

脚下方块破坏:

  1. /execute @a[m=0] ~ ~2 ~ execute @e[type=Zombie,score_BrokeTimer_min=200,r=1] ~ ~ ~ setblock ~ ~-1 ~ air 0 destory
  2. /execute @a[m=0] ~ ~3 ~ execute @e[type=Zombie,score_BrokeTimer_min=200,r=1] ~ ~ ~ setblock ~ ~-1 ~ air 0 destory
  3. /execute @a[m=0] ~ ~4 ~ execute @e[type=Zombie,score_BrokeTimer_min=200,r=1] ~ ~ ~ setblock ~ ~-1 ~ air 0 destory

四周方块破坏:

  1. /execute @e[score_BrokeTimer_min=200,type=Zombie] ~ ~ ~ fill ~-0.25 ~ ~-0.25 ~0.25 ~2 ~0.25 air 0 destroy

僵尸搭建方块:

按照下列代码类举即可。

  1. execute @a[m=0] ~ ~-3 ~ entitydata @e[type=Zombie,r=1] {Motion:[0.0,0.4,0.0]}
  2. execute @a[m=0] ~ ~-3 ~ execute @e[type=Zombie,r=1] ~ ~ ~ setblock ~ ~ ~ dirt
  3. execute @a[m=0] ~ ~-4 ~ entitydata @e[type=Zombie,r=1] {Motion:[0.0,0.4,0.0]}
  4. execute @a[m=0] ~ ~-4 ~ execute @e[type=Zombie,r=1] ~ ~ ~ setblock ~ ~ ~ dirt
  5. ...


欢迎加群交流划水:481528679