2021-07-24 17:09:47 +03:00
|
|
|
mcl_item_id = {
|
|
|
|
mod_namespaces = {},
|
|
|
|
}
|
2021-07-23 19:12:43 +03:00
|
|
|
|
2024-05-02 07:21:52 +03:00
|
|
|
local game = "voxelibre"
|
2021-07-23 19:12:43 +03:00
|
|
|
|
|
|
|
function mcl_item_id.set_mod_namespace(modname, namespace)
|
|
|
|
local namespace = namespace or modname
|
2021-07-24 17:09:47 +03:00
|
|
|
mcl_item_id.mod_namespaces[modname] = namespace
|
2021-07-23 19:12:43 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
function mcl_item_id.get_mod_namespace(modname)
|
2021-07-24 17:09:47 +03:00
|
|
|
local namespace = mcl_item_id.mod_namespaces[modname]
|
2021-07-23 19:12:43 +03:00
|
|
|
if namespace then
|
|
|
|
return namespace
|
|
|
|
else
|
2021-07-24 17:09:47 +03:00
|
|
|
return game
|
2021-07-23 19:12:43 +03:00
|
|
|
end
|
|
|
|
end
|
2021-07-18 20:21:53 +03:00
|
|
|
|
|
|
|
local same_id = {
|
2021-07-24 17:09:47 +03:00
|
|
|
enchanting = { "table" },
|
|
|
|
experience = { "bottle" },
|
2024-05-12 07:21:37 +03:00
|
|
|
heads = { "skeleton", "zombie", "stalker", "wither_skeleton" },
|
2021-07-18 20:21:53 +03:00
|
|
|
mobitems = { "rabbit", "chicken" },
|
|
|
|
walls = {
|
|
|
|
"andesite", "brick", "cobble", "diorite", "endbricks",
|
|
|
|
"granite", "mossycobble", "netherbrick", "prismarine",
|
2022-05-26 08:29:28 +03:00
|
|
|
"rednetherbrick", "redsandstone", "sandstone",
|
|
|
|
"stonebrick", "stonebrickmossy",
|
2021-07-18 20:21:53 +03:00
|
|
|
},
|
|
|
|
wool = {
|
2021-07-23 15:23:30 +03:00
|
|
|
"black", "blue", "brown", "cyan", "green",
|
2021-07-18 20:21:53 +03:00
|
|
|
"grey", "light_blue", "lime", "magenta", "orange",
|
|
|
|
"pink", "purple", "red", "silver", "white", "yellow",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
tt.register_snippet(function(itemstring)
|
2021-07-18 21:01:55 +03:00
|
|
|
local def = minetest.registered_items[itemstring]
|
2021-07-18 20:21:53 +03:00
|
|
|
local item_split = itemstring:find(":")
|
2021-07-24 17:09:47 +03:00
|
|
|
local id_string = itemstring:sub(item_split)
|
|
|
|
local id_modname = itemstring:sub(1, item_split - 1)
|
|
|
|
local new_id = game .. id_string
|
2024-05-02 07:21:52 +03:00
|
|
|
local alt_id = "mineclone" .. id_string
|
2021-07-24 17:09:47 +03:00
|
|
|
local mod_namespace = mcl_item_id.get_mod_namespace(id_modname)
|
2021-07-18 20:21:53 +03:00
|
|
|
for mod, ids in pairs(same_id) do
|
|
|
|
for _, id in pairs(ids) do
|
|
|
|
if itemstring == "mcl_" .. mod .. ":" .. id then
|
|
|
|
new_id = game .. ":" .. id .. "_" .. mod:gsub("s", "")
|
2024-05-02 07:21:52 +03:00
|
|
|
alt_id = "mineclone:" .. id .. "_" .. mod:gsub("s", "")
|
2021-07-18 20:21:53 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-07-24 17:09:47 +03:00
|
|
|
if mod_namespace ~= game then
|
|
|
|
new_id = mod_namespace .. id_string
|
2021-07-24 22:07:44 +03:00
|
|
|
end
|
|
|
|
if mod_namespace ~= id_modname then
|
2021-07-23 19:12:43 +03:00
|
|
|
minetest.register_alias_force(new_id, itemstring)
|
2024-05-02 07:21:52 +03:00
|
|
|
minetest.register_alias_force(alt_id, itemstring)
|
2021-07-23 19:12:43 +03:00
|
|
|
end
|
|
|
|
if minetest.settings:get_bool("mcl_item_id_debug", false) then
|
|
|
|
return new_id, "#555555"
|
2021-07-19 15:21:30 +03:00
|
|
|
end
|
2024-05-02 07:21:52 +03:00
|
|
|
end)
|