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 |
| contextual | contextual conditions optional | ContextualCondition | ContextualCondition[] |
| additional properties... |
Built-in Actions¶
Drop Item¶
Spawns an item entity on the ground.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "drop_item" |
| item | the item resource id | string |
| count | item amount optional | int |
| nbt | (Forge only) item nbt optional | object | string |
Example
Drops a water bottle:
{
"type": "drop_item",
"item": "potion",
"nbt": {
"Potion": "minecraft:water"
}
}
Place Block¶
Places a block in world.
This action is not repeatable.
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:
{
"type": "place",
"block": "cauldron"
}
Places a waterlogged oak stairs:
{
"type": "place",
"block": {
"blocks": ["oak_stairs"],
"state": {
"waterlogged": "true"
}
}
}
Destroys current block (place air):
{
"type": "place",
"block": "*"
}
Execute Command¶
Executes a command.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "execute" |
| command | the command to run | string |
| hide | hide this action in JEI/REI optional | boolean |
| repeat | execute commands by repetition count optional | boolean |
Example
Spawns particles:
{
"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.
Drop Experience¶
Spawns experience orbs.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "drop_xp" |
| xp | amount | int |
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",
"item": "gold_ingot",
"contextual": {
"type": "weather",
"weather": "rain"
}
},
{
"type": "drop_item",
"item": "ender_pearl"
},
{
"weight": 2,
"type": "drop_item",
"item": "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[] |
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 | boolean |
| 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 |
Hurt Entity¶
Causes damage to the entity.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "hurt" |
| damage | range of damage | DoubleBounds |
| source | damage source type optional | string |
All the vanilla damage source types can be found here.
Example
{
"type": "lychee:block_interacting",
"item_in": {
"item": "shears"
},
"block_in": "pumpkin",
"contextual": {
"type": "entity_health",
"range": {
"min": 2.1
}
},
"post": [
{
"type": "prevent_default"
},
{
"type": "hurt",
"source": "generic",
"damage": 2
}
]
}
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 |
Add Item Cooldown¶
Adds item cooldown to the item in player's hand, just like when you use ender pearl.
This action only works for interaction recipes.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "add_item_cooldown" |
| s | seconds | number |
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 |
Delay¶
Waits for several seconds, then execute the following actions.
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.
Break¶
Stops executing the following actions.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "break" |
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 |
Special Built-in Actions¶
These following actions will prevent the default behavior of the recipe (such as consuming input item). The default behaviors are explained on the recipes page.
Prevent Default Behavior¶
Prevents default behavior and do nothing.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "prevent_default" |
Damage Item¶
Consumes the item's durability.
This action is not repeatable.
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 |
| item | the item resource id | string |
| count | item amount optional | int |
| nbt | (Forge only) item nbt optional | object | string |
NBT Patch (Experimental)¶
NBT patch the inputs or the results. It is mainly used to modify NBT of the results. For rules, please refer to JSON Patch | jsonpatch.com and RFC 7386: JSON Merge Patch.
Format
| Name | Description | Type / Literal |
|---|---|---|
| type | type | "nbt_patch" |
| op | operation type | string |
| path | target | string |
| from | source optional | string |
| value | value optional | any |
Here, Lychee adds a new operation type called "deep_merge", which does exactly what its name implies.
Note
This action will be executed before any other action, regardless of its position in all actions.
Example
{
"type": "lychee:crafting",
"comment": "Test",
"pattern": [
"AA",
"BB"
],
"key": {
"A": {
"item": "feather"
},
"B": {
"item": "stone"
}
},
"result": {
"item": "pufferfish_bucket"
},
"post": [
{
"type": "nbt_patch",
"op": "deep_merge",
"path": "/post/1",
"value": {
"tag": {
"display": {
"Name": "{\"text\":\"Test\"}"
}
}
}
},
{
"type": "set_item",
"target": "/key/A",
"item": "feather"
}
],
"assembling": [
{
"type": "nbt_patch",
"op": "deep_merge",
"path": "/result",
"value": {
"tag": {
"display": {
"Name": "{\"text\":\"Test\"}"
}
}
}
}
]
}