mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-08-19 21:44:12 +02:00
Add harvest and digging damage, and campfire usage
Damage is temporary until bees are implemented
This commit is contained in:
parent
a79692a68b
commit
8a3c1eaa6e
@ -8,7 +8,10 @@ local S = minetest.get_translator(minetest.get_current_modname())
|
||||
-- Function to allow harvesting honey and honeycomb from the beehive and bee nest.
|
||||
local honey_harvest = function(pos, node, player, itemstack, pointed_thing)
|
||||
local inv = player:get_inventory()
|
||||
local shears = player:get_wielded_item():get_name() == "mcl_tools:shears"
|
||||
local bottle = player:get_wielded_item():get_name() == "mcl_potions:glass_bottle"
|
||||
local beehive = "mcl_beehives:beehive"
|
||||
local is_creative = minetest.is_creative_enabled(player:get_player_name())
|
||||
|
||||
if node.name == "mcl_beehives:beehive_5" then
|
||||
beehive = "mcl_beehives:beehive"
|
||||
@ -16,20 +19,45 @@ local honey_harvest = function(pos, node, player, itemstack, pointed_thing)
|
||||
beehive = "mcl_beehives:bee_nest"
|
||||
end
|
||||
|
||||
if player:get_wielded_item():get_name() == "mcl_potions:glass_bottle" then
|
||||
local campfire_area = vector.offset(pos, 0, -5, 0)
|
||||
local campfire = minetest.find_nodes_in_area(pos, campfire_area, "group:lit_campfire")
|
||||
|
||||
if bottle then
|
||||
local honey = "mcl_honey:honey_bottle"
|
||||
if inv:room_for_item("main", honey) then
|
||||
node.name = beehive
|
||||
minetest.set_node(pos, node)
|
||||
inv:add_item("main", "mcl_honey:honey_bottle")
|
||||
if not minetest.is_creative_enabled(player:get_player_name()) then
|
||||
if not is_creative then
|
||||
itemstack:take_item()
|
||||
end
|
||||
if not campfire[1] then mcl_util.deal_damage(player, 10) end
|
||||
end
|
||||
elseif player:get_wielded_item():get_name() == "mcl_tools:shears" then
|
||||
elseif shears then
|
||||
minetest.add_item(pos, "mcl_honey:honeycomb 3")
|
||||
node.name = beehive
|
||||
minetest.set_node(pos, node)
|
||||
if not campfire[1] then mcl_util.deal_damage(player, 10) end
|
||||
end
|
||||
end
|
||||
|
||||
-- Dig Function for Beehives
|
||||
local dig_hive = function(pos, node, oldmetadata, digger)
|
||||
local wield_item = digger:get_wielded_item()
|
||||
local beehive = string.find(node.name, "mcl_beehives:beehive")
|
||||
local beenest = string.find(node.name, "mcl_beehives:bee_nest")
|
||||
local silk_touch = mcl_enchanting.has_enchantment(wield_item, "silk_touch")
|
||||
local is_creative = minetest.is_creative_enabled(digger:get_player_name())
|
||||
|
||||
if beehive then
|
||||
minetest.add_item(pos, "mcl_beehives:beehive")
|
||||
if not silk_touch and not is_creative then mcl_util.deal_damage(digger, 10) end
|
||||
elseif beenest then
|
||||
if silk_touch or is_creative then
|
||||
minetest.add_item(pos, "mcl_beehives:bee_nest")
|
||||
else
|
||||
mcl_util.deal_damage(digger, 10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -46,22 +74,25 @@ minetest.register_node("mcl_beehives:beehive", {
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, beehive = 1 },
|
||||
_mcl_blast_resistance = 0.6,
|
||||
_mcl_hardness = 0.6,
|
||||
drop = "",
|
||||
after_dig_node = dig_hive,
|
||||
})
|
||||
|
||||
for l = 1, 4 do
|
||||
minetest.register_node("mcl_beehives:beehive_" .. l, {
|
||||
description = S("Beehive"),
|
||||
_doc_items_longdesc = S("Artificial bee nest."),
|
||||
tiles = {
|
||||
"mcl_beehives_beehive_end.png", "mcl_beehives_beehive_end.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_side.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, not_in_creative_inventory = 1, beehive = 1 },
|
||||
_mcl_blast_resistance = 0.6,
|
||||
_mcl_hardness = 0.6,
|
||||
drops = "mcl_beehives:beehive",
|
||||
description = S("Beehive"),
|
||||
_doc_items_longdesc = S("Artificial bee nest."),
|
||||
tiles = {
|
||||
"mcl_beehives_beehive_end.png", "mcl_beehives_beehive_end.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_side.png",
|
||||
"mcl_beehives_beehive_side.png", "mcl_beehives_beehive_front.png",
|
||||
},
|
||||
paramtype2 = "facedir",
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, not_in_creative_inventory = 1, beehive = 1 },
|
||||
_mcl_blast_resistance = 0.6,
|
||||
_mcl_hardness = 0.6,
|
||||
drop = "",
|
||||
after_dig_node = dig_hive,
|
||||
})
|
||||
end
|
||||
|
||||
@ -77,8 +108,9 @@ minetest.register_node("mcl_beehives:beehive_5", {
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 5, material_wood = 1, not_in_creative_inventory = 1, beehive = 1 },
|
||||
_mcl_blast_resistance = 0.6,
|
||||
_mcl_hardness = 0.6,
|
||||
drops = "mcl_beehives:beehive",
|
||||
on_rightclick = honey_harvest,
|
||||
drop = "",
|
||||
after_dig_node = dig_hive,
|
||||
})
|
||||
|
||||
-- Bee Nest
|
||||
@ -94,6 +126,8 @@ minetest.register_node("mcl_beehives:bee_nest", {
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 30, bee_nest = 1 },
|
||||
_mcl_blast_resistance = 0.3,
|
||||
_mcl_hardness = 0.3,
|
||||
drop = "",
|
||||
after_dig_node = dig_hive,
|
||||
})
|
||||
|
||||
for i = 1, 4 do
|
||||
@ -109,7 +143,8 @@ for i = 1, 4 do
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 30, not_in_creative_inventory = 1, bee_nest = 1 },
|
||||
_mcl_blast_resistance = 0.3,
|
||||
_mcl_hardness = 0.3,
|
||||
drops = "mcl_beehives:bee_nest",
|
||||
drop = "",
|
||||
after_dig_node = dig_hive,
|
||||
})
|
||||
end
|
||||
|
||||
@ -125,8 +160,9 @@ minetest.register_node("mcl_beehives:bee_nest_5", {
|
||||
groups = { axey = 1, deco_block = 1, flammable = 0, fire_flammability = 30, not_in_creative_inventory = 1, bee_nest = 1 },
|
||||
_mcl_blast_resistance = 0.3,
|
||||
_mcl_hardness = 0.3,
|
||||
drops = "mcl_beehives:bee_nest",
|
||||
on_rightclick = honey_harvest,
|
||||
drop = "",
|
||||
after_dig_node = dig_hive,
|
||||
})
|
||||
|
||||
-- Crafting
|
||||
|
@ -1,3 +1,4 @@
|
||||
name = mcl_beehives
|
||||
author = PrairieWind
|
||||
description = Adds beehives and bee nests to MineClone 2.
|
||||
description = Adds beehives and bee nests to MineClone 2.
|
||||
depends = mcl_util, mcl_enchanting
|
||||
|
Loading…
Reference in New Issue
Block a user