First create a clock with the following commands:
execute @e[name=TPSlimeBack] ~ ~ ~ tp @e[type=Slime,name=SlimeKnock,rm=1,r=2] @e[type=ArmorStand,c=1,name=TPSlimeBack,r=2]
And:
execute @e[name=TPSlimeBack] ~ ~ ~ /effect @a[r=2] minecraft:resistance 1 100
Then summon an invisible ArmorStand
and an invisible Slime
with a size of 1
on the block where you want it to knock the player back by doing:
/summon ArmorStand ~ ~ ~ {CustomName:TPSlimeBack}
And then on the same position:
/summon Slime ~ ~ ~ {CustomName:SlimeKnock,Size:1}
This will make a Slime that knocks the players back, but that can't move out of the block's radius because it teleports back to the armour stand all the time. The player also get's a resistance effect to make sure no one loses their lives.
Edit
A much easier way to do this is just to summon a Slime on the block with the Size
of 2
and NoAI
added. Do this by running the following command:
/summon Slime ~ ~ ~ {CustomName:SlimeKnock,Size:2,NoAI:1}
(Note: The custom name isn't really needed, just to kill the slime when you want to remove it.)
Best Answer
You've got the right idea, but
minecraft:zombie_head
doesn't exist as a distinct item. It's just calledminecraft:skull
with a damage value of 2.So the correct command becomes the following: