Minecraft Java Edition Commands – How to Set Scoreboard Objective for Ghast Fireballs Deflected (Java Minecraft 1.14)

minecraft-commandsminecraft-java-edition

Do I need to set up a system to track the fireballs a player deflects or does the statistics system already have a pre-made scoreboard objective for it? I couldn't find any page of all of the stats on the wiki so I only had what was on the /scoreboard command page. Is that all of them or are there others listed somewhere else?

Best Answer

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.