1 local function hive_construct(pos)
2 local meta = minetest.get_meta(pos)
3 meta:set_string("formspec", "size[8,5;]"..xdecor.fancy_gui..
4 "label[1.35,0;Bees are making honey\nwith pollen around...]"..
5 "image[-0.1,-0.2;1,1;flowers_tulip.png]"..
6 "image[0.5,0.2;1,1;flowers_dandelion_yellow.png]"..
7 "image[6.6,0.1;1,1;flowers_geranium.png]"..
8 "image[7.2,-0.1;1,1;flowers_rose.png]"..
9 "image[6,0;0.9,0.9;xdecor_bee.png]".. -- Bee texture by Charles Sanchez and Mark Weyer.
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 local function hive_dig(pos, player)
18 local meta = minetest.get_meta(pos)
19 local inv = meta:get_inventory()
21 if not inv:is_empty("honey") then
27 xdecor.register("hive", {
28 description = "Artificial Hive",
30 "xdecor_hive_top.png",
31 "xdecor_hive_top.png",
32 "xdecor_hive_side.png",
33 "xdecor_hive_side.png",
34 "xdecor_hive_side.png",
35 "xdecor_hive_front.png",
37 groups = {snappy=3, flammable=1},
38 on_construct = hive_construct,
40 on_punch = function(pos, node, puncher, pointed_thing)
41 local health = puncher:get_hp()
42 puncher:set_hp(health-4)
44 allow_metadata_inventory_put = function(pos, listname, index, stack, player)
45 local meta = minetest.get_meta(pos)
46 local inv = meta:get_inventory()
48 if listname == "honey" then return 0 end
49 return stack:get_count()
53 minetest.register_abm({
54 nodenames = {"xdecor:hive"},
55 interval = 4, chance = 4,
56 action = function(pos, node, active_object_count, active_object_count_wider)
57 local meta = minetest.get_meta(pos)
58 local inv = meta:get_inventory()
61 local minp = {x=pos.x-radius, y=pos.y-radius, z=pos.z-radius}
62 local maxp = {x=pos.x+radius, y=pos.y+radius, z=pos.z+radius}
63 local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
66 inv:add_item("honey", "xdecor:honey")