Creating the Challenge
Getting Started
Unlock challenge are defined in the same file used to register the backpack. Create a new object called unlock_challenge
under the root object. This is where the unlock challenge will be defined, which includes an implementation of one of the challenge types, and setting the progress formatter. The contents of the file should now look something similar to below.
{
"unlock_challenge": {
...
}
}
Setting the Challenge
To set the challenge, start by creating a new object called challenge
inside of the unlock_challenge
object. The challenge
object requires a type
, which is then followed by an implementation of that type. Select one of the available challenge types and assign it to the type
property. For the implementation, it is specific to the type of the challenge. On the list of available challenge types, each challenge will have an ID, Description, a table of properties that can be implemented, and a few examples for the challenge type.
Below is an example of the backpacked:craft_item
challenge type. It can be expressed as The player must craft a total of 64 planks of any type or combination of planks to unlock the backpack
.
{
"unlock_challenge": {
"challenge": {
"type": "backpacked:craft_item",
"crafted_item": {
"tag": "minecraft:planks"
},
"count": 64
}
}
}
However based on property table of the Craft Item challenge, crafted_item
is actually completely optional. Removing this property, the implementation would then be expressed as The player must craft a total of 64 of any item or combination of items to unlock the backpack
. The crafted_item
property is simply a filter to match a specific item. It is best to read the description of a property on the property table to get a full understanding.
Test the Challenge
After implementing the challenge, it is a good idea to test that it is working. Backpacked has been designed to load backpacks even if the challenges fail to load. This just simply allows outdated addons to still work with future versions of Backpacked. Backpacks will show an icon in game if the backpack had an error during load. If an error occurs, check the logs for details.
Customise the Progress Formatter
A progress formatter controls how the unlock challenge displays the progression label. This label is shown in a tooltip when the player hovers a locked backpack in the customisation menu. For example, a formatter type that is available for use in addons is backpacked:percentage
, and this will display a percentage based completion label. If the challenge is to mine ten diamond blocks, and currently only four have been mined, the tooltip will display as Completed 40%
.
There are many progress formatters available to use, and it's best to select the one that fits the most appropriately to the challenge. Simply select one of the available progress formatters and apply it to the unlock challenge as follows:
{
"unlock_challenge": {
"formatter": "backpacked:percentage",
"challenge": {
...
}
}
}