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
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[current_name;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 if not inv:is_empty("honey") then return false end
22 xdecor.register("hive", {
23 description = "Artificial Hive",
25 "xdecor_hive_top.png", "xdecor_hive_top.png",
26 "xdecor_hive_side.png", "xdecor_hive_side.png",
27 "xdecor_hive_side.png", "xdecor_hive_front.png"
29 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=1},
30 on_construct = hive.construct,
32 on_punch = function(_, _, puncher, _)
33 local health = puncher:get_hp()
34 puncher:set_hp(health - 4)
36 on_rightclick = function(_, _, clicker)
37 local health = clicker:get_hp()
38 clicker:set_hp(health - 1)
40 allow_metadata_inventory_put = function(_, listname, _, stack, _)
41 if listname == "honey" then return 0 end
42 return stack:get_count()
46 minetest.register_abm({
47 nodenames = {"xdecor:hive"},
48 interval = 10, chance = 5,
49 action = function(pos, _, _, _)
50 local inv = minetest.get_meta(pos):get_inventory()
51 local honeystack = inv:get_stack("honey", 1)
52 local honey = honeystack:get_count()
55 local minp = vector.add(pos, -radius)
56 local maxp = vector.add(pos, radius)
57 local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
59 if #flowers >= 2 and honey < 10 then
60 inv:add_item("honey", "xdecor:honey") end