Fix flowerpot placing

This commit is contained in:
MoNTE48 2020-03-28 16:47:12 +01:00
parent a25cef958a
commit 817296da00

View File

@ -132,6 +132,7 @@ inv.mesh = "flowerpot_inv.obj"
inv.tiles = {"flowerpot.png"}
inv.node_placement_prediction = ""
inv.on_place = function(itemstack, placer, pointed_thing)
if pointed_thing.type == "node" then
local under = pointed_thing.under
local node = minetest.get_node(under)
local node_def = minetest.registered_nodes[node.name]
@ -142,8 +143,17 @@ inv.on_place = function(itemstack, placer, pointed_thing)
pointed_thing) or itemstack
end
itemstack = minetest.item_place(ItemStack("flowerpot:empty"), placer, pointed_thing)
itemstack:set_name("flowerpot:pot")
local _, result = minetest.item_place(ItemStack("flowerpot:empty"),
placer, pointed_thing)
if result and not (creative and creative.is_enabled_for and
creative.is_enabled_for(placer)) then
itemstack:take_item()
minetest.sound_play({name = "default_place_node_hard", gain = 1},
{pos = pointed_thing.above})
end
end
return itemstack
end