4 function hive.construct(pos)
5 local meta = minetest.get_meta(pos)
6 local inv = meta:get_inventory()
8 local formspec = [[ size[8,5;]
9 label[0.5,0;Bees are busy making honey...]
10 image[6,0;1,1;hive_bee.png]
11 image[5,0;1,1;hive_layout.png]
12 list[context;honey;5,0;1,1;]
13 list[current_player;main;0,1.35;8,4;]
14 listring[current_player;main]
15 listring[context;honey] ]] ..
16 xbg .. default.get_hotbar_bg(0,1.35)
18 meta:set_string("formspec", formspec)
19 meta:set_string("infotext", "Artificial Hive")
20 inv:set_size("honey", 1)
22 local timer = minetest.get_node_timer(pos)
23 timer:start(math.random(64, 128))
26 function hive.timer(pos)
27 local time = (minetest.get_timeofday() or 0) * 24000
28 if time < 5500 or time > 18500 then
32 local inv = minetest.get_meta(pos):get_inventory()
33 local honeystack = inv:get_stack("honey", 1)
34 local honey = honeystack:get_count()
37 local minp = vector.add(pos, -radius)
38 local maxp = vector.add(pos, radius)
39 local flowers = minetest.find_nodes_in_area_under_air(minp, maxp, "group:flower")
41 if #flowers > 2 and honey < honey_max then
42 inv:add_item("honey", "xdecor:honey")
43 elseif honey == honey_max then
44 local timer = minetest.get_node_timer(pos)
52 xdecor.register("hive", {
53 description = "Artificial Hive",
54 tiles = {"xdecor_hive_top.png", "xdecor_hive_top.png",
55 "xdecor_hive_side.png", "xdecor_hive_side.png",
56 "xdecor_hive_side.png", "xdecor_hive_front.png"},
57 groups = {choppy=3, oddly_breakable_by_hand=2, flammable=1},
58 on_construct = hive.construct,
59 on_timer = hive.timer,
61 can_dig = function(pos)
62 local inv = minetest.get_meta(pos):get_inventory()
63 return inv:is_empty("honey")
66 on_punch = function(_, _, puncher)
67 puncher:set_hp(puncher:get_hp() - 2)
70 allow_metadata_inventory_put = function()
74 on_metadata_inventory_take = function(pos, _, _, stack)
75 if stack:get_count() == honey_max then
76 local timer = minetest.get_node_timer(pos)
77 timer:start(math.random(64, 128))
84 minetest.register_craftitem("xdecor:honey", {
85 description = "Honey",
86 inventory_image = "xdecor_honey.png",
87 wield_image = "xdecor_honey.png",
88 on_use = minetest.item_eat(2),
93 not_in_creative_inventory = 1,
99 minetest.register_craft({
100 output = "xdecor:hive",
102 {"group:stick", "group:stick", "group:stick"},
103 {"default:paper", "default:paper", "default:paper"},
104 {"group:stick", "group:stick", "group:stick"}