Type Wrappers

Block Predicate

Block predicates test for a block state at a position within the world

In scripts, they can de defined as

  • A BlockPredicate object: itself
  • A Block object: A minecraft:matching_blocks predicate matching the given block
  • A Fluid object: A minecraft:matching_fluids predicate matching the given fluid
  • A TagKey object: A minecraft:matching_block_tag predicate matching the given tag
  • A string:
    • If starts with a # character: A minecraft:matching_block_tag predicate matching the given tag id
    • Else: A minecraft:matching_blocks predicate matching the given block id
  • A list: A minecraft:all_of predicate
    • List values are expected to be block predicates (or capable of being wrapped as block predicates) themselves
  • A boolean object:
    • If true: A minecraft:true predicate
    • If false: A minecraft:not predicate wrapping a minecraft:true predicate
  • A map:
    • If the map contains a 'type' field, the map is parsed as if it were defined in json, using the specification linked above
    • If the map contains a 'not' field, a minecraft:not predicate will be made
      • The not object is expected to be a block predicate or capable of being wrapped as a block predicate
    • If the map contains an 'all' field, a minecraft:all_of predicate will be made
      • The all object is expected to be a list whose values are block predicates themselves (or are capable of being wrapped as block predicates) themselves
    • If the map contains an 'any' field, a minecraft:any_of predicate will be made
      • The any object is expected to be a list whose values are block predicates themselves (or are capable of being wrapped as block predicates) themselves
    • If the map contains a 'blocks' field, a minecraft:matching_blocks predicate is made
      • The blocks object is expected to be a map with the following fields
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
        • 'match': A block HolderSet, the valid blocks
          • Most commonly a list of block ids, or a #-prefixed tag id
    • If the map contains a 'tag' field, a minecraft:matching_block_tag predicate is made
      • The tag object is expected to be a map with the following fields
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
        • 'match': A block TagKey, the valid blocks
          • Can be defined as a string, the id of the tag
    • If the map contains a 'fluids' field, a minecraft:matching_fluids predicate is made
      • The fluids object is expected to be a map with the following fields
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
        • 'match': A fluid HolderSet, the valid fluids
          • Most commonly a list of fluid ids, or a #-prefixed tag id
    • If the map contains a 'replaceable' field, a minecraft:replaceable predicate is made
      • The replaceable object is expected to be a map with the following field
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
    • If the map contains a 'would_survive' field, a minecraft:would_survive predicate is made
      • The would_survive object is expected to be a map with the following fields
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
        • 'state': A block state, the state survivability is being checked with
    • If the map contains a 'has_sturdy_face' field, a minecraft:has_sturdy_face predicate is made
      • The has_sturdy_face object is expected to be an object with the following fields
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
        • 'direction': A Direction, the direction to check if a block is sturdy
          Reveal/hide list of allowed directions
          • up
          • down
          • east
          • west
          • north
          • south
    • If the map contains a 'solid' field, a minecraft:solid predicate is made
      • The solid object is expected to be a map with the following field
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
    • If the map contains a 'no_fluid' field, a minecraft:matching_fluids predicate which only matches minecraft:empty is made
      • The no_fluid object is expected to be a map with the following field
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
    • If the map contains a 'inside_world' field, a minecraft:inside_world_bounds is made
      • The inside_world object is expected to be a map with the following field
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]
    • If the map contains an 'unobstructed' field, a minecraft:unobstructed predicate is made
      • The unobstructed object is expected to be a map with the following field
        • 'offest': A Vec3i, the offset applied to the check when validating a checked position
          • Optional, defaults to [0, 0, 0]

Other values will emit an error

Block State Provider

Block state providers specify a block(state) which may be randomized

In scripts, they can be defined as

  • A BlockStateProvider object: itself
  • A Block object: A minecraft:simple_state_provider providing the given block
  • A BlockState object: A minecraft:simple_state_provider providing the given block state
  • A list: A minecraft:weighted_state_provider provider
  • A map:
    • If the map contains a 'type' field, the map is parsed as if it were defined in json, using the specification linked above
    • If the map contains a 'simple' or 'block' field, a minecraft:simple_state_provider provider will be made
      • The simple/block object is expected to be a block state or capable of being wrapped as a block state
    • If the map contains a 'rotate' field, a minecraft:rotated_block_provider will be created
      • The rotate object is expected to be a block or capable of being wrapped as a block
    • If the map contains a 'randomized_int' field, a minecraft:randomized_int_state_provider provider will be created
      • The randomized_int object is expected to be a map with the following fields
        • 'property': A string, the name of the block property
        • 'values': An IntProvider, the possible values of the block property
        • 'source': A BlockStateProvider, the source state to apply the property value to
    • If the contains a 'weighted' field, a minecraft:weighted_state_provider provider will be made
      • The weighted object is expected to be a list of block state provider weighted values

Other values will be attempted to be parsed as a BlockState and if successful, a minecraft:simple_state_provider will be made, else an error will be emitted

Height Provider

Height providers specify a height (range) to select from when generating certain features

In scripts, they can be defined as

  • A single number: A minecraft:constant height provider with an absolute vertical anchor of the given y-level
  • A map:
    • If the map contains a 'type' field, the map is parsed as if it were defined in json, using the specification linked above
    • If the map contains a 'uniform' field, a minecraft:uniform height provider will be created
      • The uniform object is expected to be a map with two fields
    • If the map contains a 'constant' field, a minecraft:constant height provider will be created
      • The constant object will be parsed as a [[ vertical anchor ]], the height
    • If the map contains a 'trapezoid' field, a minecraft:trapezoid height provider will be created
      • The trapezoid object is expected to be a map with the following fields
        • 'min': A vertical anchor, the minimum height
        • 'max': A vertical anchor, the maximum height
        • 'plateau': An int, the range in the middle of the trapezoid distribution that has a uniform distribution
          • Optional, defaults to 0
    • If the map contains a 'weighted' field, a minecraft:weighted_list height provider will be created
      • The weighted object is expected to a list of height provider weighted values
    • If the map contains a 'biased' field, a minecraft:biased_to_bottom height provider will be created
      • The biased object is expected to be a map with the following fields
        • 'min': A vertical anchor, the minimum height
        • 'max': A vertical anchor, the maximum height
        • 'inner': An int, the inner value
        • Optional, defaults to 1
        • 'extreme': A boolean{.p}, if the height provider should instead be a minecraft:very_biased_to_bottom height provider
          • Optional, defaults to false
  • A list: A minecraft:weighted_list height provider
  • A HeightProvider object: itself
  • A VerticalAnchor object: a minecraft:constant height provider at the given vertical anchor

Other values will emit an error

Vertical Anchor

Vertical anchors specify a y-value for feature generation, often as part of height providers

In scripts, they can be defined as

  • A single number: An absolute anchor at the given y-level
  • A string:
    • If 'bottom': An above_bottom anchor with a value of 0
    • If 'top': A below_top anchor with a value of 0
    • If '-' or 'zero': An absolute anchor with a value of 0
  • A map:
    • If the map contains a 'type' field, the map is parsed as if it were defined in json, using the specification linked above
    • If the map contains an 'absolute' field, an absolute anchor is created
      • The absolute object will be parsed as a number to use as the value of the anchor
    • If the map contains a 'above_bottom' field, a above_bottom anchor is created
      • The above_bottom object will be parsed as a number to use as the value of the anchor
    • if the map contains a 'below_top' field, a below_top anchor is created
      • The below_top object will be parsed as a number to use as the value of the anchor
  • A VerticalAnchor object: itself

Other values will emit an error

Weighted Value

Weighted values are ways of describing a collection of objects which can be weighted. Weighted values are always made as part of a list which will never accept null or undefined values. Weights less than 1 are also considered invalid and will emit an exception if encountered

Weighted values for a type can be created as

  • A WeightedValue object: Will attempt to convert the value object of the given weighted value to expected type and emit a weighted value with the same weight
    • Will emit an error if the value could not be converted to the expected type
  • A map with 'weight' and 'value' fields:
    • 'weight': The weight given to the value, an int that must be greater than 0
    • 'value': The value the is being weighted, an object of the expected type or any of its wrapped forms
  • A list:
    • The first item will be interpreted as an int, the weight
    • The second item will be wrapped to an object of the expected type or any of its wrapped forms
  • An object of the expected type or any of its wrapped forms
    • Will have a weight of 1