1
0
Fork 0

Merge pull request 'Sweetberry, nethervines: Fix placing in protected area' (#3038) from fix_sweet_berry_protection into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/3038
csm-enabled
cora 2022-11-29 11:21:14 +00:00
commit 85e7de6c14
2 changed files with 42 additions and 10 deletions

View File

@ -116,14 +116,24 @@ 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 or "") 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
if not minetest.is_creative_enabled(clicker:get_player_name()) then
itemstack:take_item()
end
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
if not minetest.is_creative_enabled(clicker:get_player_name()) then
itemstack:take_item()
end
grow_vines(pos, math.random(1, 3),"mcl_crimson:twisting_vines")
end
return itemstack
end,
drop = {
max_items = 1,
@ -162,14 +172,24 @@ 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 or "") 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
if not minetest.is_creative_enabled(clicker:get_player_name()) then
itemstack:take_item()
end
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
if not minetest.is_creative_enabled(clicker:get_player_name()) then
itemstack:take_item()
end
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 or "") 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