How to protect a player from firework rocket explosion damage?

How to protect a player from firework rocket explosion damage? - Fireworks Display

I try to make a pvp server that players are able to attack each other by using a crossbow loaded with firework rocket.The problem is if the player fires his crossbow too close to themself, they will be damaged by the rocket due to explosion damage.

I tried to solve this issue by adding the players into a team that I have created and turn off friendly fire. It works nicely but it also prevents the players from attacking their enemies since they are in the same team.

Besides, another idea is to give the player resistance 255 for 1 second after they have fired the crossbow so even if the rocket explodes near them they will not be hurt. This is by far the best solution I can come out with. However, if the player spams this, they will always be immune to all kind of damage. As a result of that, their enemies totally cannot defeat him.

So, I wonder is there another way to protect the players from being damaged by the firework rocket that is fired by themself BUT they will still be able to hurt their enemies with the same rocket.

*the version that I am using is java edition 1.16.3



Best Answer

You can set the firework entity to be on the same team as the player who fired it. Make two kinds of fireworks (for example, one with a red explosion and one with blue). Have two command blocks (set to Repeating; Always Active) with the commands below.

For red:

/team join <team> @e[type=firework_rocket{Fireworks:{Explosions:[{Colors:[I;11743532]}]}}

For blue:

/team join <team> @e[type=firework_rocket{Fireworks:{Explosions:[{Colors:[I;2437522]}]}}

If you're using colors other than red and blue, please refer to this list of firework NBT colors to change the number. However, please make sure to keep the I; in front of the color's number in the string.

With FriendlyFire set to false for both teams, this will prevent the fireworks from damaging the team they came from.




Pictures about "How to protect a player from firework rocket explosion damage?"

How to protect a player from firework rocket explosion damage? - Colorful firework on dark sky
How to protect a player from firework rocket explosion damage? - Abstract of vibrant glowing fireworks exploding high in black sky late at night
How to protect a player from firework rocket explosion damage? - From below of comfortable astronauts chairs inside of modern spacecraft simulator located in modern station



How do you prevent damage from fireworks in Minecraft?

Try not to use explosive fireworks when using extra. Doing so,you won't take damage.

Do firework rockets deal damage?

At a maximum crafting recipe of seven firework stars, a firework rocket can deal a total of 19 damage (or seven and a half hearts).

Can you deal damage with fireworks in Minecraft?

Although fireworks with firework stars can be used, the player takes blast damage if they use it in flight.



How to Make a Rocket Launcher in Minecraft 1.19 | OP Firework Crossbow




More answers regarding how to protect a player from firework rocket explosion damage?

Answer 2

Make two teams and turn off friendly fire. Add p1 to team1 and p2 to team2. They can hurt each other, but not themselves.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Pixabay, Lucas Pezeta, Damir Mijailovic, SpaceX