mirror of
https://github.com/minetest/minetest_game.git
synced 2025-01-21 04:50:17 +01:00
Add safety checks before overriding builtin item entity (#3177)
This commit is contained in:
parent
6da5e947f0
commit
ee1f2b68df
@ -2,9 +2,16 @@
|
|||||||
|
|
||||||
local builtin_item = minetest.registered_entities["__builtin:item"]
|
local builtin_item = minetest.registered_entities["__builtin:item"]
|
||||||
|
|
||||||
|
-- strictly speaking none of this is part of the API, so do some checks
|
||||||
|
-- and if it looks wrong skip the modifications
|
||||||
|
if not builtin_item or type(builtin_item.set_item) ~= "function" or type(builtin_item.on_step) ~= "function" then
|
||||||
|
minetest.log("warning", "Builtin item entity does not look as expected, skipping overrides.")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local item = {
|
local item = {
|
||||||
set_item = function(self, itemstring)
|
set_item = function(self, itemstring, ...)
|
||||||
builtin_item.set_item(self, itemstring)
|
builtin_item.set_item(self, itemstring, ...)
|
||||||
|
|
||||||
local stack = ItemStack(itemstring)
|
local stack = ItemStack(itemstring)
|
||||||
local itemdef = minetest.registered_items[stack:get_name()]
|
local itemdef = minetest.registered_items[stack:get_name()]
|
||||||
|
Loading…
Reference in New Issue
Block a user