Skip to content

Origin conditions in layers

apace100 edited this page Mar 16, 2021 · 2 revisions

Typically, the origins field in a layer JSON file looks something like this:

"origins": [
  "origins:avian",
  "origins:blazeborn",
  "origins:enderian",
  "origins:arachnid"
]

But, this new feature (0.4.0 and higher) allows you to add conditional origins. This is done by instead of providing a string, providing a json object with an Entity Condition:

"origins": [
  "origins:avian",
  "origins:blazeborn",
  {
    "condition": {
      "type": "origins:daytime"
    },
    "origins": [
      "origins:enderian"
    ]
  },
  {
    "condition": {
      "type": "origins:daytime",
      "inverted": true
    },
    "origins": [
      "origins:arachnid"
    ]
  }
]

As you can see from the above example, the "conditioned origin objects" can be used alongside the regular strings of origin IDs in the array. Also, the objects contain an array of origins which will be available only when the condition holds. That means you don't have to repeat a condition for several origins if they would have the same condition.

The main use of this feature is for a data pack which provides several layers, and would like to restrict which origins are possible given the previously selected ones (such as first picking an element, and then a fitting origin in the next layer). Specifically for this, the conditions Origin and Power exist. Example, assuming you have a layer elemental_origins:element where you can choose an element:

"origins": [
  {
    "condition": {
      "type": "origins:origin",
      "origin": "elemental_origins:fire",
      "layer": "elemental_origins:element"
    },
    "origins": [
      "origins:blazeborn",
      "elemental_origins:flame_spirit"
    ]
  },
  {
    "condition": {
      "type": "origins:origin",
      "origin": "elemental_origins:air",
      "layer": "elemental_origins:element"
    },
    "origins": [
      "origins:avian",
      "aerum:aerum"
    ]
  },
  "..."
]
Clone this wiki locally