forked from MineClone5/MineClone5
Fix #1842 make other mods not using "mineclone" name space for item ids
This commit is contained in:
parent
0a9ea7e46a
commit
75b425ffd7
|
@ -1,4 +1,5 @@
|
||||||
local game = "mineclone"
|
local game = "mineclone"
|
||||||
|
local mcl_mods = {}
|
||||||
|
|
||||||
local same_id = {
|
local same_id = {
|
||||||
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
|
heads = { "skeleton", "zombie", "creeper", "wither_skeleton" },
|
||||||
|
@ -10,17 +11,34 @@ local same_id = {
|
||||||
"stonebrick", "stonebrickmossy",
|
"stonebrick", "stonebrickmossy",
|
||||||
},
|
},
|
||||||
wool = {
|
wool = {
|
||||||
"black", "blue", "brown", "cyan", "green",
|
"black", "blue", "brown", "cyan", "green",
|
||||||
"grey", "light_blue", "lime", "magenta", "orange",
|
"grey", "light_blue", "lime", "magenta", "orange",
|
||||||
"pink", "purple", "red", "silver", "white", "yellow",
|
"pink", "purple", "red", "silver", "white", "yellow",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local worldmt = io.open(minetest.get_worldpath() .. "/world.mt", "r")
|
||||||
|
local gameid = worldmt:read("*a"):match("gameid%s*=%s*(%S+)\n")
|
||||||
|
worldmt:close()
|
||||||
|
|
||||||
|
for _, mod in pairs(minetest.get_modnames()) do
|
||||||
|
if minetest.get_modpath(mod):match("/games/" .. gameid .. "/") then
|
||||||
|
table.insert(mcl_mods, mod)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function item_id(id)
|
||||||
|
if minetest.settings:get_bool("mcl_item_id_debug", false) then
|
||||||
|
return id, "#555555"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
tt.register_snippet(function(itemstring)
|
tt.register_snippet(function(itemstring)
|
||||||
local def = minetest.registered_items[itemstring]
|
local def = minetest.registered_items[itemstring]
|
||||||
local desc = def.description
|
local desc = def.description
|
||||||
local item_split = itemstring:find(":")
|
local item_split = itemstring:find(":")
|
||||||
local new_id = game .. itemstring:sub(item_split)
|
local new_id = game .. itemstring:sub(item_split)
|
||||||
|
local mcl_mod = itemstring:sub(1, item_split)
|
||||||
for mod, ids in pairs(same_id) do
|
for mod, ids in pairs(same_id) do
|
||||||
for _, id in pairs(ids) do
|
for _, id in pairs(ids) do
|
||||||
if itemstring == "mcl_" .. mod .. ":" .. id then
|
if itemstring == "mcl_" .. mod .. ":" .. id then
|
||||||
|
@ -28,12 +46,15 @@ tt.register_snippet(function(itemstring)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if new_id ~= game .. ":book_enchanted" then
|
for _, modname in pairs(mcl_mods) do
|
||||||
minetest.register_alias_force(new_id, itemstring)
|
if modname .. ":" == mcl_mod then
|
||||||
end
|
if new_id ~= game .. ":book_enchanted" and new_id ~= itemstring then
|
||||||
if minetest.settings:get_bool("mcl_item_id_debug", false) then
|
minetest.register_alias_force(new_id, itemstring)
|
||||||
return new_id, "#555555"
|
end
|
||||||
|
return item_id(new_id)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
return item_id(itemstring)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted")
|
minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted")
|
||||||
|
|
Loading…
Reference in New Issue