1

I'm creating a PvP map in Minecraft and I'd like to track how many times a player has hit other players on a scoreboard. I'm not tracking kills; I'm tracking hits. How can I do this?

I'm not tracking the number of times player1 has hit player2, I'm tracking how many times player1 has hit anyone. Also, I'm only using projectiles. I am fine with using any projectile needed in order to track this.

  • Are there other mobs in the arena that you don't want hits on counted, or are there only players? – SirBenet Feb 21 '15 at 18:15
  • @colorfusion There are no other mobs. – FlyingPiMonster Feb 21 '15 at 18:19
  • You might be able to make something with stat.damageDealt statistic, but you need to test how it behaves if the players have different armor. – Kcats Feb 23 '15 at 14:04
1

Disclaimer: I did not test this, but precluding Minecraft weirdness/bugs, this method should work.

@Kcats was on a very good track regarding stat.damageDealt, but there is one more step to it than just looking at this.

First, set up some scoreboard objectives:

/scoreboard objectives add damageDealt stat.damageDealt
/scoreboard objectives add hits dummy

Now make a fast clock (setblock/fill clock works best) and run the following in order

/scoreboard players add @a[score_damageDealt_min=1] hits 1
/scoreboard players set @a damageDealt 0

By using a second objective, we can decouple hits from damage done. If a player has dealt any kind of damage to anything in the last clock period, it is counted as a hit.

Due to the way this is set up, there are some quirks however:

  • A hit that doesn't deal any damage due to armor or resistance effects or whatnot does not count.
  • If you set someone on fire, poison or wither someone, every tick of damage probably counts as a hit (here's where I'm unsure of the exact workings of the stat.damageDealt).
  • This would work, but I'm using projectiles, and according to this they don't work with stat.damageDealt. Good idea though, works with melee. – FlyingPiMonster May 29 '15 at 13:38
  • @kittycat3141 Interesting. My googling turned up with an older version of the bug that was marked as "fixed" in 1.7.X or so. Didn't notice that the bug is back. – MrLemon May 29 '15 at 13:55
0

Tracking projectile hits are very hard to track... as there is no tag for a projectile that hit a player / entity. I'm guessing the only way would be using wither skulls to detect whether an arrow is in a 1 block radius of a player

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.