Detect when player attacks another playerHow to detect if a mob has been hit in minecraft with command...
Jumping Numbers
Avoiding morning and evening handshakes
Can you earn endless XP using a Flameskull and its self-revival feature?
It took me a lot of time to make this, pls like. (YouTube Comments #1)
Solubility of a tribasic weak acid
How to deal with an incendiary email that was recalled
Would these multi-classing house rules cause unintended problems?
How to avoid being sexist when trying to employ someone to function in a very sexist environment?
Is there a standard way to treat events with unknown times (missing time data)?
Are there neural networks with very few nodes that decently solve non-trivial problems?
Guns against regular people
Why did other German political parties disband so fast when Hitler was appointed chancellor?
Do authors have to be politically correct in article-writing?
Slow moving projectiles from a hand-held weapon - how do they reach the target?
What was the earliest start time of a Catholic mass before 1957?
How do I say "Brexit" in Latin?
Why Normality assumption in linear regression
Why does lambda auto& parameter choose const overload?
What to do when being responsible for data protection in your lab, yet advice is ignored?
Pre-1980's science fiction short story: alien disguised as a woman shot by a gangster, has tentacles coming out of her breasts when remaking her body
How can animals be objects of ethics without being subjects as well?
Is there any differences between "Gucken" and "Schauen"?
Why zero tolerance on nudity in space?
Compress command output by piping to bzip2
Detect when player attacks another player
How to detect if a mob has been hit in minecraft with command blocks?How can I apply an effect when a player left-clicks/right-clicks with an item in hand?Keeping inventory conditionallyDetect *where* a specific player died?How can I detect if a player has a specific item with a specific datavalue in their inventory?I'm trying to /testfor a player on a blockDetect which player ignites the TNT using flint and steelVanilla Minecraft - Detect various /trigger outputsWhat's wrong with my command? “The entity UUID provided is in an invalid format”Kill skeleton horses with command block in a radiusMinecraft– How to detect for player with custom headMinecraft 1.12 reliably detect player-player interactionDetect when a player respawns, Possible?
I would like to detect when a player attacks/hits/hurts another player or entity. I have tried to use the AttackTime
tag, but it doesn't work. Here is what I have tried (on a 20HZ clock):
First command block:
scoreboard players set @a Attack 0 {AttackTime:0s}
Second command block:
scoreboard players set @a Attack 1 {AttackTime:1s}
Third command block:
tellraw @a[score_Attack_min=1] "Nice shot!"
minecraft minecraft-commands
add a comment |
I would like to detect when a player attacks/hits/hurts another player or entity. I have tried to use the AttackTime
tag, but it doesn't work. Here is what I have tried (on a 20HZ clock):
First command block:
scoreboard players set @a Attack 0 {AttackTime:0s}
Second command block:
scoreboard players set @a Attack 1 {AttackTime:1s}
Third command block:
tellraw @a[score_Attack_min=1] "Nice shot!"
minecraft minecraft-commands
add a comment |
I would like to detect when a player attacks/hits/hurts another player or entity. I have tried to use the AttackTime
tag, but it doesn't work. Here is what I have tried (on a 20HZ clock):
First command block:
scoreboard players set @a Attack 0 {AttackTime:0s}
Second command block:
scoreboard players set @a Attack 1 {AttackTime:1s}
Third command block:
tellraw @a[score_Attack_min=1] "Nice shot!"
minecraft minecraft-commands
I would like to detect when a player attacks/hits/hurts another player or entity. I have tried to use the AttackTime
tag, but it doesn't work. Here is what I have tried (on a 20HZ clock):
First command block:
scoreboard players set @a Attack 0 {AttackTime:0s}
Second command block:
scoreboard players set @a Attack 1 {AttackTime:1s}
Third command block:
tellraw @a[score_Attack_min=1] "Nice shot!"
minecraft minecraft-commands
minecraft minecraft-commands
asked Jul 6 '15 at 9:54
Jacques MaraisJacques Marais
1,486524
1,486524
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
I figured out how to do this. I use the stat.damageDealt
scoreboard objective. First I run the following command once:
/scoreboard objectives add hit stat.damageDealt
Then on the 20Hz clock I do the following:
First command block:
/tellraw @a[score_hit_min=1] "Nice Hit!"
Second command block:
/scoreboard players reset @a[score_hit_min=1] hit
How this works is that points is added to the stat.damageDealt
objective each time they hit/attack/hurt an entity or player. Then it runs the command on every player that has hurt another entity or player. When that command is done, the objective gets reset.
How I found this is that on the statistics menu from the pause menu, there is a statistic called Damage Dealt.
EDIT:
In Minecraft 1.9, use the repeating command block instead of a 20Hz clock.
I've been working on a different solution, which is much more complicated. I feel stupid now.
– MrLemon
Jul 6 '15 at 11:41
2
@MrLemon Oh, well you can post it, maybe it will be helpful to some players.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon That is if it is done.
– Jacques Marais
Jul 6 '15 at 11:42
I ended up using something I found out while fiddling around with my solution (which was just awful to be hones) to upgrade your solution.
– MrLemon
Jul 6 '15 at 12:12
I'm a little surprised thatstat.damageDealt
isn't further subdivided into the various mobs and players.
– MBraedley
Jul 6 '15 at 21:07
add a comment |
This answer is based on @CommandFox's answer and my own (totally awful) idea for a solution. However, I found that combination of the two adds a possible limitation to hurting specific entities.
First, create two scoreboard objectives: didDamage
and hurtTime
scoreboard objectives add didDamage stat.damageDealt
scoreboard objectives add hurtTime dummy
Then, create a fill clock and run the following commands:
scoreboard players add @e hurtTime 1
scoreboard players set @e hurtTime 0 {HurtTime:0s}
execute @e[score_hurtTime_min=1,score_hurtTime=1] ~ ~ ~ tellraw @a[score_didDamage=1] "Nice hit!"
scoreboard player set @a didDamage 0
So far, we have gained nothing by using the hurtTime
objective. The main benefit of it is that it can be limited using its target selector. For example, using
scoreboard players add @e[type=Zombie] hurtTime 1
scoreboard players set @e[type=Zombie] hurtTime 0 {HurtTime:0s}
makes it so that the message only appears when you actually hit a zombie. Using multiples of this command block pair makes it possible to select multiple entities.
This solution is great for when you want to limit the mobs or players that the player may hit. Thank you.
– Jacques Marais
Jul 6 '15 at 12:20
@CommandFox I'm just glad I was able to salvage something useful from my attempt after all. For players, you could also usestat.damageTaken
instead, butstat
-objectives do not work for other entities.
– MrLemon
Jul 6 '15 at 12:26
Incidentally, I found out that after hitting a mob, it is invincible (glowing red) for exactly 10 ticks (1/2 sec).
– MrLemon
Jul 6 '15 at 12:27
Yes, thank you for your help. I have a use for this on one of my command block minigames.
– Jacques Marais
Jul 6 '15 at 12:27
Wow, I didn't even know that. Thanks :D
– Jacques Marais
Jul 6 '15 at 12:31
add a comment |
žN !> _*
~local_player¡(
AgentIDæ úÿÿÿ Air, Armor
Count Damage Name Count Damage Name Count Damage Name Count Damage Name
AttackTime
Attributes
Base A Current ˜A Max A Name minecraft:health Base Current Max €D Name minecraft:luck Base Current Max €@ Name minecraft:player.exhaustion BaseÍÌÌ= CurrentÍÌÌ= Maxÿÿ Name minecraft:movement Base Current Max €A Name minecraft:absorption Base Current Max €? Name minecraft:knockback_resistance Base
×£< Current
×£< Maxÿÿ Name minecraft:underwater_movement Base €? Current €? Maxÿÿ Name minecraft:fall_damage Base €A Current €A Max E Name minecraft:follow_range Base €? Current €? Max €? Name minecraft:attack_damage Base A Current A Max A Name minecraft:player.hunger Base A Current ˜A Max A Name minecraft:player.saturation Base @@ Current @@ Max ®ÁF Name minecraft:player.level BaseÌNl> CurrentÌNl> Max €? Name minecraft:player.experience BedPositionX BedPositionY BedPositionZ Chested Color Color2
CursorSelectedItem Count Damage Name DeathTime DimensionId EnchantmentSeedñ=j EnderChestInventory
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot FallDistance Fire HurtTime Inventory
$ Count Damage Name minecraft:diamond_sword Slot Count Damage Name minecraft:arrow Slot Count Damage Name minecraft:bone Slot Count Damage] Name
minecraft:bow Slot Count@ Damage Name minecraft:iron_block Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot! Count Damage Name Slot" Count Damage Name Slot# InventoryVersion 1.7.1 Invulnerable IsAngry IsAutonomous IsBaby IsGliding IsGlobal
IsOrphaned
IsPregnant
IsSwimming IsTamed LeasherIDÿÿÿÿÿÿÿÿ LootDropped Mainhand
Count Damage Name MapIndex MarkVariant NaturalSpawn Offhand
Count Damage Name OnGround OwnerNewÿÿÿÿÿÿÿÿ
Persistent PlayerGameMode PlayerLevel PlayerLevelProgressÌNl> PortalCooldown Pos ×¢—Br=µB [9Â R5DataRecoverComplete Rotation »B ¡ B Saddled SelectedContainerId SelectedInventorySlot Sheared
ShowBottom Sitting
SleepTimer Sleeping Sneaking SpawnForced SpawnX˜ SpawnYÿ SpawnZ Strength StrengthMax Surface TargetIDÿÿÿÿÿÿÿÿ
TimeSinceRestÁs UniqueID ÿÿÿÿ Variant
abilities
attackmobs
attackplayers build doorsandswitches flySpeedÍÌL= flying
instabuild invulnerable lightning mayfly mine op opencontainers permissionsLevel playerPermissionsLevel teleport walkSpeedÍÌÌ= boundX boundY boundZ definitions +minecraft:player hasBoundOrigin
identifier minecraft:player limitedLife
New contributor
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "41"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgaming.stackexchange.com%2fquestions%2f226755%2fdetect-when-player-attacks-another-player%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I figured out how to do this. I use the stat.damageDealt
scoreboard objective. First I run the following command once:
/scoreboard objectives add hit stat.damageDealt
Then on the 20Hz clock I do the following:
First command block:
/tellraw @a[score_hit_min=1] "Nice Hit!"
Second command block:
/scoreboard players reset @a[score_hit_min=1] hit
How this works is that points is added to the stat.damageDealt
objective each time they hit/attack/hurt an entity or player. Then it runs the command on every player that has hurt another entity or player. When that command is done, the objective gets reset.
How I found this is that on the statistics menu from the pause menu, there is a statistic called Damage Dealt.
EDIT:
In Minecraft 1.9, use the repeating command block instead of a 20Hz clock.
I've been working on a different solution, which is much more complicated. I feel stupid now.
– MrLemon
Jul 6 '15 at 11:41
2
@MrLemon Oh, well you can post it, maybe it will be helpful to some players.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon That is if it is done.
– Jacques Marais
Jul 6 '15 at 11:42
I ended up using something I found out while fiddling around with my solution (which was just awful to be hones) to upgrade your solution.
– MrLemon
Jul 6 '15 at 12:12
I'm a little surprised thatstat.damageDealt
isn't further subdivided into the various mobs and players.
– MBraedley
Jul 6 '15 at 21:07
add a comment |
I figured out how to do this. I use the stat.damageDealt
scoreboard objective. First I run the following command once:
/scoreboard objectives add hit stat.damageDealt
Then on the 20Hz clock I do the following:
First command block:
/tellraw @a[score_hit_min=1] "Nice Hit!"
Second command block:
/scoreboard players reset @a[score_hit_min=1] hit
How this works is that points is added to the stat.damageDealt
objective each time they hit/attack/hurt an entity or player. Then it runs the command on every player that has hurt another entity or player. When that command is done, the objective gets reset.
How I found this is that on the statistics menu from the pause menu, there is a statistic called Damage Dealt.
EDIT:
In Minecraft 1.9, use the repeating command block instead of a 20Hz clock.
I've been working on a different solution, which is much more complicated. I feel stupid now.
– MrLemon
Jul 6 '15 at 11:41
2
@MrLemon Oh, well you can post it, maybe it will be helpful to some players.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon That is if it is done.
– Jacques Marais
Jul 6 '15 at 11:42
I ended up using something I found out while fiddling around with my solution (which was just awful to be hones) to upgrade your solution.
– MrLemon
Jul 6 '15 at 12:12
I'm a little surprised thatstat.damageDealt
isn't further subdivided into the various mobs and players.
– MBraedley
Jul 6 '15 at 21:07
add a comment |
I figured out how to do this. I use the stat.damageDealt
scoreboard objective. First I run the following command once:
/scoreboard objectives add hit stat.damageDealt
Then on the 20Hz clock I do the following:
First command block:
/tellraw @a[score_hit_min=1] "Nice Hit!"
Second command block:
/scoreboard players reset @a[score_hit_min=1] hit
How this works is that points is added to the stat.damageDealt
objective each time they hit/attack/hurt an entity or player. Then it runs the command on every player that has hurt another entity or player. When that command is done, the objective gets reset.
How I found this is that on the statistics menu from the pause menu, there is a statistic called Damage Dealt.
EDIT:
In Minecraft 1.9, use the repeating command block instead of a 20Hz clock.
I figured out how to do this. I use the stat.damageDealt
scoreboard objective. First I run the following command once:
/scoreboard objectives add hit stat.damageDealt
Then on the 20Hz clock I do the following:
First command block:
/tellraw @a[score_hit_min=1] "Nice Hit!"
Second command block:
/scoreboard players reset @a[score_hit_min=1] hit
How this works is that points is added to the stat.damageDealt
objective each time they hit/attack/hurt an entity or player. Then it runs the command on every player that has hurt another entity or player. When that command is done, the objective gets reset.
How I found this is that on the statistics menu from the pause menu, there is a statistic called Damage Dealt.
EDIT:
In Minecraft 1.9, use the repeating command block instead of a 20Hz clock.
edited Jun 14 '16 at 13:39
answered Jul 6 '15 at 11:40
Jacques MaraisJacques Marais
1,486524
1,486524
I've been working on a different solution, which is much more complicated. I feel stupid now.
– MrLemon
Jul 6 '15 at 11:41
2
@MrLemon Oh, well you can post it, maybe it will be helpful to some players.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon That is if it is done.
– Jacques Marais
Jul 6 '15 at 11:42
I ended up using something I found out while fiddling around with my solution (which was just awful to be hones) to upgrade your solution.
– MrLemon
Jul 6 '15 at 12:12
I'm a little surprised thatstat.damageDealt
isn't further subdivided into the various mobs and players.
– MBraedley
Jul 6 '15 at 21:07
add a comment |
I've been working on a different solution, which is much more complicated. I feel stupid now.
– MrLemon
Jul 6 '15 at 11:41
2
@MrLemon Oh, well you can post it, maybe it will be helpful to some players.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon That is if it is done.
– Jacques Marais
Jul 6 '15 at 11:42
I ended up using something I found out while fiddling around with my solution (which was just awful to be hones) to upgrade your solution.
– MrLemon
Jul 6 '15 at 12:12
I'm a little surprised thatstat.damageDealt
isn't further subdivided into the various mobs and players.
– MBraedley
Jul 6 '15 at 21:07
I've been working on a different solution, which is much more complicated. I feel stupid now.
– MrLemon
Jul 6 '15 at 11:41
I've been working on a different solution, which is much more complicated. I feel stupid now.
– MrLemon
Jul 6 '15 at 11:41
2
2
@MrLemon Oh, well you can post it, maybe it will be helpful to some players.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon Oh, well you can post it, maybe it will be helpful to some players.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon That is if it is done.
– Jacques Marais
Jul 6 '15 at 11:42
@MrLemon That is if it is done.
– Jacques Marais
Jul 6 '15 at 11:42
I ended up using something I found out while fiddling around with my solution (which was just awful to be hones) to upgrade your solution.
– MrLemon
Jul 6 '15 at 12:12
I ended up using something I found out while fiddling around with my solution (which was just awful to be hones) to upgrade your solution.
– MrLemon
Jul 6 '15 at 12:12
I'm a little surprised that
stat.damageDealt
isn't further subdivided into the various mobs and players.– MBraedley
Jul 6 '15 at 21:07
I'm a little surprised that
stat.damageDealt
isn't further subdivided into the various mobs and players.– MBraedley
Jul 6 '15 at 21:07
add a comment |
This answer is based on @CommandFox's answer and my own (totally awful) idea for a solution. However, I found that combination of the two adds a possible limitation to hurting specific entities.
First, create two scoreboard objectives: didDamage
and hurtTime
scoreboard objectives add didDamage stat.damageDealt
scoreboard objectives add hurtTime dummy
Then, create a fill clock and run the following commands:
scoreboard players add @e hurtTime 1
scoreboard players set @e hurtTime 0 {HurtTime:0s}
execute @e[score_hurtTime_min=1,score_hurtTime=1] ~ ~ ~ tellraw @a[score_didDamage=1] "Nice hit!"
scoreboard player set @a didDamage 0
So far, we have gained nothing by using the hurtTime
objective. The main benefit of it is that it can be limited using its target selector. For example, using
scoreboard players add @e[type=Zombie] hurtTime 1
scoreboard players set @e[type=Zombie] hurtTime 0 {HurtTime:0s}
makes it so that the message only appears when you actually hit a zombie. Using multiples of this command block pair makes it possible to select multiple entities.
This solution is great for when you want to limit the mobs or players that the player may hit. Thank you.
– Jacques Marais
Jul 6 '15 at 12:20
@CommandFox I'm just glad I was able to salvage something useful from my attempt after all. For players, you could also usestat.damageTaken
instead, butstat
-objectives do not work for other entities.
– MrLemon
Jul 6 '15 at 12:26
Incidentally, I found out that after hitting a mob, it is invincible (glowing red) for exactly 10 ticks (1/2 sec).
– MrLemon
Jul 6 '15 at 12:27
Yes, thank you for your help. I have a use for this on one of my command block minigames.
– Jacques Marais
Jul 6 '15 at 12:27
Wow, I didn't even know that. Thanks :D
– Jacques Marais
Jul 6 '15 at 12:31
add a comment |
This answer is based on @CommandFox's answer and my own (totally awful) idea for a solution. However, I found that combination of the two adds a possible limitation to hurting specific entities.
First, create two scoreboard objectives: didDamage
and hurtTime
scoreboard objectives add didDamage stat.damageDealt
scoreboard objectives add hurtTime dummy
Then, create a fill clock and run the following commands:
scoreboard players add @e hurtTime 1
scoreboard players set @e hurtTime 0 {HurtTime:0s}
execute @e[score_hurtTime_min=1,score_hurtTime=1] ~ ~ ~ tellraw @a[score_didDamage=1] "Nice hit!"
scoreboard player set @a didDamage 0
So far, we have gained nothing by using the hurtTime
objective. The main benefit of it is that it can be limited using its target selector. For example, using
scoreboard players add @e[type=Zombie] hurtTime 1
scoreboard players set @e[type=Zombie] hurtTime 0 {HurtTime:0s}
makes it so that the message only appears when you actually hit a zombie. Using multiples of this command block pair makes it possible to select multiple entities.
This solution is great for when you want to limit the mobs or players that the player may hit. Thank you.
– Jacques Marais
Jul 6 '15 at 12:20
@CommandFox I'm just glad I was able to salvage something useful from my attempt after all. For players, you could also usestat.damageTaken
instead, butstat
-objectives do not work for other entities.
– MrLemon
Jul 6 '15 at 12:26
Incidentally, I found out that after hitting a mob, it is invincible (glowing red) for exactly 10 ticks (1/2 sec).
– MrLemon
Jul 6 '15 at 12:27
Yes, thank you for your help. I have a use for this on one of my command block minigames.
– Jacques Marais
Jul 6 '15 at 12:27
Wow, I didn't even know that. Thanks :D
– Jacques Marais
Jul 6 '15 at 12:31
add a comment |
This answer is based on @CommandFox's answer and my own (totally awful) idea for a solution. However, I found that combination of the two adds a possible limitation to hurting specific entities.
First, create two scoreboard objectives: didDamage
and hurtTime
scoreboard objectives add didDamage stat.damageDealt
scoreboard objectives add hurtTime dummy
Then, create a fill clock and run the following commands:
scoreboard players add @e hurtTime 1
scoreboard players set @e hurtTime 0 {HurtTime:0s}
execute @e[score_hurtTime_min=1,score_hurtTime=1] ~ ~ ~ tellraw @a[score_didDamage=1] "Nice hit!"
scoreboard player set @a didDamage 0
So far, we have gained nothing by using the hurtTime
objective. The main benefit of it is that it can be limited using its target selector. For example, using
scoreboard players add @e[type=Zombie] hurtTime 1
scoreboard players set @e[type=Zombie] hurtTime 0 {HurtTime:0s}
makes it so that the message only appears when you actually hit a zombie. Using multiples of this command block pair makes it possible to select multiple entities.
This answer is based on @CommandFox's answer and my own (totally awful) idea for a solution. However, I found that combination of the two adds a possible limitation to hurting specific entities.
First, create two scoreboard objectives: didDamage
and hurtTime
scoreboard objectives add didDamage stat.damageDealt
scoreboard objectives add hurtTime dummy
Then, create a fill clock and run the following commands:
scoreboard players add @e hurtTime 1
scoreboard players set @e hurtTime 0 {HurtTime:0s}
execute @e[score_hurtTime_min=1,score_hurtTime=1] ~ ~ ~ tellraw @a[score_didDamage=1] "Nice hit!"
scoreboard player set @a didDamage 0
So far, we have gained nothing by using the hurtTime
objective. The main benefit of it is that it can be limited using its target selector. For example, using
scoreboard players add @e[type=Zombie] hurtTime 1
scoreboard players set @e[type=Zombie] hurtTime 0 {HurtTime:0s}
makes it so that the message only appears when you actually hit a zombie. Using multiples of this command block pair makes it possible to select multiple entities.
answered Jul 6 '15 at 12:10
MrLemonMrLemon
15.2k33969
15.2k33969
This solution is great for when you want to limit the mobs or players that the player may hit. Thank you.
– Jacques Marais
Jul 6 '15 at 12:20
@CommandFox I'm just glad I was able to salvage something useful from my attempt after all. For players, you could also usestat.damageTaken
instead, butstat
-objectives do not work for other entities.
– MrLemon
Jul 6 '15 at 12:26
Incidentally, I found out that after hitting a mob, it is invincible (glowing red) for exactly 10 ticks (1/2 sec).
– MrLemon
Jul 6 '15 at 12:27
Yes, thank you for your help. I have a use for this on one of my command block minigames.
– Jacques Marais
Jul 6 '15 at 12:27
Wow, I didn't even know that. Thanks :D
– Jacques Marais
Jul 6 '15 at 12:31
add a comment |
This solution is great for when you want to limit the mobs or players that the player may hit. Thank you.
– Jacques Marais
Jul 6 '15 at 12:20
@CommandFox I'm just glad I was able to salvage something useful from my attempt after all. For players, you could also usestat.damageTaken
instead, butstat
-objectives do not work for other entities.
– MrLemon
Jul 6 '15 at 12:26
Incidentally, I found out that after hitting a mob, it is invincible (glowing red) for exactly 10 ticks (1/2 sec).
– MrLemon
Jul 6 '15 at 12:27
Yes, thank you for your help. I have a use for this on one of my command block minigames.
– Jacques Marais
Jul 6 '15 at 12:27
Wow, I didn't even know that. Thanks :D
– Jacques Marais
Jul 6 '15 at 12:31
This solution is great for when you want to limit the mobs or players that the player may hit. Thank you.
– Jacques Marais
Jul 6 '15 at 12:20
This solution is great for when you want to limit the mobs or players that the player may hit. Thank you.
– Jacques Marais
Jul 6 '15 at 12:20
@CommandFox I'm just glad I was able to salvage something useful from my attempt after all. For players, you could also use
stat.damageTaken
instead, but stat
-objectives do not work for other entities.– MrLemon
Jul 6 '15 at 12:26
@CommandFox I'm just glad I was able to salvage something useful from my attempt after all. For players, you could also use
stat.damageTaken
instead, but stat
-objectives do not work for other entities.– MrLemon
Jul 6 '15 at 12:26
Incidentally, I found out that after hitting a mob, it is invincible (glowing red) for exactly 10 ticks (1/2 sec).
– MrLemon
Jul 6 '15 at 12:27
Incidentally, I found out that after hitting a mob, it is invincible (glowing red) for exactly 10 ticks (1/2 sec).
– MrLemon
Jul 6 '15 at 12:27
Yes, thank you for your help. I have a use for this on one of my command block minigames.
– Jacques Marais
Jul 6 '15 at 12:27
Yes, thank you for your help. I have a use for this on one of my command block minigames.
– Jacques Marais
Jul 6 '15 at 12:27
Wow, I didn't even know that. Thanks :D
– Jacques Marais
Jul 6 '15 at 12:31
Wow, I didn't even know that. Thanks :D
– Jacques Marais
Jul 6 '15 at 12:31
add a comment |
žN !> _*
~local_player¡(
AgentIDæ úÿÿÿ Air, Armor
Count Damage Name Count Damage Name Count Damage Name Count Damage Name
AttackTime
Attributes
Base A Current ˜A Max A Name minecraft:health Base Current Max €D Name minecraft:luck Base Current Max €@ Name minecraft:player.exhaustion BaseÍÌÌ= CurrentÍÌÌ= Maxÿÿ Name minecraft:movement Base Current Max €A Name minecraft:absorption Base Current Max €? Name minecraft:knockback_resistance Base
×£< Current
×£< Maxÿÿ Name minecraft:underwater_movement Base €? Current €? Maxÿÿ Name minecraft:fall_damage Base €A Current €A Max E Name minecraft:follow_range Base €? Current €? Max €? Name minecraft:attack_damage Base A Current A Max A Name minecraft:player.hunger Base A Current ˜A Max A Name minecraft:player.saturation Base @@ Current @@ Max ®ÁF Name minecraft:player.level BaseÌNl> CurrentÌNl> Max €? Name minecraft:player.experience BedPositionX BedPositionY BedPositionZ Chested Color Color2
CursorSelectedItem Count Damage Name DeathTime DimensionId EnchantmentSeedñ=j EnderChestInventory
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot FallDistance Fire HurtTime Inventory
$ Count Damage Name minecraft:diamond_sword Slot Count Damage Name minecraft:arrow Slot Count Damage Name minecraft:bone Slot Count Damage] Name
minecraft:bow Slot Count@ Damage Name minecraft:iron_block Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot! Count Damage Name Slot" Count Damage Name Slot# InventoryVersion 1.7.1 Invulnerable IsAngry IsAutonomous IsBaby IsGliding IsGlobal
IsOrphaned
IsPregnant
IsSwimming IsTamed LeasherIDÿÿÿÿÿÿÿÿ LootDropped Mainhand
Count Damage Name MapIndex MarkVariant NaturalSpawn Offhand
Count Damage Name OnGround OwnerNewÿÿÿÿÿÿÿÿ
Persistent PlayerGameMode PlayerLevel PlayerLevelProgressÌNl> PortalCooldown Pos ×¢—Br=µB [9Â R5DataRecoverComplete Rotation »B ¡ B Saddled SelectedContainerId SelectedInventorySlot Sheared
ShowBottom Sitting
SleepTimer Sleeping Sneaking SpawnForced SpawnX˜ SpawnYÿ SpawnZ Strength StrengthMax Surface TargetIDÿÿÿÿÿÿÿÿ
TimeSinceRestÁs UniqueID ÿÿÿÿ Variant
abilities
attackmobs
attackplayers build doorsandswitches flySpeedÍÌL= flying
instabuild invulnerable lightning mayfly mine op opencontainers permissionsLevel playerPermissionsLevel teleport walkSpeedÍÌÌ= boundX boundY boundZ definitions +minecraft:player hasBoundOrigin
identifier minecraft:player limitedLife
New contributor
add a comment |
žN !> _*
~local_player¡(
AgentIDæ úÿÿÿ Air, Armor
Count Damage Name Count Damage Name Count Damage Name Count Damage Name
AttackTime
Attributes
Base A Current ˜A Max A Name minecraft:health Base Current Max €D Name minecraft:luck Base Current Max €@ Name minecraft:player.exhaustion BaseÍÌÌ= CurrentÍÌÌ= Maxÿÿ Name minecraft:movement Base Current Max €A Name minecraft:absorption Base Current Max €? Name minecraft:knockback_resistance Base
×£< Current
×£< Maxÿÿ Name minecraft:underwater_movement Base €? Current €? Maxÿÿ Name minecraft:fall_damage Base €A Current €A Max E Name minecraft:follow_range Base €? Current €? Max €? Name minecraft:attack_damage Base A Current A Max A Name minecraft:player.hunger Base A Current ˜A Max A Name minecraft:player.saturation Base @@ Current @@ Max ®ÁF Name minecraft:player.level BaseÌNl> CurrentÌNl> Max €? Name minecraft:player.experience BedPositionX BedPositionY BedPositionZ Chested Color Color2
CursorSelectedItem Count Damage Name DeathTime DimensionId EnchantmentSeedñ=j EnderChestInventory
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot FallDistance Fire HurtTime Inventory
$ Count Damage Name minecraft:diamond_sword Slot Count Damage Name minecraft:arrow Slot Count Damage Name minecraft:bone Slot Count Damage] Name
minecraft:bow Slot Count@ Damage Name minecraft:iron_block Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot! Count Damage Name Slot" Count Damage Name Slot# InventoryVersion 1.7.1 Invulnerable IsAngry IsAutonomous IsBaby IsGliding IsGlobal
IsOrphaned
IsPregnant
IsSwimming IsTamed LeasherIDÿÿÿÿÿÿÿÿ LootDropped Mainhand
Count Damage Name MapIndex MarkVariant NaturalSpawn Offhand
Count Damage Name OnGround OwnerNewÿÿÿÿÿÿÿÿ
Persistent PlayerGameMode PlayerLevel PlayerLevelProgressÌNl> PortalCooldown Pos ×¢—Br=µB [9Â R5DataRecoverComplete Rotation »B ¡ B Saddled SelectedContainerId SelectedInventorySlot Sheared
ShowBottom Sitting
SleepTimer Sleeping Sneaking SpawnForced SpawnX˜ SpawnYÿ SpawnZ Strength StrengthMax Surface TargetIDÿÿÿÿÿÿÿÿ
TimeSinceRestÁs UniqueID ÿÿÿÿ Variant
abilities
attackmobs
attackplayers build doorsandswitches flySpeedÍÌL= flying
instabuild invulnerable lightning mayfly mine op opencontainers permissionsLevel playerPermissionsLevel teleport walkSpeedÍÌÌ= boundX boundY boundZ definitions +minecraft:player hasBoundOrigin
identifier minecraft:player limitedLife
New contributor
add a comment |
žN !> _*
~local_player¡(
AgentIDæ úÿÿÿ Air, Armor
Count Damage Name Count Damage Name Count Damage Name Count Damage Name
AttackTime
Attributes
Base A Current ˜A Max A Name minecraft:health Base Current Max €D Name minecraft:luck Base Current Max €@ Name minecraft:player.exhaustion BaseÍÌÌ= CurrentÍÌÌ= Maxÿÿ Name minecraft:movement Base Current Max €A Name minecraft:absorption Base Current Max €? Name minecraft:knockback_resistance Base
×£< Current
×£< Maxÿÿ Name minecraft:underwater_movement Base €? Current €? Maxÿÿ Name minecraft:fall_damage Base €A Current €A Max E Name minecraft:follow_range Base €? Current €? Max €? Name minecraft:attack_damage Base A Current A Max A Name minecraft:player.hunger Base A Current ˜A Max A Name minecraft:player.saturation Base @@ Current @@ Max ®ÁF Name minecraft:player.level BaseÌNl> CurrentÌNl> Max €? Name minecraft:player.experience BedPositionX BedPositionY BedPositionZ Chested Color Color2
CursorSelectedItem Count Damage Name DeathTime DimensionId EnchantmentSeedñ=j EnderChestInventory
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot FallDistance Fire HurtTime Inventory
$ Count Damage Name minecraft:diamond_sword Slot Count Damage Name minecraft:arrow Slot Count Damage Name minecraft:bone Slot Count Damage] Name
minecraft:bow Slot Count@ Damage Name minecraft:iron_block Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot! Count Damage Name Slot" Count Damage Name Slot# InventoryVersion 1.7.1 Invulnerable IsAngry IsAutonomous IsBaby IsGliding IsGlobal
IsOrphaned
IsPregnant
IsSwimming IsTamed LeasherIDÿÿÿÿÿÿÿÿ LootDropped Mainhand
Count Damage Name MapIndex MarkVariant NaturalSpawn Offhand
Count Damage Name OnGround OwnerNewÿÿÿÿÿÿÿÿ
Persistent PlayerGameMode PlayerLevel PlayerLevelProgressÌNl> PortalCooldown Pos ×¢—Br=µB [9Â R5DataRecoverComplete Rotation »B ¡ B Saddled SelectedContainerId SelectedInventorySlot Sheared
ShowBottom Sitting
SleepTimer Sleeping Sneaking SpawnForced SpawnX˜ SpawnYÿ SpawnZ Strength StrengthMax Surface TargetIDÿÿÿÿÿÿÿÿ
TimeSinceRestÁs UniqueID ÿÿÿÿ Variant
abilities
attackmobs
attackplayers build doorsandswitches flySpeedÍÌL= flying
instabuild invulnerable lightning mayfly mine op opencontainers permissionsLevel playerPermissionsLevel teleport walkSpeedÍÌÌ= boundX boundY boundZ definitions +minecraft:player hasBoundOrigin
identifier minecraft:player limitedLife
New contributor
žN !> _*
~local_player¡(
AgentIDæ úÿÿÿ Air, Armor
Count Damage Name Count Damage Name Count Damage Name Count Damage Name
AttackTime
Attributes
Base A Current ˜A Max A Name minecraft:health Base Current Max €D Name minecraft:luck Base Current Max €@ Name minecraft:player.exhaustion BaseÍÌÌ= CurrentÍÌÌ= Maxÿÿ Name minecraft:movement Base Current Max €A Name minecraft:absorption Base Current Max €? Name minecraft:knockback_resistance Base
×£< Current
×£< Maxÿÿ Name minecraft:underwater_movement Base €? Current €? Maxÿÿ Name minecraft:fall_damage Base €A Current €A Max E Name minecraft:follow_range Base €? Current €? Max €? Name minecraft:attack_damage Base A Current A Max A Name minecraft:player.hunger Base A Current ˜A Max A Name minecraft:player.saturation Base @@ Current @@ Max ®ÁF Name minecraft:player.level BaseÌNl> CurrentÌNl> Max €? Name minecraft:player.experience BedPositionX BedPositionY BedPositionZ Chested Color Color2
CursorSelectedItem Count Damage Name DeathTime DimensionId EnchantmentSeedñ=j EnderChestInventory
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot FallDistance Fire HurtTime Inventory
$ Count Damage Name minecraft:diamond_sword Slot Count Damage Name minecraft:arrow Slot Count Damage Name minecraft:bone Slot Count Damage] Name
minecraft:bow Slot Count@ Damage Name minecraft:iron_block Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot
Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot Count Damage Name Slot! Count Damage Name Slot" Count Damage Name Slot# InventoryVersion 1.7.1 Invulnerable IsAngry IsAutonomous IsBaby IsGliding IsGlobal
IsOrphaned
IsPregnant
IsSwimming IsTamed LeasherIDÿÿÿÿÿÿÿÿ LootDropped Mainhand
Count Damage Name MapIndex MarkVariant NaturalSpawn Offhand
Count Damage Name OnGround OwnerNewÿÿÿÿÿÿÿÿ
Persistent PlayerGameMode PlayerLevel PlayerLevelProgressÌNl> PortalCooldown Pos ×¢—Br=µB [9Â R5DataRecoverComplete Rotation »B ¡ B Saddled SelectedContainerId SelectedInventorySlot Sheared
ShowBottom Sitting
SleepTimer Sleeping Sneaking SpawnForced SpawnX˜ SpawnYÿ SpawnZ Strength StrengthMax Surface TargetIDÿÿÿÿÿÿÿÿ
TimeSinceRestÁs UniqueID ÿÿÿÿ Variant
abilities
attackmobs
attackplayers build doorsandswitches flySpeedÍÌL= flying
instabuild invulnerable lightning mayfly mine op opencontainers permissionsLevel playerPermissionsLevel teleport walkSpeedÍÌÌ= boundX boundY boundZ definitions +minecraft:player hasBoundOrigin
identifier minecraft:player limitedLife
New contributor
New contributor
answered 11 mins ago
user228063user228063
1
1
New contributor
New contributor
add a comment |
add a comment |
Thanks for contributing an answer to Arqade!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgaming.stackexchange.com%2fquestions%2f226755%2fdetect-when-player-attacks-another-player%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown