1
0
Fork 0

Sweetberry, nethervines: Fix placing in protected area

csm-enabled
cora 2022-11-28 11:43:09 +01:00
parent 17f789550d
commit 34a558ced9
2 changed files with 30 additions and 6 deletions

View File

@ -116,14 +116,20 @@ minetest.register_node("mcl_crimson:twisting_vines", {
fixed = { -3/16, -0.5, -3/16, 3/16, 0.5, 3/16 },
},
node_placement_prediction = "",
on_rightclick = function(pos, node, pointed_thing, itemstack)
if pointed_thing:get_wielded_item():get_name() == "mcl_crimson:twisting_vines" then
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local pn = clicker:get_player_name()
if clicker:is_player() and minetest.is_protected(vector.offset(pos,0,1,0), pn) then
minetest.record_protection_violation(vector.offset(pos,0,1,0), pn)
return itemstack
end
if clicker:get_wielded_item():get_name() == "mcl_crimson:twisting_vines" then
itemstack:take_item()
grow_vines(pos, 1, "mcl_crimson:twisting_vines")
elseif pointed_thing:get_wielded_item():get_name() == "mcl_dye:white" then
elseif clicker:get_wielded_item():get_name() == "mcl_dye:white" then
itemstack:take_item()
grow_vines(pos, math.random(1, 3),"mcl_crimson:twisting_vines")
end
return itemstack
end,
drop = {
max_items = 1,
@ -162,14 +168,20 @@ minetest.register_node("mcl_crimson:weeping_vines", {
fixed = { -3/16, -0.5, -3/16, 3/16, 0.5, 3/16 },
},
node_placement_prediction = "",
on_rightclick = function(pos, node, pointed_thing, itemstack)
if pointed_thing:get_wielded_item():get_name() == "mcl_crimson:weeping_vines" then
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
local pn = clicker:get_player_name()
if clicker:is_player() and minetest.is_protected(vector.offset(pos,0,1,0), pn) then
minetest.record_protection_violation(vector.offset(pos,0,1,0), pn)
return itemstack
end
if clicker:get_wielded_item():get_name() == "mcl_crimson:weeping_vines" then
itemstack:take_item()
grow_vines(pos, 1, "mcl_crimson:weeping_vines", -1)
elseif pointed_thing:get_wielded_item():get_name() == "mcl_dye:white" then
elseif clicker:get_wielded_item():get_name() == "mcl_dye:white" then
itemstack:take_item()
grow_vines(pos, math.random(1, 3),"mcl_crimson:weeping_vines", -1)
end
return itemstack
end,
drop = {
max_items = 1,

View File

@ -36,8 +36,14 @@ for i=0, 3 do
_mcl_blast_resistance = 0,
_mcl_hardness = 0,
on_rightclick = function(pos, node, 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 mcl_dye and clicker:get_wielded_item():get_name() == "mcl_dye:white" then
mcl_dye.apply_bone_meal({under=pos},clicker)
itemstack:take_item()
return
end
local stage
@ -52,6 +58,7 @@ for i=0, 3 do
end
minetest.swap_node(pos,{name = "mcl_farming:sweet_berry_bush_" .. stage - 1 })
end
return itemstack
end,
})
minetest.register_alias("mcl_sweet_berry:sweet_berry_bush_" .. i, node_name)
@ -64,6 +71,11 @@ minetest.register_craftitem("mcl_farming:sweet_berry", {
groups = { food = 2, eatable = 1, compostability=30 },
on_secondary_use = minetest.item_eat(1),
on_place = function(itemstack, placer, pointed_thing)
local pn = placer:get_player_name()
if placer:is_player() and minetest.is_protected(pointed_thing.above, pn) then
minetest.record_protection_violation(pointed_thing.above, pn)
return itemstack
end
if pointed_thing.type == "node" and table.indexof(planton,minetest.get_node(pointed_thing.under).name) ~= -1 and minetest.get_node(pointed_thing.above).name == "air" then
minetest.set_node(pointed_thing.above,{name="mcl_farming:sweet_berry_bush_0"})
if not minetest.is_creative_enabled(placer:get_player_name()) then