3 function hive.construct(pos)
4 local meta = minetest.get_meta(pos)
5 local xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
7 meta:set_string("formspec", "size[8,5;]"..xbg..
8 "label[1.35,0;Bees are making honey\nwith pollen around...]"..
9 "image[0.2,-0.1;1,1;flowers_dandelion_white.png]"..
10 "image[7,0.1;1,1;flowers_viola.png]"..
11 "image[6,0;1,1;xdecor_bee.png]"..
12 "list[current_name;honey;5,0;1,1;]"..
13 "list[current_player;main;0,1.35;8,4;]")
14 meta:set_string("infotext", "Artificial Hive")
15 local inv = meta:get_inventory()
16 inv:set_size("honey", 1)
19 function hive.dig(pos, _)
20 local meta = minetest.get_meta(pos)
21 local inv = meta:get_inventory()
23 if not inv:is_empty("honey") then return false end
27 xdecor.register("hive", {
28 description = "Artificial Hive",
30 "xdecor_hive_top.png", "xdecor_hive_top.png",
31 "xdecor_hive_side.png", "xdecor_hive_side.png",
32 "xdecor_hive_side.png", "xdecor_hive_front.png"
34 groups = {snappy=3, flammable=1},
35 on_construct = hive.construct,
37 on_punch = function(_, _, puncher, _)
38 local health = puncher:get_hp()
39 puncher:set_hp(health - 4)
41 allow_metadata_inventory_put = function(_, listname, _, stack, _)
42 if listname == "honey" then return 0 end
43 return stack:get_count()
47 minetest.register_abm({
48 nodenames = {"xdecor:hive"},
49 interval = 10, chance = 5,
50 action = function(pos, _, _, _)
51 local meta = minetest.get_meta(pos)
52 local inv = meta:get_inventory()
53 local honeystack = inv:get_stack("honey", 1)
54 local honey = honeystack:get_count()
57 local minp = vector.add(pos, -radius)
58 local maxp = vector.add(pos, radius)
59 local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
61 if #flowers >= 4 and honey < 16 then
62 inv:add_item("honey", "xdecor:honey") end