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.1,-0.2;1,1;flowers_tulip.png]"..
8 "image[0.5,0.2;1,1;flowers_dandelion_yellow.png]"..
9 "image[6.6,0.1;1,1;flowers_geranium.png]"..
10 "image[7.2,-0.1;1,1;flowers_rose.png]"..
11 "image[6,0;0.9,0.9;xdecor_bee.png]".. -- Bee texture by Charles Sanchez and Mark Weyer.
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, player)
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",
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 if listname == "honey" then return 0 end
46 return stack:get_count()
50 minetest.register_abm({
51 nodenames = {"xdecor:hive"},
52 interval = 4, chance = 4,
53 action = function(pos, node, active_object_count, active_object_count_wider)
54 local meta = minetest.get_meta(pos)
55 local inv = meta:get_inventory()
58 local minp = {x=pos.x-radius, y=pos.y-radius, z=pos.z-radius}
59 local maxp = {x=pos.x+radius, y=pos.y+radius, z=pos.z+radius}
60 local flowers = minetest.find_nodes_in_area(minp, maxp, "group:flower")
62 if #flowers >= 4 then inv:add_item("honey", "xdecor:honey") end