1
0
鏡像自 https://github.com/minetest-mods/technic.git 已同步 2025-09-18 13:40:35 +02:00

Fix cable plate placement (#446)

Cable plate placement now uses minetest.item_place
此提交包含在:
12Me21
2018-11-23 14:25:32 -05:00
提交者 SmallJoker
父節點 3d52b679b0
當前提交 8409be32fc

查看文件

@@ -117,6 +117,19 @@ local function clear_networks(pos)
end
end
local function item_place_override_node(itemstack, placer, pointed, node)
-- Call the default on_place function with a fake itemstack
local temp_itemstack = ItemStack(itemstack)
temp_itemstack:set_name(node.name)
local original_count = temp_itemstack:get_count()
temp_itemstack =
minetest.item_place(temp_itemstack, placer, pointed, node.param2) or
temp_itemstack
-- Remove the same number of items from the real itemstack
itemstack:take_item(original_count - temp_itemstack:get_count())
return itemstack
end
function technic.register_cable(tier, size)
local ltier = string.lower(tier)
cable_tier["technic:"..ltier.."_cable"] = tier
@@ -228,11 +241,10 @@ function technic.register_cable(tier, size)
num = xyz[((fine_pointed[bigger] < 0 and "-") or "") .. bigger]
end
end
minetest.set_node(pointed_thing.above, {name = "technic:"..ltier.."_cable_plate_"..num})
if not (creative and creative.is_enabled_for(placer)) then
itemstack:take_item()
end
return itemstack
return item_place_override_node(
itemstack, placer, pointed_thing,
{name = "technic:"..ltier.."_cable_plate_"..num}
)
end
else
def.groups.not_in_creative_inventory = 1