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;]"..xbg..
9 "label[1.35,0;Bees are making honey\nwith pollen around...]image[6,0;1,1;hive_bee.png]image[5,0;1,1;hive_layout.png]list[context;honey;5,0;1,1;]list[current_player;main;0,1.35;8,4;]"
11 meta:set_string("formspec", formspec)
12 meta:set_string("infotext", "Artificial Hive")
13 inv:set_size("honey", 1)
16 function hive.dig(pos, _)
17 local inv = minetest.get_meta(pos):get_inventory()
18 return inv:is_empty("honey")
21 xdecor.register("hive", {
22 description = "Artificial Hive",
24 "xdecor_hive_top.png", "xdecor_hive_top.png",
25 "xdecor_hive_side.png", "xdecor_hive_side.png",
26 "xdecor_hive_side.png", "xdecor_hive_front.png"
28 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=1},
29 on_construct = hive.construct,
31 on_punch = function(_, _, puncher, _)
32 local health = puncher:get_hp()
33 puncher:set_hp(health - 4)
35 on_rightclick = function(_, _, clicker)
36 local health = clicker:get_hp()
37 clicker:set_hp(health - 1)
39 allow_metadata_inventory_put = function(...) return 0 end
42 minetest.register_abm({
43 nodenames = {"xdecor:hive"},
44 interval = 10, chance = 5,
45 action = function(pos, _, _, _)
46 local inv = minetest.get_meta(pos):get_inventory()
47 local honeystack = inv:get_stack("honey", 1)
48 local honey = honeystack:get_count()
51 local minp = vector.add(pos, -radius)
52 local maxp = vector.add(pos, radius)
53 local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
55 if #flowers >= 2 and honey < 12 then
56 inv:add_item("honey", "xdecor:honey")