Skip to content

Migrate the action context parameter system to the existing context parameter system#86

Merged
ErrorCraft merged 22 commits into0.6.0-preview.1+1.21.4from
action-context-parameters
Mar 26, 2026
Merged

Migrate the action context parameter system to the existing context parameter system#86
ErrorCraft merged 22 commits into0.6.0-preview.1+1.21.4from
action-context-parameters

Conversation

@ErrorCraft
Copy link
Copy Markdown
Owner

@ErrorCraft ErrorCraft commented Mar 24, 2026

Migrates action context parameters to context parameters (used in for example item modifiers and predicates) and adjusts everything accordingly.

Item Behaviour Components

  • Replaced usages of entity initialisers with entity types directly.

minecraft:bucket

  • The entity target in the entity field now only accepts an entity type instead of an entity initialiser.

So if you had this:

{
  "minecraft:bucket": {
    "emptying_sound_event": "minecraft:item.bucket.empty_fish",
    "entity": {
      "entity": {
        "type": "minecraft:pufferfish"
      },
      "require_other_successful_placement": true
    },
    "fluid": "minecraft:water",
    "transforms_into": "minecraft:bucket"
  }
}

You now have to use this instead:

{
  "minecraft:bucket": {
    "emptying_sound_event": "minecraft:item.bucket.empty_fish",
    "entity": {
      "entity": "minecraft:pufferfish",
      "require_other_successful_placement": true
    },
    "fluid": "minecraft:water",
    "transforms_into": "minecraft:bucket"
  }
}

minecraft:entity

  • The entity field now only accepts an entity type instead of an entity initialiser.

So if you had this:

{
  "minecraft:entity": {
    "entity": {
      "type": "minecraft:oak_boat"
    }
  }
}

You now have to use this instead:

{
  "minecraft:entity": {
    "entity": "minecraft:oak_boat"
  }
}

minecraft:projectile

  • The entity field now only accepts an entity type instead of an entity initialiser.

So if you had this:

{
  "minecraft:projectile": {
    "entity": {
      "type": "minecraft:trident"
    }
  }
}

You now have to use this instead:

{
  "minecraft:projectile": {
    "entity": "minecraft:trident"
  }
}

Actions

  • Removed action context parameters in favour of entity targets and new position targets.
    • These values need to be updated accordingly.
    • There is more information on this in the Entity Targets section below.

So if you had this:

{
  "type": "minecraft:play_sound",
  "category": "neutral",
  "pitch": 1.0,
  "position": "this",
  "sound": "minecraft:item.bottle.fill",
  "volume": 1.0
}

You now have to use this instead:

{
  "type": "minecraft:play_sound",
  "category": "neutral",
  "pitch": 1.0,
  "position": "origin",
  "sound": "minecraft:item.bottle.fill",
  "volume": 1.0
}
  • Various actions gained fields for entity targets.
  • Exchanging stacks now works in more places and in more contexts.
  • Simplified action requirements to only take a predicate due to the migration towards context parameters.

So if you had this:

{
  "requirements": {
    "conditions": {
      "condition": "minecraft:location_check",
      "predicate": {
        "block": {
          "blocks": "minecraft:respawn_anchor"
        }
      }
    },
    "context": {
      "entity": "this",
      "position": "target"
    }
  }
}

You now have to use this instead:

{
  "requirements": {
    "condition": "minecraft:location_check",
    "position": "interacted",
    "predicate": {
      "block": {
        "blocks": "minecraft:respawn_anchor"
      }
    }
  }
}

minecraft:attach_leashed_entities_on_block

  • Added a new field called position:
    • Its value is a position target and determines the position the leashed entities will be attached to.

minecraft:damage_item

  • Removed the ignore_game_mode field.
    • The action now always takes the game mode into account.

minecraft:drop_item_from_block

  • Changed the item field to take an item stack instead of an item.

minecraft:exchange_item

  • Changed the item field to take an item stack instead of an item.
  • Removed the components field.
    • The components are now defined in the item field instead.

So if you had this:

{
  "type": "minecraft:exchange_item",
  "components": {
    "minecraft:potion_contents": {
      "potion": "minecraft:water"
    }
  },
  "item": "minecraft:potion"
}

You now have to use this instead:

{
  "type": "minecraft:exchange_item",
  "item": {
    "id": "minecraft:potion",
    "components": {
      "minecraft:potion_contents": {
        "potion": "minecraft:water"
      }
    },
    "count": 1
  }
}

minecraft:fertilize

  • Added a new field called position:
    • Its value is a position target and determines the position to fertilize.

minecraft:modify_item

  • Removed the context field.
    • The item modifier now uses the exact same context as the action.

minecraft:prime_tnt

  • Turns any block into primed TNT now instead of just TNT.
    • The block that is primed is used for the display.
  • Checking for the TNT block must be done in the action requirements now.

So if you had this:

{
  "action": {
    "type": "minecraft:prime_tnt",
    "position": "target"
  }
}

You now have to use this instead:

{
  "action": {
    "type": "minecraft:prime_tnt",
    "position": "interacted"
  },
  "requirements": {
    "condition": "minecraft:location_check",
    "position": "interacted",
    "predicate": {
      "block": {
        "blocks": "minecraft:tnt"
      }
    }
  }
}

minecraft:run_function

  • Moved the entity and position fields up due to the removal of action context parameters.

So if you had this:

{
  "type": "minecraft:run_function",
  "function": "example:function",
  "context": {
    "entity": "this",
    "position": "this"
  }
}

You now have to use this instead:

{
  "type": "minecraft:run_function",
  "function": "example:function",
  "entity": "this",
  "position": "origin"
}
  • Both fields are optional now and will never try to pass the parameter if not specified.

So if you only want the position context you can use this:

{
  "type": "minecraft:run_function",
  "function": "example:function",
  "position": "origin"
}

minecraft:sequence

  • Now no longer incorrectly reports duplicate actions defined in the same sequence as recursive.

minecraft:swing_hand

  • Added a new field called entity:
    • Its value is an entity target and determines whose hand to swing.

Predicates

minecraft:location_check

  • Added a new optional field called position:
    • Its value is a position target and is the position to retrieve to use for the check.
    • Its default value is "origin" to match existing behaviour.
    • Fails if the position defined is not present in the context.

Example:

{
  "condition": "minecraft:location_check",
  "position": "interacted",
  "predicate": {
    "block": {
      "blocks": "minecraft:tnt"
    }
  }
}

Context Parameters

Added the following context parameters from the migration:

  • minecraft:side, which is the side of a block that was interacted with.
    • Passed in the minecraft:bucket item behaviour.
    • Passed in the minecraft:entity item behaviour.
    • Used in dispense behaviour to interact with the Dispenser's facing direction.
    • Used in the minecraft:side_check predicate.
    • Used in the minecraft:drop_item_from_block action.
    • Used in the minecraft:fertilize action.
    • Used in the minecraft:use_bucket action.
  • minecraft:interacted_position, which is the position that the user interacted with.
    • Passed and used in various item behaviour.
    • Used in dispense behaviour to interact with the Dispenser's output position.
  • minecraft:equipment_slot, which is used when an item is broken.
  • minecraft:hand, which is the hand used to execute an action.
    • Passed to various item events when an item is being used.
    • Used in the minecraft:swing_hand action to swing the hand.
    • Used in the minecraft:open_book_from_item action to get the book from the executing entity.
  • minecraft:target_entity, which is the entity that was interacted with.
    • Used in the minecraft:entity and minecraft:throwable item behaviour for the spawned entities.
    • Passed to the minecraft:hit_entity and minecraft:use_weapon item events for the attacked entity.
    • Passed to the minecraft:use_on_entity item event for the interacted entity.

Action context parameters were replaced with new targets to be consistent with vanilla.
This means that all parameters are now passed to loot tables, item modifiers and predicates instead of having to select specific ones using action context parameters, which were removed as well.
This also means that you may need to update the value of certain fields.
All changes are visible below.

Entity Targets

Old New Context Parameter
"this" "this" minecraft:this_entity
"target" "target_entity" minecraft:target_entity

So if you had this:

{
  "type": "minecraft:set_entity_name_from_item",
  "entity": "target"
}

You now have to use this instead:

{
  "type": "minecraft:set_entity_name_from_item",
  "entity": "target_entity"
}

Position Targets

Old New Context Parameter
"this" "origin" minecraft:origin
"target" "interacted" minecraft:interacted_position

So if you had this:

{
  "type": "minecraft:set_block_state",
  "position": "target",
  "state": {
    "Name": "minecraft:farmland",
    "Properties": {
      "moisture": "0"
    }
  }
}

You now have to use this instead:

{
  "type": "minecraft:set_block_state",
  "position": "interacted",
  "state": {
    "Name": "minecraft:farmland",
    "Properties": {
      "moisture": "0"
    }
  }
}

@ErrorCraft ErrorCraft merged commit edddb46 into 0.6.0-preview.1+1.21.4 Mar 26, 2026
2 checks passed
@ErrorCraft ErrorCraft deleted the action-context-parameters branch March 26, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant