3

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

5
  • 2
    Have you tried putting every player on a separate team and turning off friendly fire? – fasterthanlight Sep 20 '20 at 19:40
  • The thing is it is a server. I cannot make a whole bunch of teams everytime when there is a new player come to the server. – itsme Sep 21 '20 at 10:53
  • it sounds like players will be fighting in a 2 sided, walled of arena. (e.g terf wars.)? Or is it more of a free for all style match. – Name_Hr3 Sep 21 '20 at 23:15
  • Ye just like turf wars. Players will be fighting each other in a closed arena using crossbow or some other melee weapons. – itsme Sep 22 '20 at 8:06
  • I have a theory. I will test it out sometime soon. So know that your answer may be coming. – randomuser922 Nov 8 '20 at 22:02
1

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.