Enchanted books in creative inventory
This commit is contained in:
parent
cfa6937df4
commit
5939baee52
|
@ -16,6 +16,18 @@ for _, f in pairs(builtin_filter_ids) do
|
|||
inventory_lists[f] = {}
|
||||
end
|
||||
|
||||
local function replace_enchanted_books(tbl)
|
||||
for k, item in ipairs(tbl) do
|
||||
if item:find("mcl_enchanting:book_enchanted") == 1 then
|
||||
local _, enchantment, level = item:match("(%a+) ([_%w]+) (%d+)")
|
||||
level = level and tonumber(level)
|
||||
if enchantment and level then
|
||||
tbl[k] = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), enchantment, level)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--[[ Populate all the item tables. We only do this once. Note this mod must be
|
||||
loaded after _mcl_autogroup for this to work, because it required certain
|
||||
groups to be set. ]]
|
||||
|
@ -82,11 +94,33 @@ do
|
|||
end
|
||||
end
|
||||
|
||||
for ench, def in pairs(mcl_enchanting.enchantments) do
|
||||
local str = "mcl_enchanting:book_enchanted " .. ench .. " " .. def.max_level
|
||||
if def.inv_tool_tab then
|
||||
table.insert(inventory_lists["tools"], str)
|
||||
end
|
||||
if def.inv_combat_tab then
|
||||
table.insert(inventory_lists["combat"], str)
|
||||
end
|
||||
table.insert(inventory_lists["all"], str)
|
||||
end
|
||||
|
||||
for _, to_sort in pairs(inventory_lists) do
|
||||
table.sort(to_sort)
|
||||
replace_enchanted_books(to_sort)
|
||||
end
|
||||
end
|
||||
|
||||
local function filter_item(name, description, lang, filter)
|
||||
local desc
|
||||
if not lang then
|
||||
desc = string.lower(description)
|
||||
else
|
||||
desc = string.lower(minetest.get_translated_string(lang, description))
|
||||
end
|
||||
return string.find(name, filter) or string.find(desc, filter)
|
||||
end
|
||||
|
||||
local function set_inv_search(filter, player)
|
||||
local playername = player:get_player_name()
|
||||
local inv = minetest.get_inventory({type="detached", name="creative_"..playername})
|
||||
|
@ -94,19 +128,21 @@ local function set_inv_search(filter, player)
|
|||
local lang = minetest.get_player_information(playername).lang_code
|
||||
for name,def in pairs(minetest.registered_items) do
|
||||
if (not def.groups.not_in_creative_inventory or def.groups.not_in_creative_inventory == 0) and def.description and def.description ~= "" then
|
||||
local name = string.lower(def.name)
|
||||
local desc
|
||||
if not lang then
|
||||
desc = string.lower(def.description)
|
||||
else
|
||||
desc = string.lower(minetest.get_translated_string(lang, def.description))
|
||||
end
|
||||
if string.find(name, filter) or string.find(desc, filter) then
|
||||
if filter_item(string.lower(def.name), def.description, lang, filter) then
|
||||
table.insert(creative_list, name)
|
||||
end
|
||||
end
|
||||
end
|
||||
for ench, def in pairs(mcl_enchanting.enchantments) do
|
||||
for i = 1, def.max_level do
|
||||
local stack = mcl_enchanting.enchant(ItemStack("mcl_enchanting:book_enchanted"), ench, i)
|
||||
if filter_item("mcl_enchanting:book_enchanted", minetest.strip_colors(stack:get_description()), lang, filter) then
|
||||
table.insert(creative_list, "mcl_enchanting:book_enchanted " .. ench .. " " .. i)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(creative_list)
|
||||
replace_enchanted_books(creative_list)
|
||||
|
||||
inv:set_size("main", #creative_list)
|
||||
inv:set_list("main", creative_list)
|
||||
|
|
|
@ -5,3 +5,4 @@ _mcl_autogroup?
|
|||
mcl_armor?
|
||||
mcl_brewing?
|
||||
mcl_potions?
|
||||
mcl_enchanting
|
||||
|
|
|
@ -25,6 +25,8 @@ end
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 41}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented via on_enchant and additions in mobs_mc; Slowness IV part unimplemented
|
||||
|
@ -42,6 +44,8 @@ mcl_enchanting.enchantments.bane_of_arthropods = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{5, 25}, {13, 33}, {21, 41}, {29, 49}, {37, 57}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented in mcl_armor
|
||||
|
@ -59,6 +63,8 @@ mcl_enchanting.enchantments.blast_protection = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{5, 13}, {13, 21}, {21, 29}, {29, 37}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -76,6 +82,8 @@ mcl_enchanting.enchantments.blast_protection = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{25, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented in mcl_armor
|
||||
|
@ -93,6 +101,8 @@ mcl_enchanting.enchantments.curse_of_binding = {
|
|||
requires_tool = false,
|
||||
treasure = true,
|
||||
power_range_table = {{25, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented in mcl_death_drop
|
||||
|
@ -110,6 +120,8 @@ mcl_enchanting.enchantments.curse_of_vanishing = {
|
|||
requires_tool = false,
|
||||
treasure = true,
|
||||
power_range_table = {{25, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
||||
-- unimplemented
|
||||
|
@ -127,6 +139,8 @@ mcl_enchanting.enchantments.curse_of_vanishing = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{10, 25}, {20, 35}, {30, 45}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented via on_enchant
|
||||
|
@ -154,6 +168,8 @@ mcl_enchanting.enchantments.efficiency = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 61}, {11, 71}, {21, 81}, {31, 91}, {41, 101}},
|
||||
inv_combat_tab = false,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
||||
-- implemented in mcl_armor
|
||||
|
@ -170,6 +186,8 @@ mcl_enchanting.enchantments.feather_falling = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{5, 11}, {11, 17}, {17, 23}, {23, 29}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented in mcl_mobs and via register_on_punchplayer callback
|
||||
|
@ -187,6 +205,8 @@ mcl_enchanting.enchantments.fire_aspect = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{10, 61}, {30, 71}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
||||
|
@ -216,6 +236,8 @@ mcl_enchanting.enchantments.fire_protection = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{10, 18}, {18, 26}, {26, 34}, {34, 42}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -233,6 +255,8 @@ mcl_enchanting.enchantments.fire_protection = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{20, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented in mcl_item_entity
|
||||
|
@ -250,6 +274,8 @@ mcl_enchanting.enchantments.fortune = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
|
||||
inv_combat_tab = false,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
||||
-- implemented via walkover.register_global
|
||||
|
@ -267,6 +293,8 @@ mcl_enchanting.enchantments.frost_walker = {
|
|||
requires_tool = false,
|
||||
treasure = true,
|
||||
power_range_table = {{10, 25}, {20, 35}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
walkover.register_global(function(pos, _, player)
|
||||
|
@ -301,6 +329,8 @@ end)
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 21}, {9, 29}, {17, 37}, {25, 45}, {33, 53}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented in mcl_bows
|
||||
|
@ -318,6 +348,8 @@ mcl_enchanting.enchantments.infinity = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{20, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented via minetest.calculate_knockback
|
||||
|
@ -335,6 +367,8 @@ mcl_enchanting.enchantments.knockback = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{5, 61}, {25, 71}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
local old_calculate_knockback = minetest.calculate_knockback
|
||||
|
@ -368,6 +402,8 @@ mcl_enchanting.enchantments.looting = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -385,6 +421,8 @@ mcl_enchanting.enchantments.looting = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{12, 50}, {19, 50}, {26, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented in mcl_fishing
|
||||
|
@ -402,6 +440,8 @@ mcl_enchanting.enchantments.luck_of_the_sea = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
|
||||
inv_combat_tab = false,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
||||
-- implemented in mcl_fishing
|
||||
|
@ -419,6 +459,8 @@ mcl_enchanting.enchantments.lure = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{15, 61}, {24, 71}, {33, 81}},
|
||||
inv_combat_tab = false,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
||||
-- implemented in mcl_experience
|
||||
|
@ -436,6 +478,8 @@ mcl_enchanting.enchantments.mending = {
|
|||
requires_tool = true,
|
||||
treasure = true,
|
||||
power_range_table = {{25, 75}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -453,6 +497,8 @@ mcl_enchanting.enchantments.mending = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{20, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -470,6 +516,8 @@ mcl_enchanting.enchantments.mending = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 50}, {11, 50}, {21, 50}, {31, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented in mcl_bows
|
||||
|
@ -487,6 +535,8 @@ mcl_enchanting.enchantments.power = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 16}, {11, 26}, {21, 36}, {31, 46}, {41, 56}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented in mcl_armor
|
||||
|
@ -504,6 +554,8 @@ mcl_enchanting.enchantments.projectile_protection = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 16}, {11, 26}, {21, 36}, {31, 46}, {41, 56}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented in mcl_armor
|
||||
|
@ -521,6 +573,8 @@ mcl_enchanting.enchantments.protection = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 12}, {12, 23}, {23, 34}, {34, 45}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented via minetest.calculate_knockback (together with the Knockback enchantment) and mcl_bows
|
||||
|
@ -538,6 +592,8 @@ mcl_enchanting.enchantments.punch = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{12, 37}, {32, 57}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -555,6 +611,8 @@ mcl_enchanting.enchantments.punch = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{12, 50}, {32, 50}, {52, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- unimplemented
|
||||
|
@ -572,6 +630,8 @@ mcl_enchanting.enchantments.punch = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{10, 40}, {20, 50}, {30, 60}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -589,6 +649,8 @@ mcl_enchanting.enchantments.punch = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{17, 50}, {24, 50}, {31, 50}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented via on_enchant
|
||||
|
@ -606,6 +668,8 @@ mcl_enchanting.enchantments.sharpness = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{1, 21}, {12, 32}, {23, 43}, {34, 54}, {45, 65}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented in mcl_item_entity
|
||||
|
@ -623,6 +687,8 @@ mcl_enchanting.enchantments.silk_touch = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{15, 61}},
|
||||
inv_combat_tab = false,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
||||
-- implemented via on_enchant and additions in mobs_mc
|
||||
|
@ -640,6 +706,8 @@ mcl_enchanting.enchantments.smite = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{5, 25}, {13, 33}, {21, 41}, {29, 49}, {37, 57}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- implemented in mcl_playerplus
|
||||
|
@ -657,6 +725,8 @@ mcl_enchanting.enchantments.soul_speed = {
|
|||
requires_tool = false,
|
||||
treasure = true,
|
||||
power_range_table = {{10, 25}, {20, 35}, {30, 45}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- requires missing MineClone2 feature
|
||||
|
@ -674,6 +744,8 @@ mcl_enchanting.enchantments.soul_speed = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{5, 20}, {14, 29}, {23, 38}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}]]--
|
||||
|
||||
-- implemented in mcl_armor
|
||||
|
@ -691,6 +763,8 @@ mcl_enchanting.enchantments.thorns = {
|
|||
requires_tool = false,
|
||||
treasure = false,
|
||||
power_range_table = {{10, 61}, {30, 71}, {50, 81}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = false,
|
||||
}
|
||||
|
||||
-- for tools & weapons implemented via on_enchant; for bows implemented in mcl_bows; for armor implemented in mcl_armor and mcl_tt; for fishing rods implemented in mcl_fishing
|
||||
|
@ -704,7 +778,7 @@ mcl_enchanting.enchantments.unbreaking = {
|
|||
weight = 5,
|
||||
description = S("Increases item durability."),
|
||||
curse = false,
|
||||
on_enchant = function(itemstack, level)
|
||||
on_enchant = function(itemstack, level)
|
||||
local tool_capabilities = itemstack:get_tool_capabilities()
|
||||
for group, capability in pairs(tool_capabilities.groupcaps) do
|
||||
capability.uses = capability.uses * (1 + level)
|
||||
|
@ -715,4 +789,6 @@ mcl_enchanting.enchantments.unbreaking = {
|
|||
requires_tool = true,
|
||||
treasure = false,
|
||||
power_range_table = {{5, 61}, {13, 71}, {21, 81}},
|
||||
inv_combat_tab = true,
|
||||
inv_tool_tab = true,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user