- Minecraft Version(s)
- 1.12, 1.13, 1.14
So, you want to test if a player has hit another player, or mob, or ghost, or Notch. Well, have I got a solution for you! Yes, you!
So first things first, you need to know how to make wait for it! a data pack! Let us use mine for example!
As we see the data pack is formatted so that we have data, then the namespace folder. The one we will be looking at is the advancements folder, which contains the well-named advancements folder underneath it.
In this folder we find two files, we need only to look at one, as they are for the most part the same...
Let us look in the first one, for simplicity reasons. Make sure your files are .json, or else they will fail.
Lines 1-13 are not really super important for the whole ordeal, but after that, you need to pay attention.
Ok, so you have your criteria, that is what the advancement is looking for. You then have an example, that is where you put your trigger. Then you have your trigger, this is the most important part, THE MOST IMPORTANT. So you can put down a lot of triggers, but we are doing player_hurt_entity, so this trigger will activate when the player hurts a certain entity. Type allows you to customize who is doing the hurting, so you can test for arrows from the player or if it is the player directly. As well as NBT of the entity, which helps a ton. You then have the entity which is being hurt, which you can do the NBT for it as well. Then rewards which allow you to execute a function from the advancement.
So first things first, you need to know how to make wait for it! a data pack! Let us use mine for example!
As we see the data pack is formatted so that we have data, then the namespace folder. The one we will be looking at is the advancements folder, which contains the well-named advancements folder underneath it.
In this folder we find two files, we need only to look at one, as they are for the most part the same...
Let us look in the first one, for simplicity reasons. Make sure your files are .json, or else they will fail.
Lines 1-13 are not really super important for the whole ordeal, but after that, you need to pay attention.
Ok, so you have your criteria, that is what the advancement is looking for. You then have an example, that is where you put your trigger. Then you have your trigger, this is the most important part, THE MOST IMPORTANT. So you can put down a lot of triggers, but we are doing player_hurt_entity, so this trigger will activate when the player hurts a certain entity. Type allows you to customize who is doing the hurting, so you can test for arrows from the player or if it is the player directly. As well as NBT of the entity, which helps a ton. You then have the entity which is being hurt, which you can do the NBT for it as well. Then rewards which allow you to execute a function from the advancement.