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 Mar 26, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates action context parameters to context parameters (used in for example item modifiers and predicates) and adjusts everything accordingly.
Item Behaviour Components
minecraft:bucketentityfield 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:entityentityfield 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:projectileentityfield 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
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 }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_blockposition:minecraft:damage_itemignore_game_modefield.minecraft:drop_item_from_blockitemfield to take an item stack instead of an item.minecraft:exchange_itemitemfield to take an item stack instead of an item.componentsfield.itemfield 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:fertilizeposition:minecraft:modify_itemcontextfield.minecraft:prime_tntSo 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_functionentityandpositionfields 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" }So if you only want the position context you can use this:
{ "type": "minecraft:run_function", "function": "example:function", "position": "origin" }minecraft:sequenceminecraft:swing_handentity:Predicates
minecraft:location_checkposition:"origin"to match existing behaviour.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.minecraft:bucketitem behaviour.minecraft:entityitem behaviour.minecraft:side_checkpredicate.minecraft:drop_item_from_blockaction.minecraft:fertilizeaction.minecraft:use_bucketaction.minecraft:interacted_position, which is the position that the user interacted with.minecraft:equipment_slot, which is used when an item is broken.minecraft:hand, which is the hand used to execute an action.minecraft:swing_handaction to swing the hand.minecraft:open_book_from_itemaction to get the book from the executing entity.minecraft:target_entity, which is the entity that was interacted with.minecraft:entityandminecraft:throwableitem behaviour for the spawned entities.minecraft:hit_entityandminecraft:use_weaponitem events for the attacked entity.minecraft:use_on_entityitem 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
"this""this"minecraft:this_entity"target""target_entity"minecraft:target_entitySo 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
"this""origin"minecraft:origin"target""interacted"minecraft:interacted_positionSo 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" } } }