Post Action¶
Post-action is an action to be executed.
You can add post-actions to a Lychee's recipe, and they will be executed after the recipe is successfully matched.
Basic Format¶
| Name | Description | Type / Literal |
|---|---|---|
| type | type | string |
| if | contextual conditions optional | ContextualCondition | ContextualCondition[] |
| hide | hide this action in JEI/REI/EMI optional | true | false |
| icon | sprite icon location optional | string |
| additional properties... |
Basic Shorthand Format¶
Post-actions can be defined using a shorthand string:
<command> [arg1] [arg2] ... [/option1][/option2]
"<command> [arg1] [arg2] ... [/option1][/option2]"
Available Options¶
/hide- Hide this action in JEI/REI/EMI./<number>- Add a chance for this action to be executed. For example,/0.5= 50% chance.
Entity-related Actions¶
Drop Item¶
Spawns an item entity on the ground.
Shorthand Format
drop <ItemStack>
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "drop_item" |
| id | the item resource id | string |
| count | item amount optional | int |
| components | item components optional | dictionary |
Example
Drops a water bottle:
type: drop_item
id: potion
components:
potion_contents:
potion: minecraft:water
{
"type": "drop_item",
"id": "potion",
"components": {
"potion_contents": {
"potion": "minecraft:water"
}
}
}
Drop Experience¶
Spawns experience orbs.
Shorthand Format
drop <amount: int>xp
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "drop_xp" |
| xp | amount | int |
Set Falling Block's Block¶
Sets the block of a falling block entity.
This action is not repeatable.
Shorthand Format
set_block <BlockPredicate>
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "set_block" |
| block | the block being set | BlockPredicate |
Block-related Actions¶
Place Block¶
Places a block in world.
This action is not repeatable.
Shorthand Format
place <BlockPredicate> [<offsetX: int> <offsetY: int> <offsetZ: int>]
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "place" |
| block | the block being placed | BlockPredicate |
| offsetX | offsets to location optional | int |
| offsetY | offsets to location optional | int |
| offsetZ | offsets to location optional | int |
Example
Places a cauldron:
place cauldron
"place cauldron"
type: place
block: cauldron
{
"type": "place",
"block": "cauldron"
}
Places a waterlogged oak stairs:
place oak_stairs[waterlogged=true]
"place oak_stairs[waterlogged=true]"
type: place
block:
blocks: oak_stairs
state:
waterlogged: 'true'
{
"type": "place",
"block": {
"blocks": "oak_stairs",
"state": {
"waterlogged": "true"
}
}
}
Destroys current block (place air):
place *
"place *"
type: place
block: '*'
{
"type": "place",
"block": "*"
}
Cycle State Property¶
Cycles a property's value in a block-state.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "cycle_state_property" |
| block | only matched block-states will be cycled | BlockPredicate |
| property | the property name | string |
| offsetX | offsets to location optional | int |
| offsetY | offsets to location optional | int |
| offsetZ | offsets to location optional | int |
| reversed | cycle in reversed order optional | true | false |
Item-related Actions¶
Damage Item¶
Consumes the item's durability.
This action is not repeatable.
Shorthand Format
damage_item
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "damage_item" |
| damage | damage optional | int |
| target | target items optional | JsonPointer |
Set Item¶
Replaces the inputs or the results.
This action is not repeatable.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "set_item" |
| target | target items optional | JsonPointer |
| id | the item resource id | string (Identifier) |
| count | item amount optional | int |
| components | item components optional | dictionary |
Add Item Cooldown¶
Adds item cooldown to an item, just like the cooldown when you use an ender pearl.
Shorthand Format
add_item_cooldown <seconds: number>
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "add_item_cooldown" |
| s | seconds | number |
| item | the item resource id optional | string (Identifier) |
Copy Component¶
Copies an item's component to another item. For example, you can copy custom NBT data from the input item to the output item.
This action is not repeatable.
Shorthand Format
copy_component <component: string>
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "copy_component" |
| component | the component id to be copied | string | string[] |
| source | the source item optional | JsonPointer |
| target | the target item optional | JsonPointer |
Remove Component¶
Removes an item's component.
This action is not repeatable.
Shorthand Format
remove_component <component: string>
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "remove_component" |
| component | the component id to be removed | string | string[] |
| target | the target item optional | JsonPointer |
Copy Durability¶
Copies durability from one item to another based on the durability percentage.
This action is not repeatable.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "copy_durability" |
| source | the source item optional | JsonPointer |
| target | the target item optional | JsonPointer |
| bonus | extra durability factor. For example, if the source item has 50% durability and the bonus factor is -0.5, the target item will have 24% durability. optional | number |
Control Flow Actions¶
Prevent Default Behavior¶
Prevents default behavior and do nothing. The default behaviors are explained on the recipes page.
Shorthand Format
prevent_default
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "prevent_default" |
Delay¶
Waits for several seconds, then execute the following actions.
Shorthand Format
delay <seconds: number>
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "delay" |
| s | seconds | number |
Note
After the delay, some context will lose. For example, if the player leaves the game while delaying, you can't hurt the player after this delay.
Exit¶
Stops executing the following actions.
Shorthand Format
exit
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "exit" |
Random¶
Randomly selects entries from an action list to apply. Similar to loot table.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "random" |
| rolls | specifies the number of rolls on the pool optional | IntBounds |
| entries | a list of actions that can be applied | WeightedPostAction[] |
| empty_weight | optional | int |
The format of WeightedPostAction is just like a normal PostAction, but you can add a weight entry to it to decide how often this action is chosen out of all the actions.
Example
type: random
rolls:
min: 3
max: 5
entries:
- type: drop_item
id: gold_ingot
if:
type: weather
weather: rain
- type: drop_item
id: ender_pearl
- weight: 2
type: drop_item
id: dirt
{
"type": "random",
"rolls": {
"min": 3,
"max": 5
},
"entries": [
{
"type": "drop_item",
"id": "gold_ingot",
"if": {
"type": "weather",
"weather": "rain"
}
},
{
"type": "drop_item",
"id": "ender_pearl"
},
{
"weight": 2,
"type": "drop_item",
"id": "dirt"
}
]
}
If-Else Statement¶
Executes a list of actions if the contextual conditions are met or not.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "if" |
| then | a list of actions to be executed if the conditions are met optional | PostAction | PostAction[] |
| else | a list of actions to be executed if the conditions are not met optional | PostAction | PostAction[] |
Position Anchor Actions¶
Move¶
Moves the anchored position in the context.
Shorthand Format
move <x: int> <y: int> <z: int>
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "move" |
| offset | the distance to move | number[3] |
| with | block property name optional | string |
You can use with to rotate the offset according to the facing of the current block. When with is set, the offset will be rotated from "up".
Move towards Face¶
Moves the anchored position in the context towards the direction that being interacted. Only works for interaction recipes.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "move_towards_face" |
| factor | factor optional | number |
Miscellaneous Actions¶
Execute Command¶
Executes a command.
Shorthand Format
run "<command: string>" or execute "<command: string>"
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "execute" |
| command | the command to run | string |
| repeat | execute commands by repetition count optional | true | false |
Example
Spawns particles:
run "particle minecraft:angry_villager ~ ~1 ~ 1 1 1 0 20" /hide
"run \"particle minecraft:angry_villager ~ ~1 ~ 1 1 1 0 20\" /hide"
type: execute
command: particle minecraft:angry_villager ~ ~1 ~ 1 1 1 0 20
hide: true
{
"type": "execute",
"command": "particle minecraft:angry_villager ~ ~1 ~ 1 1 1 0 20",
"hide": true
}
For how to use particle command, please read the wiki.
Create Explosion¶
Creates an explosion at where the interaction occurs.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "explode" |
| offsetX | offsets to location optional | int |
| offsetY | offsets to location optional | int |
| offsetZ | offsets to location optional | int |
| fire | set fire. false by default optional | true | false |
| block_interaction | whether break blocks or not. "destroy" by default optional | "keep" | "destroy" | "destroy_with_decay" |
| radius | the base radius of the explosion. 4 by default optional | number |
| radius_step | the radius step according to how many times the recipe can be done. 0.5 by default optional | number |
Set Falling Anvil Damage Chance¶
This action can only be used in the Block Crushing recipe. The default damage chance depends on the falling height.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "anvil_damage_chance" |
| chance | chance between 0 and 1 | number |