How do I make a custom Minecraft 1.15 advancement that's granted when a player gets killed by TNT?
Conditions within the same criterion work based on AND logic, meaning that they must all match. This is not what you want in this constellation.
To use OR logic (making the advancement succeed when one of the conditions is met), you need to make a constellation such as the following:
"criteria": {
"firstcheck": {
"trigger": "minecraft:entity_killed_player",
"conditions": {
"entity": {
"type": "minecraft:tnt"
},
"killing_blow": {
"is_explosion": true
}
}
},
"secondcheck": {
"trigger": "minecraft:entity_killed_player",
"conditions": {
"killing_blow": {
"is_explosion": true,
"direct_entity": {
"type": "minecraft:tnt"
}
}
}
},
"thirdcheck": {
"trigger": "minecraft:entity_killed_player",
"conditions": {
"killing_blow": {
"is_explosion": true,
"source_entity": {
"type": "minecraft:tnt"
}
}
}
}
},
"requirements": [
[
"firstcheck",
"secondcheck",
"thirdcheck"
]
]
Note the two pairs of square brackets in the requirements
tag. To function in OR logic, your criteria must be combined in the same inner bracket. With something like "requirements": [["criterion1"],["criterion2"]]
, you once again create AND logic, but this time each of the criteria must have been met at some point, and not necessarily at the same time.
For an in-game example of what I just explained, compare the Vanilla advancement The Parrots and the Bats (minecraft:husbandry/breed_an_animal
) with Two By Two (minecraft:husbandry/bred_all_animals
). In general, reading and understanding the default datapack can help a lot with understanding the various mechanics behind them and thus being able to write your own content.