Forbid renaming of written books

This commit is contained in:
Wuzzy 2018-02-02 05:13:26 +01:00
parent 06c9b2c3f6
commit 40163aed91
3 changed files with 15 additions and 9 deletions

View File

@ -52,6 +52,7 @@ Please read <http://minecraft.gamepedia.com/Breaking> to learn how digging times
* `can_eat_when_full=1`: Only for foodstuffs. This item can be eaten when the user has a full hunger bar
* `attached_node_facedir=1`: Like `attached_node`, but for facedir nodes
* `cauldron`: Cauldron. 1: Empty. 2-4: Water height
* `no_rename=1`: Item cannot be renamed by anvil
#### Footnotes

View File

@ -38,6 +38,10 @@ local function update_anvil_slots(meta)
else
name_item = input1
end
-- No renaming allowed with group no_rename=1
if minetest.get_item_group(name_item:get_name(), "no_rename") == 1 then
new_output = ""
else
local meta = name_item:get_meta()
-- Limit name length
new_name = string.sub(new_name, 1, 30)
@ -46,6 +50,7 @@ local function update_anvil_slots(meta)
-- Double-save the name internally, too
meta:set_string("name", new_name)
new_output = name_item
end
else
new_output = ""
end

View File

@ -179,7 +179,7 @@ minetest.register_craftitem("mcl_books:written_book", {
To copy the text of the written book, place it into the crafting grid together with a book and quill (or multiple of those) and craft. The written book will not be consumed. Copies of copies can not be copied.]],
inventory_image = "mcl_books_book_written.png",
groups = { not_in_creative_inventory=1, book=1 },
groups = { not_in_creative_inventory=1, book=1, no_rename=1 },
stack_max = 16,
on_place = read,
on_secondary_use = read