mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-01-08 16:19:37 +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
|
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)
|
function mcl_util.calculate_durability(itemstack)
|
||||||
local unbreaking_level = mcl_enchanting.get_enchantment(itemstack, "unbreaking")
|
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",
|
inventory_image = "mcl_bone_meal.png",
|
||||||
groups = {craftitem=1},
|
groups = {craftitem=1},
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
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.
|
-- Use pointed node's on_rightclick function first, if present.
|
||||||
if placer and not placer:get_player_control().sneak then
|
local called
|
||||||
if ndef and ndef.on_rightclick then
|
itemstack, called = mcl_util.handle_node_rightclick(itemstack, placer, pointed_thing)
|
||||||
local new_stack = mcl_util.call_on_rightclick(itemstack, placer, pointed_thing)
|
if called then return itemstack end
|
||||||
if new_stack and new_stack ~= itemstack then return new_stack end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return mcl_bone_meal.use_bone_meal(itemstack, placer, pointed_thing)
|
return mcl_bone_meal.use_bone_meal(itemstack, placer, pointed_thing)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
name = mcl_farming
|
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
|
optional_depends = mcl_armor, doc
|
||||||
|
|
|
@ -14,19 +14,21 @@ for i=0, 3 do
|
||||||
|
|
||||||
local on_bonemealing = nil
|
local on_bonemealing = nil
|
||||||
local function do_berry_drop(pos)
|
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")
|
minetest.add_item(pos, "mcl_farming:sweet_berry")
|
||||||
end
|
end
|
||||||
minetest.swap_node(pos, {name = "mcl_farming:sweet_berry_bush_1"})
|
minetest.swap_node(pos, {name = "mcl_farming:sweet_berry_bush_1"})
|
||||||
end
|
end
|
||||||
if i ~= 3 then
|
if i ~= 3 then
|
||||||
on_bonemealing = function(itemstack, placer, pointed_thing)
|
on_bonemealing = function(_, _, pointed_thing)
|
||||||
local pos = pointed_thing.under
|
local pos = pointed_thing.under
|
||||||
local node = minetest.get_node(pos)
|
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
|
end
|
||||||
else
|
else
|
||||||
on_bonemealing = function(itemstack, placer, pointed_thing)
|
on_bonemealing = function(_, _, pointed_thing)
|
||||||
do_berry_drop(pointed_thing.under)
|
do_berry_drop(pointed_thing.under)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,20 +67,12 @@ for i=0, 3 do
|
||||||
_mcl_blast_resistance = 0,
|
_mcl_blast_resistance = 0,
|
||||||
_mcl_hardness = 0,
|
_mcl_hardness = 0,
|
||||||
_on_bone_meal = on_bonemealing,
|
_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()
|
local pn = clicker:get_player_name()
|
||||||
if clicker:is_player() and minetest.is_protected(pos, pn) then
|
if clicker:is_player() and minetest.is_protected(pos, pn) then
|
||||||
minetest.record_protection_violation(pos, pn)
|
minetest.record_protection_violation(pos, pn)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
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
|
if i >= 2 then
|
||||||
do_berry_drop(pos)
|
do_berry_drop(pos)
|
||||||
|
|
Loading…
Reference in a new issue