Fix "Ignoring CONTENT_IGNORE redefinition" warning (#4393)
authoryou <ovvv@web.de>
Sun, 18 Feb 2018 09:40:14 +0000 (10:40 +0100)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Sun, 18 Feb 2018 09:40:14 +0000 (10:40 +0100)
minetest.override_item still passes to core

builtin/game/register.lua

index 15d9b42d0ea13d1af12f19c3be793a2594cb618d..5ce8caf3a7fd0f83506f91db5be1901a308bab1d 100644 (file)
@@ -116,6 +116,8 @@ function core.register_item(name, itemdef)
        end
        itemdef.name = name
 
+       local is_overriding = core.registered_items[name]
+
        -- Apply defaults and add to registered_* table
        if itemdef.type == "node" then
                -- Use the nodebox as selection box if it's not set manually
@@ -177,7 +179,13 @@ function core.register_item(name, itemdef)
        --core.log("Registering item: " .. itemdef.name)
        core.registered_items[itemdef.name] = itemdef
        core.registered_aliases[itemdef.name] = nil
-       register_item_raw(itemdef)
+
+       -- Used to allow builtin to register ignore to registered_items
+       if name ~= "ignore" then
+               register_item_raw(itemdef)
+       elseif is_overriding then
+               core.log("warning", "Attempted redefinition of \"ignore\"")
+       end
 end
 
 function core.unregister_item(name)