diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index ba90848d..75ed19ef 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -1,3 +1,4 @@ +local S = minetest.get_translator("mcl_item_entity") --basic settings local item_drop_settings = {} --settings table item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting @@ -781,3 +782,29 @@ minetest.register_entity(":__builtin:item", { -- Note: on_punch intentionally left out. The player should *not* be able to collect items by punching }) + +-- The “getwrittenbook” command was added as a debug aid. It can help +-- reproducing situations in which items with lots of metadata trigger +-- issues like heavy lag or server crashes. Do not remove this command +-- unless another easy way of getting items with overlong meta exists! +-- +-- “/getwrittenbook 65323” creates an item that creates the largest +-- possible serializable written book item entity when dropped. +-- +-- “/getwrittenbook 65324” creates an item that creates the smallest +-- possible non-serializable written book item entity when dropped. +minetest.register_chatcommand("getwrittenbook", { + params = S(""), + description = S("Get a written book with a configurable amount of characters."), + privs = {debug=true}, + func = function(name, param) + local count = tonumber(param) + local itemstack = ItemStack("mcl_books:written_book") + local meta = itemstack:get_meta() + meta:set_string("description", "") + meta:set_string("text", string.rep("x", count)) + local player = minetest.get_player_by_name(name) + local inv = player:get_inventory() + inv:add_item("main", itemstack) + end +})