mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-12-25 02:42:25 +01:00
Node on_rightclick: bed, bucket, lilypad, sign
This commit is contained in:
parent
9cb2f5b392
commit
b31405307d
@ -47,6 +47,15 @@ function beds.register_bed(name, def)
|
|||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
|
|
||||||
|
-- Use pointed node's on_rightclick function first, if present
|
||||||
|
local node = minetest.get_node(under)
|
||||||
|
if placer and not placer:get_player_control().sneak then
|
||||||
|
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||||
|
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local pos
|
local pos
|
||||||
if minetest.registered_items[minetest.get_node(under).name].buildable_to then
|
if minetest.registered_items[minetest.get_node(under).name].buildable_to then
|
||||||
pos = under
|
pos = under
|
||||||
|
@ -141,9 +141,17 @@ minetest.register_craftitem("bucket:bucket_empty", {
|
|||||||
if pointed_thing.type ~= "node" then
|
if pointed_thing.type ~= "node" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
-- Check if pointing to a liquid source
|
|
||||||
|
-- Call on_rightclick if the pointed node defines it
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
local nn = node.name
|
local nn = node.name
|
||||||
|
if user and not user:get_player_control().sneak then
|
||||||
|
if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then
|
||||||
|
return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Check if pointing to a liquid source
|
||||||
liquiddef = bucket.liquids[nn]
|
liquiddef = bucket.liquids[nn]
|
||||||
local new_bucket
|
local new_bucket
|
||||||
if liquiddef ~= nil and liquiddef.itemname ~= nil and (nn == liquiddef.source or
|
if liquiddef ~= nil and liquiddef.itemname ~= nil and (nn == liquiddef.source or
|
||||||
|
@ -295,18 +295,25 @@ minetest.register_node("mcl_flowers:waterlily", {
|
|||||||
|
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
local node = minetest.get_node(pointed_thing.under).name
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
local def = minetest.registered_nodes[node]
|
local nodename = node.name
|
||||||
|
local def = minetest.registered_nodes[nodename]
|
||||||
local node_above = minetest.get_node(pointed_thing.above).name
|
local node_above = minetest.get_node(pointed_thing.above).name
|
||||||
local def_above = minetest.registered_nodes[node_above]
|
local def_above = minetest.registered_nodes[node_above]
|
||||||
local player_name = placer:get_player_name()
|
local player_name = placer:get_player_name()
|
||||||
|
|
||||||
if def and
|
if def then
|
||||||
pointed_thing.under.x == pointed_thing.above.x and
|
-- Use pointed node's on_rightclick function first, if present
|
||||||
pointed_thing.under.z == pointed_thing.above.z then
|
if placer and not placer:get_player_control().sneak then
|
||||||
if ((def.liquidtype == "source" and minetest.get_item_group(node, "water") > 0) or
|
if def and def.on_rightclick then
|
||||||
(node == "mcl_core:ice") or
|
return def.on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||||
(minetest.get_item_group(node, "frosted_ice") > 0)) and
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if (pointed_thing.under.x == pointed_thing.above.x and pointed_thing.under.z == pointed_thing.above.z) and
|
||||||
|
((def.liquidtype == "source" and minetest.get_item_group(nodename, "water") > 0) or
|
||||||
|
(nodename == "mcl_core:ice") or
|
||||||
|
(minetest.get_item_group(nodename, "frosted_ice") > 0)) and
|
||||||
(def_above.buildable_to and minetest.get_item_group(node_above, "liquid") == 0) then
|
(def_above.buildable_to and minetest.get_item_group(node_above, "liquid") == 0) then
|
||||||
if not minetest.is_protected(pos, player_name) then
|
if not minetest.is_protected(pos, player_name) then
|
||||||
minetest.set_node(pos, {name = "mcl_flowers:waterlily",
|
minetest.set_node(pos, {name = "mcl_flowers:waterlily",
|
||||||
|
@ -207,6 +207,15 @@ minetest.register_node("signs:sign_wall", {
|
|||||||
on_place = function(itemstack, placer, pointed_thing)
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
local above = pointed_thing.above
|
local above = pointed_thing.above
|
||||||
local under = pointed_thing.under
|
local under = pointed_thing.under
|
||||||
|
|
||||||
|
-- Use pointed node's on_rightclick function first, if present
|
||||||
|
local node = minetest.get_node(under)
|
||||||
|
if placer and not placer:get_player_control().sneak then
|
||||||
|
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
|
||||||
|
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local dir = {x = under.x - above.x,
|
local dir = {x = under.x - above.x,
|
||||||
y = under.y - above.y,
|
y = under.y - above.y,
|
||||||
z = under.z - above.z}
|
z = under.z - above.z}
|
||||||
|
Loading…
Reference in New Issue
Block a user