3 function hive.construct(pos)
4 local meta = minetest.get_meta(pos)
5 meta:set_string("formspec", "size[8,5;]"..xdecor.fancy_gui..
6 "label[1.35,0;Bees are making honey\nwith pollen around...]"..
7 "image[0.2,-0.1;1,1;flowers_dandelion_white.png]"..
8 "image[7,0.1;1,1;flowers_viola.png]"..
9 "image[6,0;1,1;xdecor_bee.png]"..
10 "list[current_name;honey;5,0;1,1;]"..
11 "list[current_player;main;0,1.35;8,4;]")
12 meta:set_string("infotext", "Artificial Hive")
13 local inv = meta:get_inventory()
14 inv:set_size("honey", 1)
17 function hive.dig(pos, _)
18 local meta = minetest.get_meta(pos)
19 local inv = meta:get_inventory()
21 if not inv:is_empty("honey") then return false end
25 xdecor.register("hive", {
26 description = "Artificial Hive",
28 "xdecor_hive_top.png", "xdecor_hive_top.png",
29 "xdecor_hive_side.png", "xdecor_hive_side.png",
30 "xdecor_hive_side.png", "xdecor_hive_front.png"
32 groups = {snappy=3, flammable=1},
33 on_construct = hive.construct,
35 on_punch = function(_, _, puncher, _)
36 local health = puncher:get_hp()
37 puncher:set_hp(health - 4)
39 allow_metadata_inventory_put = function(_, listname, _, stack, _)
40 if listname == "honey" then return 0 end
41 return stack:get_count()
45 minetest.register_abm({
46 nodenames = {"xdecor:hive"},
47 interval = 10, chance = 4,
48 action = function(pos, _, _, _)
49 local meta = minetest.get_meta(pos)
50 local inv = meta:get_inventory()
53 local minp = vector.add(pos, -radius)
54 local maxp = vector.add(pos, radius)
55 local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
57 if #flowers >= 4 then inv:add_item("honey", "xdecor:honey") end