3 function hive.construct(pos)
4 local meta = minetest.get_meta(pos)
5 local inv = meta:get_inventory()
6 local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots..default.get_hotbar_bg(0,1.35)
8 local formspec = [[ size[8,5;]
9 label[1.35,0;Bees are making honey]
10 label[1.35,0.5;with pollen around...]
11 image[6,0;1,1;hive_bee.png]
12 image[5,0;1,1;hive_layout.png]
13 list[context;honey;5,0;1,1;]
14 list[current_player;main;0,1.35;8,4;] ]]
16 meta:set_string("formspec", formspec..xbg)
17 meta:set_string("infotext", "Artificial Hive")
18 inv:set_size("honey", 1)
21 function hive.dig(pos, _)
22 local inv = minetest.get_meta(pos):get_inventory()
23 return inv:is_empty("honey")
26 xdecor.register("hive", {
27 description = "Artificial Hive",
29 "xdecor_hive_top.png", "xdecor_hive_top.png",
30 "xdecor_hive_side.png", "xdecor_hive_side.png",
31 "xdecor_hive_side.png", "xdecor_hive_front.png"
33 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=1},
34 on_construct = hive.construct,
36 on_punch = function(_, _, puncher, _)
37 local health = puncher:get_hp()
38 puncher:set_hp(health - 4)
40 on_rightclick = function(_, _, clicker)
41 local health = clicker:get_hp()
42 clicker:set_hp(health - 1)
44 allow_metadata_inventory_put = function() return 0 end
47 minetest.register_abm({
48 nodenames = {"xdecor:hive"},
49 interval = 10, chance = 5,
50 action = function(pos, _, _, _)
51 local inv = minetest.get_meta(pos):get_inventory()
52 local honeystack = inv:get_stack("honey", 1)
53 local honey = honeystack:get_count()
56 local minp = vector.add(pos, -radius)
57 local maxp = vector.add(pos, radius)
58 local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
60 if #flowers >= 2 and honey < 12 then
61 inv:add_item("honey", "xdecor:honey")