mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-01-07 15:49:32 +01:00
Fix sweetberry bonemealing crash, fix sweetberry growth, fix double bonemeal usage
This commit is contained in:
parent
bf7017cfe7
commit
d7bb017dca
4 changed files with 26 additions and 24 deletions
|
@ -343,6 +343,21 @@ function mcl_util.call_on_rightclick(itemstack, player, pointed_thing)
|
|||
end
|
||||
end
|
||||
end
|
||||
function mcl_util.handle_node_rightclick(itemstack, player, pointed_thing)
|
||||
-- Call on_rightclick if the pointed node defines it
|
||||
if pointed_thing and pointed_thing.type == "node" then
|
||||
local pos = pointed_thing.under
|
||||
local node = minetest.get_node(pos)
|
||||
if player and not player:get_player_control().sneak then
|
||||
local nodedef = minetest.registered_nodes[node.name]
|
||||
local on_rightclick = nodedef and nodedef.on_rightclick
|
||||
if on_rightclick then
|
||||
return on_rightclick(pos, node, player, itemstack, pointed_thing) or itemstack, true
|
||||
end
|
||||
end
|
||||
end
|
||||
return itemstack, false
|
||||
end
|
||||
|
||||
function mcl_util.calculate_durability(itemstack)
|
||||
local unbreaking_level = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
||||
|
|
|
@ -123,17 +123,10 @@ minetest.register_craftitem("mcl_bone_meal:bone_meal", {
|
|||
inventory_image = "mcl_bone_meal.png",
|
||||
groups = {craftitem=1},
|
||||
on_place = function(itemstack, placer, pointed_thing)
|
||||
local pos = pointed_thing.under
|
||||
local node = minetest.get_node(pos)
|
||||
local ndef = minetest.registered_nodes[node.name]
|
||||
|
||||
-- Use pointed node's on_rightclick function first, if present.
|
||||
if placer and not placer:get_player_control().sneak then
|
||||
if ndef and ndef.on_rightclick then
|
||||
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
|
||||
if new_stack and new_stack ~= itemstack then return new_stack end
|
||||
end
|
||||
end
|
||||
local called
|
||||
itemstack, called = mcl_util.handle_node_rightclick(itemstack, placer, pointed_thing)
|
||||
if called then return itemstack end
|
||||
|
||||
return mcl_bone_meal.use_bone_meal(itemstack, placer, pointed_thing)
|
||||
end,
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
name = mcl_farming
|
||||
depends = mcl_core, mcl_sounds, mcl_wool, mcl_torches, mcl_weather, mobs_mc, mcl_colors, mcl_init
|
||||
depends = mcl_core, mcl_sounds, mcl_wool, mcl_torches, mcl_weather, mobs_mc, mcl_colors, mcl_init, mcl_bone_meal
|
||||
optional_depends = mcl_armor, doc
|
||||
|
|
|
@ -14,19 +14,21 @@ for i=0, 3 do
|
|||
|
||||
local on_bonemealing = nil
|
||||
local function do_berry_drop(pos)
|
||||
for j=1, berries_to_drop[math.random(2)] do
|
||||
if not berries_to_drop then return end
|
||||
|
||||
for _=1, berries_to_drop[math.random(2)] do
|
||||
minetest.add_item(pos, "mcl_farming:sweet_berry")
|
||||
end
|
||||
minetest.swap_node(pos, {name = "mcl_farming:sweet_berry_bush_1"})
|
||||
end
|
||||
if i ~= 3 then
|
||||
on_bonemealing = function(itemstack, placer, pointed_thing)
|
||||
on_bonemealing = function(_, _, pointed_thing)
|
||||
local pos = pointed_thing.under
|
||||
local node = minetest.get_node(pos)
|
||||
return mcl_farming:grow_plant("plant_sweet_berry_bush", pos, node, 0, true)
|
||||
return mcl_farming:grow_plant("plant_sweet_berry_bush", pos, node, 1, true)
|
||||
end
|
||||
else
|
||||
on_bonemealing = function(itemstack, placer, pointed_thing)
|
||||
on_bonemealing = function(_, _, pointed_thing)
|
||||
do_berry_drop(pointed_thing.under)
|
||||
end
|
||||
end
|
||||
|
@ -65,20 +67,12 @@ for i=0, 3 do
|
|||
_mcl_blast_resistance = 0,
|
||||
_mcl_hardness = 0,
|
||||
_on_bone_meal = on_bonemealing,
|
||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||
on_rightclick = function(pos, _, clicker, itemstack, pointed_thing)
|
||||
local pn = clicker:get_player_name()
|
||||
if clicker:is_player() and minetest.is_protected(pos, pn) then
|
||||
minetest.record_protection_violation(pos, pn)
|
||||
return itemstack
|
||||
end
|
||||
if 3 ~= i and mcl_dye and
|
||||
clicker:get_wielded_item():get_name() == "mcl_bone_meal:bone_meal" then
|
||||
mcl_dye.apply_bone_meal({under=pos, above=vector.offset(pos,0,1,0)},clicker)
|
||||
if not minetest.is_creative_enabled(pn) then
|
||||
itemstack:take_item()
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if i >= 2 then
|
||||
do_berry_drop(pos)
|
||||
|
|
Loading…
Reference in a new issue