diff --git a/API.md b/API.md index b23c82e6..19590ac2 100644 --- a/API.md +++ b/API.md @@ -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` * Beds: `ITEMS/mcl_beds` * Buckets: `ITEMS/mcl_buckets` +* Dispenser support: `ITEMS/REDSTONE/mcl_dispensers` ## Mobs * Mobs: `ENTITIES/mods` diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/API.md b/mods/ITEMS/REDSTONE/mcl_dispensers/API.md new file mode 100644 index 00000000..419c3ac4 --- /dev/null +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/API.md @@ -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.