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 map 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

Condition Source

Condition sources are used by minecraft:condition rule sources to decide if their sub-source should be used

In scripts, they can be defined as

  • A string:
    • If 'above_preliminary_surface': A minecraft:above_preliminary_surface condition source
    • If 'hole': A minecraft:hole condition source
    • If 'temperature': A minecraft:temperature condition source
    • If 'steep': A minecraft:steep condition source
  • A list: A minecraft:biome condition source
    • List elements are expected to be biome ids
  • 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 'biome' field, a minecraft:biome condition source will be created
      • The biome object is expected to be a list whose entries are biome ids
    • If the map contains a 'noise_threshold' field, a minecraft:noise_threshold condition source will be made
      • The noise_threshold object is expected to be a map with the following fields
        • 'noise': The id of a noise
        • 'min_threshold': A number, the minimum noise value where the condition passes
        • 'max_threshold': A number, the maximum noise value where the condition passes
          • Optional, defaults to (2 - Math.power(2, -52)) * Math.power(2, 1023)
    • If the map contains a 'vertical_gradient' field, a minecraft:vertical_gradient condition source will be created
      • The vertical_gradient object is expected to be a map with the following fields
        • 'random_name': A string
        • 'true_at_and_below': A vertical anchor, the condition will always pass at and below this height
        • 'false_at_and_above': A vertical anchor, the condition will always pass at and above this height
    • If the map contains a 'y_above' field, a minecraft:y_above condition source will be created
      • The y_above object is expected to be a map with the following fields
        • 'add_stone_depth': A boolean, If the distance to the surface above should be added
          • Optional, defaults to false
        • 'anchor': A vertical anchor, the anchor to compare the height to
        • 'surface_depth_multiplier': A int, how much the comparison is affected by the surface depth
          • Must be in the range [-20, 20]
    • If the map contains a 'water' field, a minecraft:water condition source will be created
      • The water field is expected to be a map with the following fields
        • 'offset': An int, the value added to the water depth before comparison
        • 'surface_depth_multiplier': An int, how much the comparison is affected by the surface depth
          • Must be in the range [-20, 20]
        • 'add_stone_depth': A boolean, if the distance to the surface should be added to the offset
          • Optional, defaults to false
    • If the map contains a 'temperature' field, a minecraft:temperature condition source will be created
    • If the map contains a 'steep' field, a minecraft:steep condition source will be created
    • If the map contains a 'not' field, a minecraft:not condition source will be created
      • The not field is expected to be a condition source, the condition source to invert
    • If the map contains a 'hole' field, a minecraft:hole condition source will be created
    • If the map contains a 'above_preliminary_surface' field, a minecraft:above_preliminary_surface condition surface will be created
    • If the map contains a 'stone_depth' field, a minecraft:stone_depth condition source will be created
      • The stone_depth object is expected to be a map with the following fields
        • 'offset': An int, the vertical offset
        • 'add_surface_depth': A boolean, if the surface depth should be added to the offset
          • Optional, defaults to false
        • 'secondary_depth_range': An int, the mapped value of the secondary surface depth to add to the offset
        • 'surface_type': A CaveSurface, the surface type to compare to
          Reveal/hide valid cave surfaces
          • floor
          • ceiling

Other values will emit an error

Density Function

Density functions define a function to obtain a number from a position

In scripts they can de defined as

  • A DensityFunction object: itself
  • A string, ResourceLocation, or density function ResourceKey: The density function previously registered under the given id
  • A number: A minecraft:constant density function
    • Must be in the range [-1000000, 1000000]
  • 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 'blend_alpha' field, a minecraft:blend_alpha density function will be created
    • If the map contains a 'beardifier' field, a minecraft:beardifier density function will be created
    • If the map contains a 'old_blend_noise' field, a minecraft:old_blend_noise density function will be created
      • The old_blend_noise object is expected to be a map with the following fields
        • 'xz_scale': A number, the horizontal scale
          • Must be in the range [0.001, 1000]
        • 'y_scale': A number, the vertical scale
          • Must be in the range [0.001, 1000]
        • 'xz_factor': A number, the horizontal scale
          • Must be in the range [0.001, 1000]
        • 'y_factor': A number, the vertical scale
          • Must be in the range [0.001, 1000]
        • 'smear_scale_multiplier': A number, a multiplier applied to the y_scale
          • Must be in the range [1, 8]
    • If the map contains a 'interpolated' field, a minecraft:interpolated density function will be created
      • The interpolated object is expected to be a density function
    • If the map contains a 'flat_cache' field, a minecraft:flat_cache density function will be created
      • The flat_cache object is expected to be a density function
    • If the map contains a 'cache_2d' field, a minecraft:cache_2d density function will be created
      • The cache_2d object is expected to be a density function
    • If the map contains a 'cache_once' field, a minecraft:cache_once density function will be created
      • The cache_once object is expected to be a density function
    • If the map contains a 'cache_all_in_cell' field, a minecraft:cache_all_in_cell density function will be made
      • The cache_all_in_cell object is expected to be a density function
    • If the map contains a 'noise' field, a minecraft:noise density function will be created
      • The noise object is expected to be a map with the following fields
        • 'noise': A noise parameters id, the noise to use
        • 'xz_scale': A number, the horizontal scaling before sampling
        • 'y_scale': A number, the vertical scaling before sampling
    • If the map contains a 'end_islands' object, a minecraft:end_islands density function will be made
    • If the map contains a 'weird_scaled_sampler' field, a minecraft:weird_scaled_sampler density function will be created
      • The weird_scaled_sampler is expected to be a map with the following fields
        • 'input': A density function, the function to be scaled
        • 'noise': A noise parameters id, the noise to use
        • 'rarity_value_mapper': A RarityValueMapper, the value mapper type to use
          Reveal/hide valid rarity value mappers
          • type1
          • type2
    • If the map contains a 'shifted_noise' field, a minecraft:shifted_noise density function will be created
      • The shifted_noise object is expected to be map with the following fields
        • 'shift_x': A density function, the shift in the x direction
        • 'shift_y': A density function, the shift in the y direction
        • 'shift_z': A density function, the shift in the z direction
        • 'xz_scale': A number, the horizontal scaling before sampling
        • 'y_scale': A number, the vertical scaling before sampling
        • 'noise': A noise parameters id, the noise to use
    • If the map contains a 'range_choice' field, a minecraft:range_choice density function will be created
      • The range_choice object is expected to be a map with the following fields
        • 'input': A density function, the value to compare
        • 'min_inclusive': A number, the lower bound of the range
          • Must be in the range [-1000000, 1000000]
        • 'max_inclusive': A number, the upper bound of the range
          • Must be in the range [-1000000, 1000000]
        • 'when_in_range': A density function, the value to use when the input is within the range
        • 'when_out_of_range': A density function, the value to use when the input is outside of the range
    • If the map contains a 'shift_a' field, a minecraft:shift_a density function will be created
      • The shift_a object is expected to be a noise parameters id, the noise to sample
    • If the map contains a 'shift_b' field, a minecraft:shift_b density function will be created
      • The shift_b object is expected to be a noise parameters id, the noise to sample
    • If the map contains a 'shift' field, a minecraft:shift density function will be created
    • If the map contains a 'blend_density' field, a minecraft:blend_density density function will be created
      • The blend_density object is expected to be a density function, the desired density of new chunks
    • If the map contains a 'clamp' field, a minecraft:clamp density function will be created
      • The clamp object is expected to be a map with the following fields
        • 'input': A density function, the function be clamped
        • 'min_value': A number, the minimum value
          • Must be in the range [-1000000, 1000000]
        • 'max_value': A number, the maximum value
          • Must be in the range [-1000000, 1000000]
    • If the map contains an 'abs' field, a minecraft:abs density function will be created
      • The abs object is expected to be a density function, the function to be absolute valued
    • If the map contains a 'square' field, a minecraft:square density function will be created
      • The square object is expected to be a density function, the function to be squared
    • If the map contains a 'cube' field, a minecraft:cube density function will be created
      • The cube object is expected to be a density function, the function to be cubed
    • If the map contains a 'half_negative' field, a minecraft:half_negative density function will be created
      • The half_negative object is expected to be a density function, the function to halve when negative
    • If the map contains a 'quarter_negative' field, a minecraft:quarter_negative density function will be created
      • The quarter_negative field is expected to be a density function, the function to be quartered when negative
    • If the map contains a 'squeeze' field, a minecraft:squeeze density function will be created
      • The squeeze object is expected to be a density function, the function to be squeezed
    • If the map contains an 'add' field, a minecraft:add density function will be created
      • The add object is expected to be a map with two fields
        • 'first': A density function
        • 'second': A density function
    • If the map contains a 'mul' field, a minecraft:mul density function will be created
      • The mul object is expected to be a map with two fields
        • 'first': A density function
        • 'second': A density function
    • If the map contains a 'min' field, a minecraft:min density function will be created
      • The min object is expected to be a map with two fields
        • 'first': A density function
        • 'second': A density function
    • If the map contains a 'max' field, a minecraft:max density function will be created
      • The max object is expected to be a map with two fields
        • 'first': A density function
        • 'second': A density function
    • If the map contains a 'spline' field, a minecraft:spline density function will be created
      • The spline object is expected to be a spline
    • If the map contains a 'constant' field, a minecraft:constant density function will be created
      • The constant field is expected to be A number, the constant value
        • Must be in the range [-1000000, 1000000]
    • If the map contains a 'y_clamped_gradient' field, a minecraft:y_clamped_gradient density function will be created
      • The y_clamped_gradient object is expected to be a map with the following fields
        • 'from_y': An int, the value to map to from_value
          • Must be in the range [-4064, 4062]
        • 'to_y': An int, the value to map to to_value
          • Must be in the range [-4064, 4062]
        • 'from_value': A number, the value to map from_y to
          • Must be in the range [-1000000, 1000000]
        • 'to_value': A number, the value to map to_y to
          • Must be in the range [-1000000, 1000000]

Other values will emit an error

Spline

In density functions, splines can be defined in scripts as

  • A number: A constant value
  • A map with the following fields
    • 'coordiante': A string, ResourceLocation, or density function ResourceKey: The previously registered density function used to determine the location on the spline
    • 'value_transformer': The transformer applied to constant spline points. A callback with the params
      • value: number: The value of the point
      • return: number: The transformed value
      • Optional, defaults to val => val
    • 'points': A list of spline points, which are maps with the following fields
      • For a constant point
        • 'location': A number, the location of the point on the spline
        • 'value': A number, the value of the point
        • 'derivative': A number, the slope at the point
      • For a variable point
        • 'location': A number, the location of the point on the spline
        • 'value': A spline, the value of the point

Other values will emit an error

Height Provider

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

In scripts, they can be defined as

  • A HeightProvider object: itself
  • A 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
    • 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, 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

Rule Source

Rule sources determine the block for each solid position of the terrain

In scripts, they can be defined as

  • A RuleSource object: itself
  • The string 'badlands': a minecraft:badlands rule source
  • A list: A minecraft:sequence rule source
    • List values will be parsed as rule sources, the rules for the sequence
  • 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 'badlands' field, a minecraft:badlands rule source
    • If the map contains a 'sequence' field, a minecraft:sequence rule source will be created
      • The sequence object is expected to a list
        • The list entries will be parsed as rule sources, the rules of the sequence
    • If the map contains a 'block' field, a minecraft:block rule source will be created
      • The block object is expected to be a block state
    • If the map contains a 'condition' field, a minecraft:condition rule source will be created
      • The condition object is expected to be a map with the following fields
  • A block state, or anything which can parse as one: A minecraft:block rule source placing that block state is placed

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 VerticalAnchor object: itself
  • A 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 used to describe arbitrary weighted collections in a manner that is script-friendly. They 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 object 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