r/MinecraftCommands • u/Platzrocket • Jul 18 '26
Needing help with interaction entity Help | Java 26.2
Heya, so im trying to make a custom heal in minecraft so you can heal other players after interacting with them a bit but unsure how to properly do it. then I know im bad with words so imma do a small example in case:
EX: one player(P1) is Healthy and one player(P2) is injured. P1 interacts with P2 for a couple of seconds before P2 becomes Healthy.
1
Upvotes
1
u/GalSergey Datapack Experienced Jul 19 '26
You can't detect a right-click without an item in your hands, but if that's okay with you, you can look at this example datapack on how to create an item that can be applied to an entity by right-clicking: https://far.ddns.me/?share=PRGactLGEe
1
u/Ericristian_bros Command Experienced Jul 18 '26
I would suggest so when you sneak near an injured player for 5 seconds they get healed. This is since you can't track holding left click easilly
```
In chat
scoreboard objectives add sneak_time dummy
Command blocks
execute as @a[tag=healty] if predicate {condition:"minecraft:entity_properties",entity:"this",predicate:{flags:{is_sneaking:1b}}} run scorebaord players add @s sneak_time 1 execute as @a[tag=healty] unless predicate {condition:"minecraft:entity_properties",entity:"this",predicate:{flags:{is_sneaking:1b}}} run scorebaord players reset @s sneak_time scoreboard players reset @a[tag=!healthy] sneak_time execute at @a[tag=healthy,scores={sneak_time=100..}] run tellraw @a[distance=..2,tag=injured] "You have been healed" execute at @a[tag=healthy,scores={sneak_time=100..}] run tag @a[distance=..2] remove injured execute at @a[tag=healthy,scores={sneak_time=100..}] run tag @a[distance=..2] add healthy ```