Fix placing fishbuckets to actually replace buildable_to

This commit is contained in:
cora 2023-09-03 20:44:57 +02:00 committed by MrRar
parent 12727a6a0a
commit 0a47814383
1 changed files with 15 additions and 8 deletions

View File

@ -18,14 +18,21 @@ local function on_place_fish(itemstack, placer, pointed_thing)
return new_stack
end
local pos = pointed_thing.above or pointed_thing.under
if not pos then return end
local n = minetest.get_node_or_nil(pos)
local def = minetest.registered_nodes[n.name]
if def and def.buildable_to or n.name == "mcl_portals:portal" then
local fish = itemstack:get_name():gsub(fishbucket_prefix,"")
if fish_names[fish] then
local o = minetest.add_entity(pos, "mobs_mc:" .. fish)
if pointed_thing.type ~= "node" then return end
local pos = pointed_thing.above
local n = minetest.get_node(pointed_thing.above)
local def = minetest.registered_nodes[minetest.get_node(pointed_thing.under).name]
if ( def and def.buildable_to ) or n.name == "mcl_portals:portal" then
pos = pointed_thing.under
n = minetest.get_node(pointed_thing.under)
end
local fish = itemstack:get_name():gsub(fishbucket_prefix,"")
if fish_names[fish] then
local o = minetest.add_entity(pos, "mobs_mc:" .. fish)
if o and o:get_pos() then
local props = itemstack:get_meta():get_string("properties")
if props ~= "" then
o:set_properties(minetest.deserialize(props))