Minecraft – How to create an “impact grenade” in Minecraft 1.13

minecraft-commandsminecraft-java-edition

I am trying to make an "impact grenade" command in Minecraft 1.13. I am trying to get it to work so that when an egg hits blocks or entities, a creeper will be summoned. I originally used the following command set up in 1.12 and tried to update it to current, 1.13:

Always active, repeat: /execute at @e[type=egg] run kill
@e[tag=tracker,distance=2]

Chain unconditional: /execute at @e[tag=tracker] run summon creeper ~
~ ~ {Silent:1b,Invulnerable:1b,CustomNameVisible:0b,Fuse:1,ignited:1b}

Chain unconditional: /kill @e[tag=tracker]

Chain unconditional: /execute at @e[type=egg] run summon
area_effect_cloud ~ ~ ~
{Particle:"ambient_entity_effect",Duration:2,Tags:["tracker"]}

Instead, all that happens is the creepers are summoned constantly at the egg. Any help on this subject would be great!

Best Answer

You're in luck, because I have a function that does exactly this. I'll explain what it does then give you the commands. I'm not sure eggs are a good idea, though, because there is a chance a baby chicken could spawn.

First, a scoreboard objective is created that tracks players who have thrown eggs. Players who have thrown an egg and have held an egg (determined by tag commands at the end of the function) summons an armor stand at the closest egg without a certain tag, then tags the egg so it doesn't happen again. The armor stand is constantly teleported to the closest egg, but when it does not detect a nearby egg then it is tagged. You can then execute all armor stands who have that tag to summon creepers or whatever you want to happen, then kill the armor stand.

This is the function. I converted it into 1.13 because it was originally in 1.12, and I changed it from snowballs to eggs (named "Grenade"). Because of lack of time I haven't tested it, but I see no reason why it shouldn't work. If it doesn't work, just let me know.

scoreboard objectives add grenade minecraft.used:minecraft.egg
execute as @a[scores={grenade=1..},tag=grenade] at @e[sort=nearest,limit=1,type=egg,tag=!grenade] run summon armor_stand ~ ~ ~ {Small:1b,NoGravity:1b,CustomName:"\"grenade\"",Marker:1b,Invisible:1b}
execute as @e[type=egg,tag=grenade] at @s run tp @e[type=armor_stand,name=grenade,limit=1,sort=nearest,distance=..2] @s
tag @e[type=armor_stand,name=grenade] add boom
execute as @e[type=egg,tag=grenade] at @s run tag @e[type=armor_stand,name=grenade,limit=1,sort=nearest] remove boom
execute as @e[type=armor_stand,tag=boom] at @s run summon creeper ~ ~ ~ {Fuse:0.0b,CustomName:"\"a grenade\""}
kill @e[type=armor_stand,tag=boom]
scoreboard players reset @a grenade
tag @a remove grenade
tag @a[nbt={SelectedItem:{id:"minecraft:egg",tag:{display:{Name:"\"Grenade\""}}}}] add grenade