2020-04-20 20:22:07 +03:00
|
|
|
|
2020-04-21 22:54:54 +10:00
|
|
|
-- Dig beehives while keeping inventory count information.
|
|
|
|
-- Add centrifuge recipe for beehives with honey in inventory.
|
2020-04-20 20:22:07 +03:00
|
|
|
|
2020-04-21 22:54:54 +10:00
|
|
|
local S = mobs.intllib
|
2020-04-20 20:22:07 +03:00
|
|
|
|
2020-04-21 22:54:54 +10:00
|
|
|
minetest.override_item("mobs:beehive", {
|
|
|
|
on_dig = function(pos, node, digger)
|
2020-04-23 16:06:58 +02:00
|
|
|
if digger and minetest.is_protected(pos, digger:get_player_name()) then
|
2020-04-21 22:54:54 +10:00
|
|
|
return
|
|
|
|
end
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
local honey = inv:get_stack("beehive", 1):get_count()
|
|
|
|
local stack = "mobs:beehive"
|
|
|
|
if honey > 0 then
|
|
|
|
stack = stack .. "_" .. honey
|
|
|
|
end
|
|
|
|
minetest.handle_node_drops(pos, {stack}, digger)
|
|
|
|
minetest.remove_node(pos)
|
|
|
|
end,
|
|
|
|
})
|
2020-04-20 20:22:07 +03:00
|
|
|
|
2020-04-21 22:54:54 +10:00
|
|
|
-- register beehive items and technic recipes
|
|
|
|
for i = 1, 12 do
|
|
|
|
minetest.register_craftitem(":mobs:beehive_" .. i, {
|
|
|
|
description = S("Beehive") .. ": " .. S("Honey") .. string.format(" %d/12", i),
|
|
|
|
inventory_image = "mobs_beehive.png",
|
|
|
|
groups = {oddly_breakable_by_hand = 3, flammable = 1, not_in_creative_inventory=1},
|
|
|
|
on_place = function(itemstack, placer, pointed_thing)
|
|
|
|
local _,pos = minetest.item_place(ItemStack("mobs:beehive"), placer, pointed_thing)
|
|
|
|
if pos then
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local inv = meta:get_inventory()
|
|
|
|
local name = itemstack:get_name()
|
|
|
|
inv:add_item("beehive", "mobs:honey " .. string.sub(name, 14))
|
|
|
|
itemstack:take_item(1)
|
|
|
|
end
|
|
|
|
return itemstack
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
technic.register_separating_recipe({
|
|
|
|
input = {"mobs:beehive_" .. i .. " 1"},
|
|
|
|
output = {"mobs:beehive", "mobs:honey " .. i},
|
|
|
|
time = ( i + 2 ) * 3 - i
|
|
|
|
})
|
2020-04-20 20:22:07 +03:00
|
|
|
end
|