(Java Minecraft 1.14) Scoreboard objective for ghast fireballs deflected?
Solution 1:
So it turns out you can't necessarily detect fireballs deflected, but you can detect fireballs deflected into ghasts. The vanilla datapack has the 'Return to Sender' JSON advancement file as:
{
"parent": "minecraft:nether/root",
"display": {
"icon": {
"item": "minecraft:fire_charge"
},
"title": {
"translate": "advancements.nether.return_to_sender.title"
},
"description": {
"translate": "advancements.nether.return_to_sender.description"
},
"frame": "challenge",
"show_toast": true,
"announce_to_chat": true,
"hidden": false
},
"rewards": {
"experience": 50
},
"criteria": {
"killed_ghast": {
"trigger": "minecraft:player_killed_entity",
"conditions": {
"entity": {
"type": "minecraft:ghast"
},
"killing_blow": {
"is_projectile": true,
"direct_entity": {
"type": "minecraft:fireball"
}
}
}
}
},
"requirements": [
[
"killed_ghast"
]
]
}
So you could use a hidden advancement which detects that, and so every time a player gets it, add one to a dummy scoreboard and revoke the advancement.
Another possible thing (which I haven't tested) is the possibility of using the player hurt entity trigger for the advancement on the ghast fireball, so then if the player "hurts" (punches) the fireball the advancement is granted, and you use the same scoreboard process as above.
I will edit whether that is possible and if it is, what JSON advancement file I used when I get around to it.