From 4207f88266e7659f2b920164d84ee81565f74285 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 1 Feb 2018 23:00:50 +0100 Subject: [PATCH] Add dispenser API docs --- API.md | 1 + mods/ITEMS/REDSTONE/mcl_dispensers/API.md | 27 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 mods/ITEMS/REDSTONE/mcl_dispensers/API.md diff --git a/API.md b/API.md index b23c82e65..19590ac2c 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 000000000..419c3ac40 --- /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.