]> git.lizzy.rs Git - Crafter.git/blob - mods/hopper/api.txt
Use actual state modifiers with ticks to control satiation and hunger instead of...
[Crafter.git] / mods / hopper / api.txt
1
2 Hopper API
3 ----------
4
5 This API is kept simple by adding a single command which allows mods to add
6 containers like chests and furnaces to the hopper check list.
7
8
9 Command Usage
10 -------------
11
12 Make sure any mods using this function has 'hopper' in the depends.txt file.
13
14 hopper:add_container({ {"where_from", "node_name", "inventory_name"} })
15
16   'where_from' is a string telling the api that items are coming from either
17                the 'top' node into a hopper below, going into the 'bottom' node
18                from the hopper above or coming from a 'side' hopper into the
19                node next door.
20
21   'node_name"  is the name of the container itself (e.g. "default:chest")
22
23   'inventory_name' is the name of the container inventory that is affected.
24
25 e.g.
26
27 hopper:add_container({
28         {"top", "default:furnace", "dst"}, -- take cooked items from above into hopper below
29         {"bottom", "default:furnace", "src"}, -- insert items below to be cooked from hopper above
30         {"side", "default:furnace", "fuel"}, -- replenish furnace fuel from hopper at side
31 })
32
33 You can also register hopper interaction targets by group, or by a group and a specific group
34 value. For example:
35
36 hopper:add_container({
37         {"top", "group:loot_chest", "loot"},
38         {"bottom", "group:loot_chest", "loot"},
39         {"side", "group:loot_chest", "loot"},
40 })
41
42 Would cause hoppers to interact with the "loot" inventory of all nodes belonging to the group
43 "loot_chest", and
44
45 hopper:add_container({
46         {"top", "group:protected_container=1", "main"},
47         {"bottom", "group:protected_container=1", "main"},
48         {"side", "group:protected_container=1", "main"},
49 })
50
51 Would cause hoppers to interact with the "main" inventory of nodes belonging to the group
52 "protected_container" provided they had a value of 1 in that group. Hoppers prioritize the most
53 specific definition first; they check for registrations for a specific node name, then
54 for registrations that apply to a node's group and group value, and then for registrations
55 applying to a node's group in general.
56
57 Note that if multiple group registrations apply to the same node it's undefined which group
58 will take priority. Using the above examples, if there were a node that belonged to *both*
59 the groups "loot_chest" and "protected_container=1" there's no way of knowing ahead of time
60 whether hoppers would interact with the "loot" or "main" inventories. Try to avoid this situation.
61
62 The hopper mod already have support for the wine barrel inside of the Wine mod and protected
63 chests inside of Protector Redo, as well as default chests, furnaces and hoppers
64 themselves.