New advancement

What we want to achieve

For this example we want to create a new advancement for our custom datapack that unlocks when we unlock either Hiken or Higan of Mera Mera no Mi.

How to do it

Since this is our custom advancement and not something we want to replace from another mod we will be using our own namespace called datapackexample. So create this folder in the data folder, and inside it create a advancements/category folder structure with a test.json file at the very end.

Our project should look like this:

└── data
    └── datapackexample
        └── advancements
            └── category
                └── test.json

The category name can be whatever you want, same for test.json, the name of the file does not affect the name of the advancement however its a good practice to keep the names at least similar to avoid confusion.

Now inside our test.json file we want to actually write the logic for the advancement.

{
  "display": {
    "icon": {
      "item": "mineminenomi:mera_mera_no_mi"
    },
    "title": {
      "translate": "datapackexample:advancements.category.test.title"
    },
    "description": {
      "translate": "datapackexample:advancements.category.test.description"
    },
    "frame": "task",
    "show_toast": true,
    "announce_to_chat": true,
    "hidden": false,
    "background": "minecraft:textures/gui/advancements/backgrounds/adventure.png"
  },
  "criteria": {
    "hiken": {
      "trigger": "mineminenomi:unlock_ability",
      "conditions": {
        "ability": "mineminenomi:hiken"
      }
    },
    "higan": {
      "trigger": "mineminenomi:unlock_ability",
      "conditions": {
        "ability": "mineminenomi:higan"
      }
    }
  },
  "requirements": [["hiken", "higan"]]
}

For Mine Mine no Mi you can also opt in to use abilities as icons instead of items by using something like this:

{
    "icon": {
        "ability": "mineminenomi:hiken",
        "item": "minecraft:paper"
    }
}

Note that we're also adding an item icon as a fallback, in case our ability gets removed or we've written it wrong or for any other reason where it cannot be loaded, it will fallback to the item's texture. This is optional but encouraged to avoid potential problems caused by future releases.

What interests us most in this is the criteria section:

{
    "hiken": {
        "trigger": "mineminenomi:unlock_ability",
        "conditions": {
            "ability": "mineminenomi:hiken"
        }
    },
    "higan": {
        "trigger": "mineminenomi:unlock_ability",
        "conditions": {
            "ability": "mineminenomi:higan"
        }
    }
}

The names of each criteria can be whatever you want, we could've named them like "unlocked_hiken" and "unlocked_higan" if we wanted to. However you do need to be careful to also edit the requirements list at the bottom with their proper names.

Translation notes

If you decide to use the above method don't forget to register the localized titles and descriptions!

If you want to be lazy and keep the datapack as a standalone file without a resourcepack you can also write titles and descriptions as:

{
    "title": {
      "translate": "Test Title"
    },
    "description": {
      "translate": "Test Description"
    }
}

Do keep in mind this is the lazy approach and not the intended way of doing things.

Testing

Now we need to test if everything works, so archive the datapack accordingly and put the zip file in a any world's datapacks folder.

Join that world and run /datapack list to see if the datapack was loaded correctly.

We can now unlock this advancement using the following command: /ability give mineminenomi:hiken

Or if you just want to easily unlock the advancement: /advancement grant @a from datapackexample:category/test

In both cases it should pop up in the right corner as well as in the advancements UI in a new category named "category" and with a Mera Mera no Mi icon.

Last change: 2024-08-14