1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-11-15 22:40:19 +01:00

Replace deprecated get_metadata() calls (#3142)

This commit is contained in:
Niklp 2024-07-27 15:42:08 +03:00 committed by GitHub
parent 9cb57ae5f2
commit 88ecab34d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 4 deletions

View File

@ -163,12 +163,12 @@ function default.chest.register_chest(prefixed_name, d)
local itemstack = player:get_wielded_item() local itemstack = player:get_wielded_item()
local key_meta = itemstack:get_meta() local key_meta = itemstack:get_meta()
if itemstack:get_metadata() == "" then if itemstack:get_meta():get_string("") == "" then
return return
end end
if key_meta:get_string("secret") == "" then if key_meta:get_string("secret") == "" then
key_meta:set_string("secret", minetest.parse_json(itemstack:get_metadata()).secret) key_meta:set_string("secret", minetest.parse_json(itemstack:get_meta():get_string("")).secret)
itemstack:set_metadata("") itemstack:set_metadata("")
end end

View File

@ -57,7 +57,7 @@ local function book_on_use(itemstack, user)
local page, page_max, lines, string = 1, 1, {}, "" local page, page_max, lines, string = 1, 1, {}, ""
-- Backwards compatibility -- Backwards compatibility
local old_data = minetest.deserialize(itemstack:get_metadata()) local old_data = minetest.deserialize(itemstack:get_meta():get_string(""))
if old_data then if old_data then
meta:from_table({ fields = old_data }) meta:from_table({ fields = old_data })
end end

View File

@ -803,7 +803,7 @@ function default.can_interact_with_node(player, pos)
local key_meta = item:get_meta() local key_meta = item:get_meta()
if key_meta:get_string("secret") == "" then if key_meta:get_string("secret") == "" then
local key_oldmeta = item:get_metadata() local key_oldmeta = item:get_meta():get_string("")
if key_oldmeta == "" or not minetest.parse_json(key_oldmeta) then if key_oldmeta == "" or not minetest.parse_json(key_oldmeta) then
return false return false
end end