1

When a player kill a mob run a command

TijolitoGr's Avatar TijolitoGr7/22/21 6:51 pm
1 emeralds 2.8k 6
7/23/2021 7:20 pm
Panda Masala's Avatar Panda Masala
How i made to make a player when he kill a mob, spawn a firework in the exactaly position that the mob has been killed.
Posted by TijolitoGr's Avatar
TijolitoGr
Level 35 : Artisan Turtle
16

Create an account or sign in to comment.

6

Panda Masala
07/23/2021 7:20 pm
Level 34 : Artisan Bear
Panda Masala's Avatar
Dang, my bad- I made a big fat error. The moment the mob dies, it ceases to exist- therefore the "execute at @e[tag=dummy]" portion would fail, because no entity tagged "dummy" would exist after you kill it. Yea, I think the best option would be to go with the passenger idea.

I think maybe you could modify this concept though, to spawn firework rockets, seeing as though the person uses it to spawn lightning bolts and summon armor stand corpses.
2
HoboMaggot
07/22/2021 7:44 pm
Level 52 : Grandmaster Blob
HoboMaggot's Avatar
Detecting mob death as the mob is very limited as your cant directly execute on dead mobs.

You can detect if a mob dies from a player by making the killed mob have a passenger (such as a marker) before it is killed. When the player kills a mob, give them a custom player_killed_entity advancement and detect any of the passenger left behind when the mob is killed and execute a command on them
2
Panda Masala
07/22/2021 7:40 pm
Level 34 : Artisan Bear
Panda Masala's Avatar
I know a command that could detect whether an entity is dead. Not sure how I would make sure the player themselves does the killing though.

/execute unless @e[​tag=dummy] run execute at @e[​tag=dummy] run ___________

I'm not sure how to spawn a firework using commands, I'll get back to you if I figure it out. The command to summon a firework goes in the blank space I put.

Also- you can give your mob any tag you'd like, so long as you change the "dummy" tag to reflect what tag you give the mob. You will need to spawn the mob using a command generator, and fill in the tag section with the tag you choose. Think of it as like the mob's name, but one the players can't see.
2
HoboMaggot
07/23/2021 7:17 am
Level 52 : Grandmaster Blob
HoboMaggot's Avatar
What are you proposing the @e[​tag=dummy] equal to. Are they different entities?
2
Panda Masala
07/23/2021 7:02 pm
Level 34 : Artisan Bear
Panda Masala's Avatar
No, each and every entity with that tag would be affected by it. I assumed it would be an effect that would happen if you kill a special type of mob, which would mean giving those special mobs their own tag would be the most efficient way of doing it.

If it's just any generic mob, like, a cow for example, then it could easily be replaced with

@e[​type=cow]


All cows that get killed would then run the command.
2
Panda Masala
07/23/2021 7:12 pm
Level 34 : Artisan Bear
Panda Masala's Avatar
Oh whoops I made a syntax error. I'll be adjusting it when I post my next comment, I think I may have it working now.
2
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome