Do not override alias func

This commit is contained in:
Jean-Patrick Guerrero 2019-09-30 16:33:15 +02:00
parent bb6b3a4ee5
commit 94637c624e

View File

@ -14,7 +14,6 @@ local searches = {}
local recipes_cache = {} local recipes_cache = {}
local usages_cache = {} local usages_cache = {}
local fuel_cache = {} local fuel_cache = {}
local alias_cache = {}
local toolrepair local toolrepair
@ -26,6 +25,7 @@ local after = core.after
local clr = core.colorize local clr = core.colorize
local reg_tools = core.registered_tools local reg_tools = core.registered_tools
local reg_items = core.registered_items local reg_items = core.registered_items
local reg_alias = core.registered_aliases
local show_formspec = core.show_formspec local show_formspec = core.show_formspec
local globalstep = core.register_globalstep local globalstep = core.register_globalstep
local on_shutdown = core.register_on_shutdown local on_shutdown = core.register_on_shutdown
@ -874,20 +874,6 @@ local function search(data)
data.items = filtered_list data.items = filtered_list
end end
local old_register_alias = core.register_alias
core.register_alias = function(old, new)
old_register_alias(old, new)
alias_cache[new] = old
end
local old_register_alias_force = core.register_alias_force
core.register_alias_force = function(old, new)
old_register_alias_force(old, new)
alias_cache[new] = old
end
--[[ As `core.get_craft_recipe` and `core.get_all_craft_recipes` do not --[[ As `core.get_craft_recipe` and `core.get_all_craft_recipes` do not
return the replacements and toolrepair, we have to override return the replacements and toolrepair, we have to override
`core.register_craft` and do some reverse engineering. `core.register_craft` and do some reverse engineering.
@ -972,7 +958,7 @@ local function get_init_items()
local c = 0 local c = 0
for name, def in pairs(reg_items) do for name, def in pairs(reg_items) do
if show_item(def) then if show_item(def) then
local old_name = alias_cache[name] local old_name = reg_alias[name]
if old_name then if old_name then
local old_recipes = recipes_cache[old_name] local old_recipes = recipes_cache[old_name]
local old_usages = usages_cache[old_name] local old_usages = usages_cache[old_name]