Skip to content

Quest Definition

Kārlis Čerņavskis edited this page Aug 7, 2024 · 7 revisions

Quest

To add quest definitions, you need to create a JSON file for each quest. These JSON files should be placed in the quests directory of your datapack.

Note: There are no defaults for triggers, objectives, and rewards, they are always required, even if it's an empty array.

{
  // A list of objectives that will trigger the quest to appear and start tracking the quest's objective goals.
  // If the array is empty, the quest will be available to start immediately.
  triggers: Objective[],

  // A list of objectives that the player must complete to finish the quest.
  // If the array is empty, the quest will be completed immediately.
  objectives: Objective[],

  // A list of rewards that the player will receive upon completing the quest.
  // If the array is empty, the player will receive no rewards.
  rewards: Reward[],

  // The display information for the quest.
  display: QuestDisplay,
}

Example:

{
  "triggers": [],
  "objectives": [
    {
     "type": "questlog:block_mine",
     "total": 100,
    },
  ],
  "rewards": [
    {
      "type": "questlog:experience",
      "amount": 100,
      "levels": false,
      "instant": true,
      "display": {
        "name": "100 Experience",
        "icon": { "item": "minecraft:experience_bottle" }
      }
    }
  ],
  "display": {
      "title": "Mine 100 Stone",
      "description": "Mine 100 stone blocks.",
      "icon": "minecraft:textures/item/stone.png",
  }
}

Objective

An objective is a task that the player must complete to finish a quest. Objectives can be anything from killing a mob to crafting an item.

{
  // The type of objective.
  // Some types of objectives may require additional properties, for example, a block mining quest
  // requires a "block" field to specify the block type to mine.
  // 
  // See Objective Types for a list of built-in objective types.
  type: ResourceLocation,

  // The total number of times the player must complete the set task to finish the objective.
  // For example, if the objective is to mine 100 stone blocks, the total would be `100`.
  total: number,

  // The display information for the objective.
  // If not provided, the objective will use the default display information for its type.
  // 
  // If this objective is a trigger, this will be disregarded.
  display?: ObjectiveDisplay,
}

Reward

Rewards are items or other benefits that the player receives upon completing a quest.
They only show up in the quest details after the quest is completed.

{
  // The type of reward. Some types of rewards may require additional properties.
  // See Reward Types for a list of built-in reward types.
  type: ResourceLocation,

  // Determines if the player will receive the reward instantly upon completing the quest or if
  // they will have to claim it manually.
  // Defaults to: false
  instant?: boolean,

  // The display information for the reward.
  // If not provided, the reward will use the default display information for its type.
  display?: RewardDisplay,
}

QuestDisplay

{
  // The title of the quest.
  // Example: `"Mine 100 Stone"`
  title: string,

  // The description of the quest. May contain line breaks (`\n`), or formatting codes using `§`.
  // Example: `"Mine 100 stone blocks."`
  description: string,

  // The icon to display for the quest.
  // This is used in the quest log and in the quest start toast.
  // If not provided, no icon will be displayed.
  icon?: Renderable,

  // Whether the title and description are translatable strings.
  // If true, the title and description will be treated as translation keys,
  // and the client will attempt to translate them using the player's language settings.
  // Defaults to: false
  translatable?: boolean,

  // The sound to play when the quest is completed or triggered.
  sound?: QuestSoundOptions,
  style?: StyleOptions,

  // Notification options for the quest.
  notification?: NotificationOptions,

  // Hides the quest from the quest log.
  // This is useful for quests that should only show a popup.
  hidden?: boolean,
}

ObjectiveDisplay

{
  // The name of the objective.
  // Example: `"Mine 100 Stone"`
  name: string,

  // The icon to display for the objective.
  // This is used in the quest details screen.
  // If not provided, no icon will be displayed.
  icon?: Renderable,

  // Whether the name is a translatable string.
  // If true, the name will be treated as a translation key,
  // and the client will attempt to translate it using the player's language settings.
  // Defaults to: false
  translatable?: boolean,
}

RewardDisplay

{
  // The name of the reward.
  // Example: `"100 Experience"`
  name: string,

  // The icon to display for the reward.
  // This is used in the quest details screen.
  // If not provided, the reward will use the default icon for its type.
  icon?: Renderable,

  // Whether the name is a translatable string.
  // If true, the name will be treated as a translation key,
  // and the client will attempt to translate it using the player's language settings.
  // Defaults to: false
  translatable?: boolean,

  // The sound to play when a reward is claimed.
  sound?: RewardSoundOptions,
}

StyleOptions

{
  // The texture to use for the quest details and toasts.
  // Defaults to: { "texture": "questlog:textures/gui/quest_peripherals.png" }
  peripheral?: Texture,

  // The texture to use for the quest page background.
  // Defaults to: { "texture": "questlog:textures/gui/quest_page.png" }
  background?: Texture,

  // The text to use for the "Back" button in the quest details screen.
  // This is affected by the `translatable` option.
  // Defaults to: "gui.back" translation
  buttonText?: string,

  // The text color to use for the description, objective, reward, and button text.
  // Defaults to: "#4C381B"
  textColor: string,

  // The color to use for the "Completed" and "Collected" text for objectives and rewards.
  // Defaults to: "#529E52"
  completedTextColor: string,

  // The color to use for the button text when the button is hovered over.
  // Defaults to: "#FFFFFF"
  hoveredTextColor: string,

  // The color to use for the quest title.
  // Defaults to: "#4C381B"
  titleColor: string,

  // The color to use for the progress text for objectives and rewards when they're unclaimed.
  // Defaults to: "#9E7852"
  progressTextColor: string,
}

QuestSoundOptions

{
  // The sound to play when a quest is completed.
  completed?: ResourceLocation,

  // The sound to play when a quest is triggered.
  triggered?: ResourceLocation,
}

RewardSoundOptions

{
  // The sound to play when a reward is claimed.
  claimed?: ResourceLocation,
}

NotificationOptions

{
  // Enables the toast notification when the quest is triggered.
  toastOnTrigger?: boolean,

  // Enables the toast notification when the quest is completed.
  toastOnComplete?: boolean,

  // Determines whether to show a popup on trigger instead of a toast. Read more in Popup.
  popup?: boolean,
}

ResourceLocation

A resource location is a string that identifies a resource in the game.
It is formatted as namespace:path. You may have seen this in Minecraft's item IDs, such as minecraft:diamond_sword.
Type: string

Renderable

This provides a way to specify a texture or item to be rendered as an icon in the game.
Type: Texture | Item

Texture

The path to the texture file.
This texture should always be a 16x16 image.

{
  texture: ResourceLocation,
}

Example:

{ "texture": "minecraft:textures/mob_effect/luck.png" }

Item

Item ID to be used for rendering.
This mod respects item models, so you can use any item ID here, not just regular 2d items.

{
  item: ResourceLocation,
}

Example:

{ "item": "minecraft:grass_block" }