Add dispenser API docs

master
Wuzzy 2018-02-01 23:00:50 +01:00
parent fa10dc93ae
commit 4207f88266
2 changed files with 28 additions and 0 deletions

1
API.md
View File

@ -25,6 +25,7 @@ A lot of things are possible by using one of the APIs in the mods. Note that not
* Walls: `ITEMS/mcl_walls` * Walls: `ITEMS/mcl_walls`
* Beds: `ITEMS/mcl_beds` * Beds: `ITEMS/mcl_beds`
* Buckets: `ITEMS/mcl_buckets` * Buckets: `ITEMS/mcl_buckets`
* Dispenser support: `ITEMS/REDSTONE/mcl_dispensers`
## Mobs ## Mobs
* Mobs: `ENTITIES/mods` * Mobs: `ENTITIES/mods`

View File

@ -0,0 +1,27 @@
# API documentation for dispensers
The dispensers API allows you to add custom code which is called when a
particular item is dispensed.
Just add the `_on_dispense` function to the item definition.
By default, items are just thrown out as item entities.
## Additional fields for item definitions
### `_on_dispense(stack, pos, droppos, dropnode, dropdir)`
This is a function which is called when an item is dispensed by the dispenser.
These are the parameters:
* stack: Itemstack which is dispense. This is always exactly 1 item
* pos: Position of dispenser
* droppos: Position to which to dispense item
* dropnode: Node of droppos
* dropdir: Drop direction
By default (return value: `nil`), the itemstack is consumed by the dispenser afterwards.
Optionally, you can explicitly set the return value to a custom leftover itemstack.
### `_dispense_into_walkable`
By default, items will only be dispensed into non-walkable nodes.
But if this value is set If `true`, the item can be dispensed into walkable nodes.