From 26f3d821a4db723ffc416db374071ff21faa414a Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sun, 1 Nov 2020 13:44:05 +0100 Subject: [PATCH] Proper anvil naming support --- mods/CORE/_mcl_enchanting/enchantments.lua | 344 ---------- mods/CORE/_mcl_enchanting/features.lua | 124 ---- .../LICENSE | 0 .../README | 0 .../core.lua => mcl_enchanting/api.lua} | 210 ++++--- .../book.lua | 0 .../command.lua | 0 mods/CORE/mcl_enchanting/enchantments.lua | 591 ++++++++++++++++++ .../init.lua | 9 +- .../mod.conf | 0 .../models/mcl_enchanting_book.b3d | Bin .../models/mcl_enchanting_book_entity.png | Bin .../roman_numerals.lua | 0 .../sounds/mcl_enchanting_enchant.ogg | Bin .../table.lua | 0 .../textures/mcl_enchanting_book_closed.png | Bin .../textures/mcl_enchanting_book_open.png | Bin .../textures/mcl_enchanting_button.png | Bin .../mcl_enchanting_button_background.png | Bin .../mcl_enchanting_button_hovered.png | Bin .../textures/mcl_enchanting_button_off.png | Bin .../textures/mcl_enchanting_glyph_1.png | Bin .../textures/mcl_enchanting_glyph_10.png | Bin .../textures/mcl_enchanting_glyph_11.png | Bin .../textures/mcl_enchanting_glyph_12.png | Bin .../textures/mcl_enchanting_glyph_13.png | Bin .../textures/mcl_enchanting_glyph_14.png | Bin .../textures/mcl_enchanting_glyph_15.png | Bin .../textures/mcl_enchanting_glyph_16.png | Bin .../textures/mcl_enchanting_glyph_17.png | Bin .../textures/mcl_enchanting_glyph_18.png | Bin .../textures/mcl_enchanting_glyph_2.png | Bin .../textures/mcl_enchanting_glyph_3.png | Bin .../textures/mcl_enchanting_glyph_4.png | Bin .../textures/mcl_enchanting_glyph_5.png | Bin .../textures/mcl_enchanting_glyph_6.png | Bin .../textures/mcl_enchanting_glyph_7.png | Bin .../textures/mcl_enchanting_glyph_8.png | Bin .../textures/mcl_enchanting_glyph_9.png | Bin .../mcl_enchanting_lapis_background.png | Bin .../textures/mcl_enchanting_number_1.png | Bin .../textures/mcl_enchanting_number_1_off.png | Bin .../textures/mcl_enchanting_number_2.png | Bin .../textures/mcl_enchanting_number_2_off.png | Bin .../textures/mcl_enchanting_number_3.png | Bin .../textures/mcl_enchanting_number_3_off.png | Bin .../textures/mcl_enchanting_table_bottom.png | Bin .../textures/mcl_enchanting_table_side.png | Bin .../textures/mcl_enchanting_table_top.png | Bin .../tt.lua | 2 +- mods/HELP/tt/init.lua | 6 +- mods/ITEMS/mcl_anvils/depends.txt | 1 + mods/ITEMS/mcl_anvils/init.lua | 13 +- mods/ITEMS/mcl_bows/bow.lua | 8 +- mods/ITEMS/mcl_bows/depends.txt | 1 + mods/PLAYER/mcl_death_drop/depends.txt | 1 + mods/PLAYER/mcl_death_drop/init.lua | 2 +- 57 files changed, 734 insertions(+), 578 deletions(-) delete mode 100644 mods/CORE/_mcl_enchanting/enchantments.lua delete mode 100644 mods/CORE/_mcl_enchanting/features.lua rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/LICENSE (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/README (100%) rename mods/CORE/{_mcl_enchanting/core.lua => mcl_enchanting/api.lua} (64%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/book.lua (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/command.lua (100%) create mode 100644 mods/CORE/mcl_enchanting/enchantments.lua rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/init.lua (76%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/mod.conf (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/models/mcl_enchanting_book.b3d (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/models/mcl_enchanting_book_entity.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/roman_numerals.lua (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/sounds/mcl_enchanting_enchant.ogg (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/table.lua (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_book_closed.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_book_open.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_button.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_button_background.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_button_hovered.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_button_off.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_1.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_10.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_11.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_12.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_13.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_14.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_15.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_16.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_17.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_18.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_2.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_3.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_4.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_5.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_6.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_7.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_8.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_glyph_9.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_lapis_background.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_number_1.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_number_1_off.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_number_2.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_number_2_off.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_number_3.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_number_3_off.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_table_bottom.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_table_side.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/textures/mcl_enchanting_table_top.png (100%) rename mods/CORE/{_mcl_enchanting => mcl_enchanting}/tt.lua (78%) diff --git a/mods/CORE/_mcl_enchanting/enchantments.lua b/mods/CORE/_mcl_enchanting/enchantments.lua deleted file mode 100644 index 4aab62f683..0000000000 --- a/mods/CORE/_mcl_enchanting/enchantments.lua +++ /dev/null @@ -1,344 +0,0 @@ --- Taken from https://minecraft.gamepedia.com/Enchanting - -mcl_enchanting.enchantments = { - -- unimplemented - aqua_affinity = { - name = "Aqua Affinity", - max_level = 1, - primary = {armor_head = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {}, - weight = 2, - description = "Increases underwater mining speed." - }, - -- unimplemented - bane_of_anthropods = { - name = "Bane of Anthropods", - max_level = 5, - primary = {sword = true}, - secondary = {axe = true}, - disallow = {}, - incompatible = {smite = true, shaprness = true}, - weight = 5, - description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites)." - }, - -- unimplemented - blast_protection = { - name = "Blast Protection", - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {fire_protection = true, protection = true, projectile_protection = true}, - weight = 2, - description = "Reduces explosion damage and knockback." - }, - -- unimplemented - curse_of_binding = { - name = "Curse of Binding", - max_level = 1, - primary = {}, - secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - disallow = {}, - incompatible = {}, - weight = 1, - description = "Except when in creative mode, items cannot be removed from armor slots except due to death or breaking." - }, - -- unimplemented - curse_of_vanishing = { - name = "Curse of Vanishing", - max_level = 1, - primary = {}, - secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true}, - disallow = {clock = true}, - incompatible = {}, - weight = 1, - description = "Except when in creative mode, items cannot be removed from armor slots except due to death or breaking." - }, - -- unimplemented - depth_strider = { - name = "Depth Strider", - max_level = 3, - primary = {}, - secondary = {armor_feet = true}, - disallow = {non_combat_armor = true}, - incompatible = {frost_walker = true}, - weight = 2, - description = "Increases underwater movement speed." - }, - -- unimplemented - efficiency = { - name = "Efficiency", - max_level = 5, - primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, - secondary = {shears = true}, - disallow = {}, - incompatible = {}, - weight = 10, - description = "Increases mining speed." - }, - -- unimplemented - feather_falling = { - name = "Feather Falling", - max_level = 4, - primary = {armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {}, - weight = 5, - description = "Reduces fall damage." - }, - -- unimplemented - fire_aspect = { - name = "Fire Aspect", - max_level = 2, - primary = {sword = true}, - secondary = {}, - disallow = {}, - incompatible = {}, - weight = 2, - description = "Sets target on fire." - }, - -- unimplemented - fire_protection = { - name = "Fire Protection", - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {blast_protection = true, protection = true, projectile_protection = true}, - weight = 5, - description = "Reduces fire damage." - }, - -- unimplemented - flame = { - name = "Flame", - max_level = 1, - primary = {bow = true}, - secondary = {}, - disallow = {}, - incompatible = {}, - weight = 2, - description = "Arrows set target on fire." - }, - -- unimplemented - fortune = { - name = "Fortune", - max_level = 4, - primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, - secondary = {}, - disallow = {}, - incompatible = {silk_touch = true}, - weight = 2, - description = "Increases certain block drops." - }, - -- unimplemented - frost_walker = { - name = "Frost Walker", - max_level = 2, - primary = {}, - secondary = {armor_feet = true}, - disallow = {non_combat_armor = true}, - incompatible = {depth_strider = true}, - weight = 2, - description = "Turns water beneath the player into frosted ice and prevents the damage the player would take from standing on magma blocks." - }, - infinity = { - name = "Infinity", - max_level = 1, - primary = {bow = true}, - secondary = {}, - disallow = {}, - incompatible = {mending = true}, - weight = 1, - description = "Shooting consumes no regular arrows." - }, - -- unimplemented - knockback = { - name = "Knockback", - max_level = 2, - primary = {sword = true}, - secondary = {}, - disallow = {}, - incompatible = {}, - weight = 5, - description = "Increases knockback." - }, - -- unimplemented - looting = { - name = "Looting", - max_level = 3, - primary = {sword = true}, - secondary = {}, - disallow = {}, - incompatible = {}, - weight = 2, - description = "Increases mob loot." - }, - -- unimplemented - luck_of_the_sea = { - name = "Luck of the Sea", - max_level = 3, - primary = {fishing_rod = true}, - secondary = {}, - disallow = {}, - incompatible = {}, - weight = 2, - description = "Increases rate of good loot (enchanting books, etc.)" - }, - -- unimplemented - lure = { - name = "Lure", - max_level = 3, - primary = {fishing_rod = true}, - secondary = {}, - disallow = {}, - incompatible = {}, - weight = 2, - description = "Decreases wait time until fish/junk/loot \"bites\"." - }, - -- unimplemented - mending = { - name = "Mending", - max_level = 1, - primary = {}, - secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true}, - disallow = {non_combat_armor = true, compass = true, clock = true}, - incompatible = {infinity = true}, - weight = 2, - description = "Repair the item while gaining XP orbs." - }, - -- unimplemented - power = { - name = "Power", - max_level = 5, - primary = {}, - secondary = {bow = true}, - disallow = {}, - incompatible = {}, - weight = 10, - description = "Increases arrow damage." - }, - -- unimplemented - projectile_protection = { - name = "Projectile Protection", - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {blast_protection = true, fire_protection = true, protection = true}, - weight = 5, - description = "Reduces projectile damage." - }, - -- unimplemented - protection = { - name = "Protection", - max_level = 4, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, - weight = 10, - description = "Reduces most types of damage by 4% for each level." - }, - -- unimplemented - punch = { - name = "Punch", - max_level = 2, - primary = {}, - secondary = {bow = true}, - disallow = {}, - incompatible = {}, - weight = 2, - description = "Increases arrow knockback." - }, - -- unimplemented - respiration = { - name = "Respiration", - max_level = 3, - primary = {armor_head = true}, - secondary = {}, - disallow = {non_combat_armor = true}, - incompatible = {}, - weight = 2, - description = "Extends underwater breathing time." - }, - -- unimplemented - sharpness = { - name = "Sharpness", - max_level = 5, - primary = {sword = true}, - secondary = {axe = true}, - disallow = {}, - incompatible = {bane_of_anthropods = true, smite = true}, - weight = 5, - description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites)." - }, - -- unimplemented - silk_touch = { - name = "Silk Touch", - max_level = 1, - primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, - secondary = {shears = true}, - disallow = {}, - incompatible = {fortune = true}, - weight = 1, - description = "Mined blocks drop themselves." - }, - -- unimplemented - smite = { - name = "Smite", - max_level = 5, - primary = {sword = true}, - secondary = {axe = true}, - disallow = {}, - incompatible = {bane_of_anthropods = true, sharpness = true}, - weight = 5, - description = "Increases damage to undead mobs." - }, - -- unimplemented - soul_speed = { - name = "Soul Speed", - max_level = 3, - primary = {}, - secondary = {armor_feet = true}, - disallow = {non_combat_armor = true}, - incompatible = {frost_walker = true}, - weight = 2, - description = "Incerases walking speed on soul sand." - }, - -- unimplemented - sweeping_edge = { - name = "Sweeping Edge", - max_level = 3, - primary = {sword = true}, - secondary = {}, - disallow = {}, - incompatible = {}, - weight = 2, - description = "Increases sweeping attack damage." - }, - -- unimplemented - thorns = { - name = "Thorns", - max_level = 3, - primary = {armor_head = true}, - secondary = {armor_torso = true, armor_legs = true, armor_feet = true}, - disallow = {non_combat_armor = true}, - incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, - weight = 1, - description = "Reflects some of the damage taken when hit, at the cost of reducing durability with each proc." - }, - -- unimplemented - unbreaking = { - name = "Unbreaking", - max_level = 3, - primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, pickaxe = true, shovel = true, axe = true, hoe = true, sword = true, fishing_rod = true, bow = true}, - secondary = {tool = true}, - disallow = {non_combat_armor = true}, - incompatible = {}, - weight = 5, - description = "Increases item durability." - }, -} diff --git a/mods/CORE/_mcl_enchanting/features.lua b/mods/CORE/_mcl_enchanting/features.lua deleted file mode 100644 index f12abe0972..0000000000 --- a/mods/CORE/_mcl_enchanting/features.lua +++ /dev/null @@ -1,124 +0,0 @@ -mcl_enchanting.features = {} - - ---[[ -local pickaxes = {"mcl_tools:pick_wood", "mcl_tools:pick_stone", "mcl_tools:pick_gold", "mcl_tools:pick_iron", "mcl_tools:pick_diamond"} -local pickaxes_better_than_iron = {"mcl_tools:pick_iron", "mcl_tools:pick_diamond"} -local pickaxes_better_than_stone = {"mcl_tools:pick_stone", "mcl_tools:pick_gold", "mcl_tools:pick_iron", "mcl_tools:pick_diamond"} -local shovels = {"mcl_tools:shovel_wood", "mcl_tools:shovel_stone", "mcl_tools:shovel_gold", "mcl_tools:shovel_iron", "mcl_tools:shovel_diamond"} - -local silk_touch_tool_lists = { - ["mcl_books:bookshelf"] = true, - ["mcl_core:clay"] = true, - ["mcl_core:stone_with_coal"] = pickaxes, - ["group:coral_block"] = pickaxes, - ["group:coral"] = true, - ["group:coral_fan"] = true, - ["mcl_core:stone_with_diamond"] = pickaxes_better_than_iron, - ["mcl_core:stone_with_emerald"] = pickaxes_better_than_iron, - ["mcl_chests:ender_chest"] = pickaxes, - ["group:glass"] = true, - ["mcl_nether:glowstone"] = true, - ["mcl_core:dirt_with_grass"] = true, - ["mcl_core:gravel"] = true, - ["mcl_core:ice"] = true, - ["mcl_core:stone_with_lapis"] = pickaxes_better_than_stone, - ["group:leaves"] = true, - ["mcl_farming:melon"] = true, - ["group:huge_mushroom"] = true, - ["mcl_core:mycelium"] = true, - ["mcl_nether:quartz_ore"] = pickaxes, - ["mcl_core:packed_ice"] = true, - ["mcl_core:podzol"] = true, - ["mcl_core:stone_with_redstone"] = pickaxes_better_than_iron, - ["mcl_ocean:sea_lantern"] = true, - ["group:top_snow"] = shovels, - ["mcl_core:snowblock"] = shovels, - ["mcl_core:stone"] = pickaxes, -} - -minetest.register_on_mods_loaded(function() - local old_handle_node_drops = minetest.handle_node_drops - function minetest.handle_node_drops(pos, drops, digger) - if digger and digger:is_player() then - local wielditem = digger:get_wielded_item() - local tooldef = wielditem:get_definition() - if tooldef._silk_touch then - local nodename = minetest.get_node(pos).name - local nodedef = minetest.registered_nodes[nodename] - local silk_touch_spec = silk_touch_tool_lists[nodename] - local suitable_tool = false - local tool_list - if silk_touch_spec == true then - suitable_tool = true - elseif silk_touch_spec then - tool_list = silk_touch_spec - else - for k, v in pairs(nodedef.groups) do - if v > 0 then - local group_spec = silk_touch_tool_lists["group:" .. k] - if group_spec == true then - suitable_tool = true - elseif group_spec then - toollist = group_spec - break - end - end - end - end - if tool_list and not suitable_tool then - suitable_tool = (table.indexof(tool_list, tooldef._original_tool) ~= -1) - end - if suitable_tool then - drops = {nodename} - end - end - end - old_handle_node_drops(pos, drops, digger) - end -end) ---]] - - ---[[ - sharpness = { - name = "Sharpness", - max_level = 5, - create_itemdef = function(def, level) - def.tool_capabilities.damage_groups.fleshy = def.tool_capabilities.damage_groups.fleshy + (level + 1) / 2 - end, - }, - efficiency = { - name = "Efficiency", - max_level = 5, - create_itemdef = function(def, level) - local groupcaps = def.tool_capabilities.groupcaps - for _, groupcap in pairs(groupcaps) do - for i, t in pairs(groupcap.times) do - local m = 1 / t - m = m + math.pow(level, 2) + 1 - groupcap.times[i] = 1 / m - end - end - end, - }, - unbreaking = { - name = "Unbreaking", - max_level = 3, - create_itemdef = function(def, level) - local toolcaps = def.tool_capabilities - local armor_uses = def.groups.mcl_armor_uses - local factor = 0.5 - if toolcaps then - local groupcaps = toolcaps.groupcaps - for _, groupcap in pairs(groupcaps) do - groupcap.uses = math.floor(groupcap.uses * (1 + level)) - end - def.tool_capabilities.punch_attack_uses = math.floor(def.tool_capabilities.punch_attack_uses * (1 + level)) - elseif armor_uses then - def.groups.mcl_armor_uses = math.floor(armor_uses / (0.6 + (0.4 / (level + 1)))) - end - end - }, - },--]] - diff --git a/mods/CORE/_mcl_enchanting/LICENSE b/mods/CORE/mcl_enchanting/LICENSE similarity index 100% rename from mods/CORE/_mcl_enchanting/LICENSE rename to mods/CORE/mcl_enchanting/LICENSE diff --git a/mods/CORE/_mcl_enchanting/README b/mods/CORE/mcl_enchanting/README similarity index 100% rename from mods/CORE/_mcl_enchanting/README rename to mods/CORE/mcl_enchanting/README diff --git a/mods/CORE/_mcl_enchanting/core.lua b/mods/CORE/mcl_enchanting/api.lua similarity index 64% rename from mods/CORE/_mcl_enchanting/core.lua rename to mods/CORE/mcl_enchanting/api.lua index 38a5e1767e..a646134992 100644 --- a/mods/CORE/_mcl_enchanting/core.lua +++ b/mods/CORE/mcl_enchanting/api.lua @@ -1,87 +1,3 @@ -mcl_enchanting.total_weight = 0 -mcl_enchanting.all_item_groups = {} - -for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do - local all_item_groups = {} - for primary in pairs(enchantment_def.primary) do - all_item_groups[primary] = true - mcl_enchanting.all_item_groups[primary] = true - end - for secondary in pairs(enchantment_def.secondary) do - all_item_groups[secondary] = true - mcl_enchanting.all_item_groups[secondary] = true - end - enchantment_def.all = all_item_groups - mcl_enchanting.total_weight = mcl_enchanting.total_weight + enchantment_def.weight -end - ---[[ -minetest.register_on_mods_loaded(function() - for toolname, tooldef in pairs(minetest.registered_tools) do - for _, material in pairs(tooldef.materials) do - local full_name = toolname .. ((material == "") and "" or "_" .. material) - local old_def = minetest.registered_tools[full_name] - if not old_def then break end - mcl_enchanting.all_tools[full_name] = toolname - for _, enchantment in pairs(tooldef.enchantments) do - local enchantment_def = mcl_enchanting.enchantments[enchantment] - for lvl = 1, enchantment_def.max_level do - local new_def = table.copy(old_def) - new_def.description = minetest.colorize("#54FCFC", old_def.description) .. "\n" .. mcl_enchanting.get_enchantment_description(enchantment, lvl) - new_def.inventory_image = old_def.inventory_image .. "^[colorize:violet:50" - new_def.groups.not_in_creative_inventory = 1 - new_def.texture = old_def.texture or full_name:gsub("%:", "_") - new_def._original_tool = full_name - enchantment_def.create_itemdef(new_def, lvl) - minetest.register_tool(":" .. full_name .. "_enchanted_" .. enchantment .. "_" .. lvl, new_def) - end - end - end - end -end) ---]] - -minetest.register_on_mods_loaded(function() - local register_list = {} - for toolname, tooldef in pairs(minetest.registered_tools) do - if tooldef.groups.enchanted then - break - end - local quick_test = false - for group, groupv in pairs(tooldef.groups) do - if groupv > 0 and mcl_enchanting.all_item_groups[group] then - quick_test = true - break - end - end - if quick_test then - --print(toolname) - local expensive_test = false - for enchantment in pairs(mcl_enchanting.enchantments) do - if mcl_enchanting.item_supports_enchantment(toolname, enchantment, true) then - -- print("\tSupports " .. enchantment) - expensive_test = true - break - end - end - if expensive_test then - local new_name = toolname .. "_enchanted" - minetest.override_item(toolname, {_mcl_enchanting_enchanted_tool = new_name}) - local new_def = table.copy(tooldef) - new_def.inventory_image = tooldef.inventory_image .. "^[colorize:purple:50" - new_def.groups.not_in_creative_inventory = 1 - new_def.groups.enchanted = 1 - new_def.texture = tooldef.texture or toolname:gsub("%:", "_") - new_def._mcl_enchanting_enchanted_tool = new_name - register_list[":" .. new_name] = new_def - end - end - end - for new_name, new_def in pairs(register_list) do - minetest.register_tool(new_name, new_def) - end -end) - function mcl_enchanting.get_enchantments(itemstack) return minetest.deserialize(itemstack:get_meta():get_string("mcl_enchanting:enchantments")) or {} end @@ -90,8 +6,12 @@ function mcl_enchanting.set_enchantments(itemstack, enchantments) return itemstack:get_meta():set_string("mcl_enchanting:enchantments", minetest.serialize(enchantments)) end -function mcl_enchanting.get_enchantment(itemstack, enchantment, data) - return (data or mcl_enchanting.get_enchantments(itemstack))[enchantment] or 0 +function mcl_enchanting.get_enchantment(itemstack, enchantment) + return mcl_enchanting.get_enchantments(itemstack)[enchantment] or 0 +end + +function mcl_enchanting.has_enchantment(itemstack, enchantment) + return mcl_enchanting.get_enchantment(itemstack, enchantment) > 0 end function mcl_enchanting.get_enchantment_description(enchantment, level) @@ -99,16 +19,32 @@ function mcl_enchanting.get_enchantment_description(enchantment, level) return enchantment_def.name .. (enchantment_def.max_level == 1 and "" or " " .. mcl_enchanting.roman_numerals.toRoman(level)) end +function mcl_enchanting.get_colorized_enchantment_description(enchantment, level) + return minetest.colorize(mcl_enchanting.enchantments[enchantment].curse and "#FC5454" or "#A8A8A8", mcl_enchanting.get_enchantment_description(enchantment, level)) +end + function mcl_enchanting.get_enchanted_itemstring(itemname) - local def = minetest.registered_items[itemname] + local def = minetest.registered_items[itemname] return def and def._mcl_enchanting_enchanted_tool end +function mcl_enchanting.is_enchanted_def(itemname) + return minetest.get_item_group(itemname, "enchanted") > 0 +end + +function mcl_enchanting.is_enchanted(itemstack) + return mcl_enchanting.is_enchanted_def(itemstack:get_name()) +end + function mcl_enchanting.item_supports_enchantment(itemname, enchantment, early) if not early and not mcl_enchanting.get_enchanted_itemstring(itemname) then return false end local enchantment_def = mcl_enchanting.enchantments[enchantment] + local tooldef = minetest.registered_tools[itemname] + if not tooldef and enchantment_def.requires_tool then + return false + end for disallow in pairs(enchantment_def.disallow) do if minetest.get_item_group(itemname, disallow) > 0 then return false @@ -167,10 +103,104 @@ end function mcl_enchanting.reload_enchantments(itemstack, enchantments) local itemdef = itemstack:get_definition() for enchantment, level in pairs(enchantments) do - local func = mcl_enchanting.features[enchantment] - if func then - func(itemstack, level, itemdef) + local enchantment_def = mcl_enchanting.enchantments[enchantment] + if enchantment_def.on_enchant then + enchantment_def.on_enchant(itemstack, level, itemdef) end end tt.reload_itemstack_description(itemstack) end + +function mcl_enchanting.initialize() + local tool_list = {} + local item_list = {} + for enchantment, enchantment_def in pairs(mcl_enchanting.enchantments) do + local all_item_groups = {} + for primary in pairs(enchantment_def.primary) do + all_item_groups[primary] = true + mcl_enchanting.all_item_groups[primary] = true + end + for secondary in pairs(enchantment_def.secondary) do + all_item_groups[secondary] = true + mcl_enchanting.all_item_groups[secondary] = true + end + enchantment_def.all = all_item_groups + mcl_enchanting.total_weight = mcl_enchanting.total_weight + enchantment_def.weight + end + for itemname, itemdef in pairs(minetest.registered_items) do + if itemdef.groups.enchanted then + break + end + local quick_test = false + for group, groupv in pairs(itemdef.groups) do + if groupv > 0 and mcl_enchanting.all_item_groups[group] then + quick_test = true + break + end + end + if quick_test then + if mcl_enchanting.debug then + print(itemname) + end + local expensive_test = false + for enchantment in pairs(mcl_enchanting.enchantments) do + if mcl_enchanting.item_supports_enchantment(itemname, enchantment, true) then + expensive_test = true + if mcl_enchanting.debug then + print("\tSupports " .. enchantment) + else + break + end + end + end + if expensive_test then + local tooldef = minetest.registered_tools[itemname] + local new_name = itemname .. "_enchanted" + minetest.override_item(itemname, {_mcl_enchanting_enchanted_tool = new_name}) + local new_def = table.copy(itemdef) + new_def.inventory_image = itemdef.inventory_image .. "^[colorize:purple:50" + new_def.groups.not_in_creative_inventory = 1 + new_def.groups.enchanted = 1 + new_def.texture = itemdef.texture or itemname:gsub("%:", "_") + new_def._mcl_enchanting_enchanted_tool = new_name + local register_list = item_list + if tooldef then + register_list = tool_list + end + register_list[":" .. new_name] = new_def + end + end + end + for new_name, new_def in pairs(item_list) do + minetest.register_craftitem(new_name, new_def) + end + for new_name, new_def in pairs(tool_list) do + minetest.register_tool(new_name, new_def) + end +end + +--[[ +minetest.register_on_mods_loaded(function() + for toolname, tooldef in pairs(minetest.registered_tools) do + for _, material in pairs(tooldef.materials) do + local full_name = toolname .. ((material == "") and "" or "_" .. material) + local old_def = minetest.registered_tools[full_name] + if not old_def then break end + mcl_enchanting.all_tools[full_name] = toolname + for _, enchantment in pairs(tooldef.enchantments) do + local enchantment_def = mcl_enchanting.enchantments[enchantment] + for lvl = 1, enchantment_def.max_level do + local new_def = table.copy(old_def) + new_def.description = minetest.colorize("#54FCFC", old_def.description) .. "\n" .. mcl_enchanting.get_enchantment_description(enchantment, lvl) + new_def.inventory_image = old_def.inventory_image .. "^[colorize:violet:50" + new_def.groups.not_in_creative_inventory = 1 + new_def.texture = old_def.texture or full_name:gsub("%:", "_") + new_def._original_tool = full_name + enchantment_def.create_itemdef(new_def, lvl) + minetest.register_tool(":" .. full_name .. "_enchanted_" .. enchantment .. "_" .. lvl, new_def) + end + end + end + end +end) +--]] diff --git a/mods/CORE/_mcl_enchanting/book.lua b/mods/CORE/mcl_enchanting/book.lua similarity index 100% rename from mods/CORE/_mcl_enchanting/book.lua rename to mods/CORE/mcl_enchanting/book.lua diff --git a/mods/CORE/_mcl_enchanting/command.lua b/mods/CORE/mcl_enchanting/command.lua similarity index 100% rename from mods/CORE/_mcl_enchanting/command.lua rename to mods/CORE/mcl_enchanting/command.lua diff --git a/mods/CORE/mcl_enchanting/enchantments.lua b/mods/CORE/mcl_enchanting/enchantments.lua new file mode 100644 index 0000000000..dfe5559cb9 --- /dev/null +++ b/mods/CORE/mcl_enchanting/enchantments.lua @@ -0,0 +1,591 @@ +-- Taken from https://minecraft.gamepedia.com/Enchanting + +-- unimplemented +mcl_enchanting.enchantments.aqua_affinity = { + name = "Aqua Affinity", + max_level = 1, + primary = {armor_head = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {}, + weight = 2, + description = "Increases underwater mining speed.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.bane_of_anthropods = { + name = "Bane of Anthropods", + max_level = 5, + primary = {sword = true}, + secondary = {axe = true}, + disallow = {}, + incompatible = {smite = true, shaprness = true}, + weight = 5, + description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.blast_protection = { + name = "Blast Protection", + max_level = 4, + primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {fire_protection = true, protection = true, projectile_protection = true}, + weight = 2, + description = "Reduces explosion damage and knockback.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.curse_of_binding = { + name = "Curse of Binding", + max_level = 1, + primary = {}, + secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, + disallow = {}, + incompatible = {}, + weight = 1, + description = "Except when in creative mode, items cannot be removed from armor slots except due to death or breaking.", + curse = true, + on_enchant = function() end, + requires_tool = false, +} + +-- implemented in mcl_death_drop +mcl_enchanting.enchantments.curse_of_vanishing = { + name = "Curse of Vanishing", + max_level = 1, + primary = {}, + secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true}, + disallow = {clock = true}, + incompatible = {}, + weight = 1, + description = "Except when in creative mode, items cannot be removed from armor slots except due to death or breaking.", + curse = true, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.depth_strider = { + name = "Depth Strider", + max_level = 3, + primary = {}, + secondary = {armor_feet = true}, + disallow = {non_combat_armor = true}, + incompatible = {frost_walker = true}, + weight = 2, + description = "Increases underwater movement speed.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.efficiency = { + name = "Efficiency", + max_level = 5, + primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, + secondary = {shears = true}, + disallow = {}, + incompatible = {}, + weight = 10, + description = "Increases mining speed.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.feather_falling = { + name = "Feather Falling", + max_level = 4, + primary = {armor_feet = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {}, + weight = 5, + description = "Reduces fall damage.",curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.fire_aspect = { + name = "Fire Aspect", + max_level = 2, + primary = {sword = true}, + secondary = {}, + disallow = {}, + incompatible = {}, + weight = 2, + description = "Sets target on fire.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.fire_protection = { + name = "Fire Protection", + max_level = 4, + primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {blast_protection = true, protection = true, projectile_protection = true}, + weight = 5, + description = "Reduces fire damage.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.flame = { + name = "Flame", + max_level = 1, + primary = {bow = true}, + secondary = {}, + disallow = {}, + incompatible = {}, + weight = 2, + description = "Arrows set target on fire.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.fortune = { + name = "Fortune", + max_level = 4, + primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, + secondary = {}, + disallow = {}, + incompatible = {silk_touch = true}, + weight = 2, + description = "Increases certain block drops.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.frost_walker = { + name = "Frost Walker", + max_level = 2, + primary = {}, + secondary = {armor_feet = true}, + disallow = {non_combat_armor = true}, + incompatible = {depth_strider = true}, + weight = 2, + description = "Turns water beneath the player into frosted ice and prevents the damage the player would take from standing on magma blocks.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- implemented in mcl_bows +mcl_enchanting.enchantments.infinity = { + name = "Infinity", + max_level = 1, + primary = {bow = true}, + secondary = {}, + disallow = {}, + incompatible = {mending = true}, + weight = 1, + description = "Shooting consumes no regular arrows.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.knockback = { + name = "Knockback", + max_level = 2, + primary = {sword = true}, + secondary = {}, + disallow = {}, + incompatible = {}, + weight = 5, + description = "Increases knockback.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.looting = { + name = "Looting", + max_level = 3, + primary = {sword = true}, + secondary = {}, + disallow = {}, + incompatible = {}, + weight = 2, + description = "Increases mob loot.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.luck_of_the_sea = { + name = "Luck of the Sea", + max_level = 3, + primary = {fishing_rod = true}, + secondary = {}, + disallow = {}, + incompatible = {}, + weight = 2, + description = "Increases rate of good loot (enchanting books, etc.)", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.lure = { + name = "Lure", + max_level = 3, + primary = {fishing_rod = true}, + secondary = {}, + disallow = {}, + incompatible = {}, + weight = 2, + description = "Decreases wait time until fish/junk/loot \"bites\".", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.mending = { + name = "Mending", + max_level = 1, + primary = {}, + secondary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, tool = true, weapon = true}, + disallow = {non_combat_armor = true, compass = true, clock = true}, + incompatible = {infinity = true}, + weight = 2, + description = "Repair the item while gaining XP orbs.", + curse = false, + on_enchant = function() end, + requires_tool = true, +} + +-- unimplemented +mcl_enchanting.enchantments.power = { + name = "Power", + max_level = 5, + primary = {}, + secondary = {bow = true}, + disallow = {}, + incompatible = {}, + weight = 10, + description = "Increases arrow damage.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.projectile_protection = { + name = "Projectile Protection", + max_level = 4, + primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {blast_protection = true, fire_protection = true, protection = true}, + weight = 5, + description = "Reduces projectile damage.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.protection = { + name = "Protection", + max_level = 4, + primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, + weight = 10, + description = "Reduces most types of damage by 4% for each level.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.punch = { + name = "Punch", + max_level = 2, + primary = {}, + secondary = {bow = true}, + disallow = {}, + incompatible = {}, + weight = 2, + description = "Increases arrow knockback.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.respiration = { + name = "Respiration", + max_level = 3, + primary = {armor_head = true}, + secondary = {}, + disallow = {non_combat_armor = true}, + incompatible = {}, + weight = 2, + description = "Extends underwater breathing time.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.sharpness = { + name = "Sharpness", + max_level = 5, + primary = {sword = true}, + secondary = {axe = true}, + disallow = {}, + incompatible = {bane_of_anthropods = true, smite = true}, + weight = 5, + description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.silk_touch = { + name = "Silk Touch", + max_level = 1, + primary = {pickaxe = true, shovel = true, axe = true, hoe = true}, + secondary = {shears = true}, + disallow = {}, + incompatible = {fortune = true}, + weight = 1, + description = "Mined blocks drop themselves.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + + +-- unimplemented +mcl_enchanting.enchantments.smite = { + name = "Smite", + max_level = 5, + primary = {sword = true}, + secondary = {axe = true}, + disallow = {}, + incompatible = {bane_of_anthropods = true, sharpness = true}, + weight = 5, + description = "Increases damage to undead mobs.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.soul_speed = { + name = "Soul Speed", + max_level = 3, + primary = {}, + secondary = {armor_feet = true}, + disallow = {non_combat_armor = true}, + incompatible = {frost_walker = true}, + weight = 2, + description = "Incerases walking speed on soul sand.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.sweeping_edge = { + name = "Sweeping Edge", + max_level = 3, + primary = {sword = true}, + secondary = {}, + disallow = {}, + incompatible = {}, + weight = 2, + description = "Increases sweeping attack damage.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.thorns = { + name = "Thorns", + max_level = 3, + primary = {armor_head = true}, + secondary = {armor_torso = true, armor_legs = true, armor_feet = true}, + disallow = {non_combat_armor = true}, + incompatible = {blast_protection = true, fire_protection = true, projectile_protection = true}, + weight = 1, + description = "Reflects some of the damage taken when hit, at the cost of reducing durability with each proc.", + curse = false, + on_enchant = function() end, + requires_tool = false, +} + +-- unimplemented +mcl_enchanting.enchantments.unbreaking = { + name = "Unbreaking", + max_level = 3, + primary = {armor_head = true, armor_torso = true, armor_legs = true, armor_feet = true, pickaxe = true, shovel = true, axe = true, hoe = true, sword = true, fishing_rod = true, bow = true}, + secondary = {tool = true}, + disallow = {non_combat_armor = true}, + incompatible = {}, + weight = 5, + description = "Increases item durability.", + curse = false, + on_enchant = function() end, + requires_tool = true, +} + + + +--[[ +local pickaxes = {"mcl_tools:pick_wood", "mcl_tools:pick_stone", "mcl_tools:pick_gold", "mcl_tools:pick_iron", "mcl_tools:pick_diamond"} +local pickaxes_better_than_iron = {"mcl_tools:pick_iron", "mcl_tools:pick_diamond"} +local pickaxes_better_than_stone = {"mcl_tools:pick_stone", "mcl_tools:pick_gold", "mcl_tools:pick_iron", "mcl_tools:pick_diamond"} +local shovels = {"mcl_tools:shovel_wood", "mcl_tools:shovel_stone", "mcl_tools:shovel_gold", "mcl_tools:shovel_iron", "mcl_tools:shovel_diamond"} + +local silk_touch_tool_lists = { + ["mcl_books:bookshelf"] = true, + ["mcl_core:clay"] = true, + ["mcl_core:stone_with_coal"] = pickaxes, + ["group:coral_block"] = pickaxes, + ["group:coral"] = true, + ["group:coral_fan"] = true, + ["mcl_core:stone_with_diamond"] = pickaxes_better_than_iron, + ["mcl_core:stone_with_emerald"] = pickaxes_better_than_iron, + ["mcl_chests:ender_chest"] = pickaxes, + ["group:glass"] = true, + ["mcl_nether:glowstone"] = true, + ["mcl_core:dirt_with_grass"] = true, + ["mcl_core:gravel"] = true, + ["mcl_core:ice"] = true, + ["mcl_core:stone_with_lapis"] = pickaxes_better_than_stone, + ["group:leaves"] = true, + ["mcl_farming:melon"] = true, + ["group:huge_mushroom"] = true, + ["mcl_core:mycelium"] = true, + ["mcl_nether:quartz_ore"] = pickaxes, + ["mcl_core:packed_ice"] = true, + ["mcl_core:podzol"] = true, + ["mcl_core:stone_with_redstone"] = pickaxes_better_than_iron, + ["mcl_ocean:sea_lantern"] = true, + ["group:top_snow"] = shovels, + ["mcl_core:snowblock"] = shovels, + ["mcl_core:stone"] = pickaxes, +} + +minetest.register_on_mods_loaded(function() + local old_handle_node_drops = minetest.handle_node_drops + function minetest.handle_node_drops(pos, drops, digger) + if digger and digger:is_player() then + local wielditem = digger:get_wielded_item() + local tooldef = wielditem:get_definition() + if tooldef._silk_touch then + local nodename = minetest.get_node(pos).name + local nodedef = minetest.registered_nodes[nodename] + local silk_touch_spec = silk_touch_tool_lists[nodename] + local suitable_tool = false + local tool_list + if silk_touch_spec == true then + suitable_tool = true + elseif silk_touch_spec then + tool_list = silk_touch_spec + else + for k, v in pairs(nodedef.groups) do + if v > 0 then + local group_spec = silk_touch_tool_lists["group:" .. k] + if group_spec == true then + suitable_tool = true + elseif group_spec then + toollist = group_spec + break + end + end + end + end + if tool_list and not suitable_tool then + suitable_tool = (table.indexof(tool_list, tooldef._original_tool) ~= -1) + end + if suitable_tool then + drops = {nodename} + end + end + end + old_handle_node_drops(pos, drops, digger) + end +end) +--]] + + +--[[ + sharpness = { + name = "Sharpness", + max_level = 5, + create_itemdef = function(def, level) + def.tool_capabilities.damage_groups.fleshy = def.tool_capabilities.damage_groups.fleshy + (level + 1) / 2 + end, + }, + efficiency = { + name = "Efficiency", + max_level = 5, + create_itemdef = function(def, level) + local groupcaps = def.tool_capabilities.groupcaps + for _, groupcap in pairs(groupcaps) do + for i, t in pairs(groupcap.times) do + local m = 1 / t + m = m + math.pow(level, 2) + 1 + groupcap.times[i] = 1 / m + end + end + end, + }, + unbreaking = { + name = "Unbreaking", + max_level = 3, + create_itemdef = function(def, level) + local toolcaps = def.tool_capabilities + local armor_uses = def.groups.mcl_armor_uses + local factor = 0.5 + if toolcaps then + local groupcaps = toolcaps.groupcaps + for _, groupcap in pairs(groupcaps) do + groupcap.uses = math.floor(groupcap.uses * (1 + level)) + end + def.tool_capabilities.punch_attack_uses = math.floor(def.tool_capabilities.punch_attack_uses * (1 + level)) + elseif armor_uses then + def.groups.mcl_armor_uses = math.floor(armor_uses / (0.6 + (0.4 / (level + 1)))) + end + end + }, + },--]] + + diff --git a/mods/CORE/_mcl_enchanting/init.lua b/mods/CORE/mcl_enchanting/init.lua similarity index 76% rename from mods/CORE/_mcl_enchanting/init.lua rename to mods/CORE/mcl_enchanting/init.lua index 80b171db1a..5921d77d3b 100644 --- a/mods/CORE/_mcl_enchanting/init.lua +++ b/mods/CORE/mcl_enchanting/init.lua @@ -4,14 +4,19 @@ mcl_enchanting = { lapis_itemstring = "mcl_dye:blue", book_offset = vector.new(0, 0.75, 0), roman_numerals = dofile(modpath .. "/roman_numerals.lua"), -- https://exercism.io/tracks/lua/exercises/roman-numerals/solutions/73c2fb7521e347209312d115f872fa49 + enchantments = {}, + total_weight = 0, + all_item_groups = {}, + debug = true, } +dofile(modpath .. "/api.lua") dofile(modpath .. "/enchantments.lua") -dofile(modpath .. "/features.lua") -dofile(modpath .. "/core.lua") dofile(modpath .. "/command.lua") dofile(modpath .. "/tt.lua") -- dofile(modpath .. "/ui.lua") -- dofile(modpath .. "/fx.lua") -- dofile(modpath .. "/book.lua") -- dofile(modpath .. "/table.lua") + +minetest.register_on_mods_loaded(mcl_enchanting.initialize) diff --git a/mods/CORE/_mcl_enchanting/mod.conf b/mods/CORE/mcl_enchanting/mod.conf similarity index 100% rename from mods/CORE/_mcl_enchanting/mod.conf rename to mods/CORE/mcl_enchanting/mod.conf diff --git a/mods/CORE/_mcl_enchanting/models/mcl_enchanting_book.b3d b/mods/CORE/mcl_enchanting/models/mcl_enchanting_book.b3d similarity index 100% rename from mods/CORE/_mcl_enchanting/models/mcl_enchanting_book.b3d rename to mods/CORE/mcl_enchanting/models/mcl_enchanting_book.b3d diff --git a/mods/CORE/_mcl_enchanting/models/mcl_enchanting_book_entity.png b/mods/CORE/mcl_enchanting/models/mcl_enchanting_book_entity.png similarity index 100% rename from mods/CORE/_mcl_enchanting/models/mcl_enchanting_book_entity.png rename to mods/CORE/mcl_enchanting/models/mcl_enchanting_book_entity.png diff --git a/mods/CORE/_mcl_enchanting/roman_numerals.lua b/mods/CORE/mcl_enchanting/roman_numerals.lua similarity index 100% rename from mods/CORE/_mcl_enchanting/roman_numerals.lua rename to mods/CORE/mcl_enchanting/roman_numerals.lua diff --git a/mods/CORE/_mcl_enchanting/sounds/mcl_enchanting_enchant.ogg b/mods/CORE/mcl_enchanting/sounds/mcl_enchanting_enchant.ogg similarity index 100% rename from mods/CORE/_mcl_enchanting/sounds/mcl_enchanting_enchant.ogg rename to mods/CORE/mcl_enchanting/sounds/mcl_enchanting_enchant.ogg diff --git a/mods/CORE/_mcl_enchanting/table.lua b/mods/CORE/mcl_enchanting/table.lua similarity index 100% rename from mods/CORE/_mcl_enchanting/table.lua rename to mods/CORE/mcl_enchanting/table.lua diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_book_closed.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_book_closed.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_book_closed.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_book_closed.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_book_open.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_book_open.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_book_open.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_book_open.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_button.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_button.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button_background.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_button_background.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button_background.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_button_background.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button_hovered.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_button_hovered.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button_hovered.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_button_hovered.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button_off.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_button_off.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_button_off.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_button_off.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_1.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_1.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_1.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_1.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_10.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_10.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_10.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_10.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_11.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_11.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_11.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_11.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_12.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_12.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_12.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_12.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_13.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_13.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_13.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_13.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_14.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_14.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_14.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_14.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_15.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_15.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_15.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_15.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_16.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_16.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_16.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_16.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_17.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_17.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_17.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_17.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_18.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_18.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_18.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_18.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_2.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_2.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_2.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_2.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_3.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_3.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_3.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_3.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_4.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_4.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_4.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_4.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_5.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_5.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_5.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_5.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_6.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_6.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_6.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_6.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_7.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_7.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_7.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_7.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_8.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_8.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_8.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_8.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_9.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_9.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_glyph_9.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_glyph_9.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_lapis_background.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_lapis_background.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_lapis_background.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_lapis_background.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_1.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_1.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_1.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_1.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_1_off.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_1_off.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_1_off.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_1_off.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_2.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_2.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_2.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_2.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_2_off.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_2_off.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_2_off.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_2_off.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_3.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_3.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_3.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_3.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_3_off.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_3_off.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_number_3_off.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_number_3_off.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_table_bottom.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_table_bottom.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_table_bottom.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_table_bottom.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_table_side.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_table_side.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_table_side.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_table_side.png diff --git a/mods/CORE/_mcl_enchanting/textures/mcl_enchanting_table_top.png b/mods/CORE/mcl_enchanting/textures/mcl_enchanting_table_top.png similarity index 100% rename from mods/CORE/_mcl_enchanting/textures/mcl_enchanting_table_top.png rename to mods/CORE/mcl_enchanting/textures/mcl_enchanting_table_top.png diff --git a/mods/CORE/_mcl_enchanting/tt.lua b/mods/CORE/mcl_enchanting/tt.lua similarity index 78% rename from mods/CORE/_mcl_enchanting/tt.lua rename to mods/CORE/mcl_enchanting/tt.lua index 41ceb6249d..f9b8e34c1d 100644 --- a/mods/CORE/_mcl_enchanting/tt.lua +++ b/mods/CORE/mcl_enchanting/tt.lua @@ -5,7 +5,7 @@ function mcl_enchanting.enchantments_snippet(_, _, itemstack) local enchantments = mcl_enchanting.get_enchantments(itemstack) local text = "" for enchantment, level in pairs(enchantments) do - text = text .. mcl_enchanting.get_enchantment_description(enchantment, level) .. "\n" + text = text .. mcl_enchanting.get_colorized_enchantment_description(enchantment, level) .. "\n" end if text ~= "" then return text, false diff --git a/mods/HELP/tt/init.lua b/mods/HELP/tt/init.lua index d1bb6d6b8b..a2b747ce83 100644 --- a/mods/HELP/tt/init.lua +++ b/mods/HELP/tt/init.lua @@ -60,8 +60,10 @@ minetest.register_on_mods_loaded(append_snippets) tt.reload_itemstack_description = function(itemstack) local itemstring = itemstack:get_name() local def = itemstack:get_definition() - if should_change(itemstring, def) then - local meta = itemstack:get_meta() + local meta = itemstack:get_meta() + if def._mcl_generate_description then + def._mcl_generate_description(itemstack) + elseif should_change(itemstring, def) and meta:get_string("name") == "" then local orig_desc = def._tt_original_description local desc = apply_snippets(orig_desc, itemstring, itemstack:get_tool_capabilities(), itemstack) if desc ~= orig_desc then diff --git a/mods/ITEMS/mcl_anvils/depends.txt b/mods/ITEMS/mcl_anvils/depends.txt index 98a3e017eb..c17e5a0b20 100644 --- a/mods/ITEMS/mcl_anvils/depends.txt +++ b/mods/ITEMS/mcl_anvils/depends.txt @@ -3,3 +3,4 @@ mcl_formspec mcl_sounds mcl_core? screwdriver? +tt diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index ce74a10d9d..fbc1c9d03c 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -170,23 +170,16 @@ local function update_anvil_slots(meta) new_name = string.sub(new_name, 1, MAX_NAME_LENGTH) -- Don't rename if names are identical if new_name ~= old_name then + -- Save the raw name internally + meta:set_string("name", new_name) -- Rename item if new_name == "" then - -- Empty name - if name_item:get_definition()._mcl_generate_description then - -- _mcl_generate_description(itemstack): If defined, set custom item description of itemstack. - name_item:get_definition()._mcl_generate_description(name_item) - else - -- Otherwise, just clear description - meta:set_string("description", "") - end + tt.reload_itemstack_description(name_item) else -- Custom name set. Colorize it! -- This makes the name visually different from unnamed items meta:set_string("description", minetest.colorize(NAME_COLOR, new_name)) end - -- Save the raw name internally, too - meta:set_string("name", new_name) new_output = name_item elseif just_rename then new_output = "" diff --git a/mods/ITEMS/mcl_bows/bow.lua b/mods/ITEMS/mcl_bows/bow.lua index 21b55c31ba..53776df3b6 100644 --- a/mods/ITEMS/mcl_bows/bow.lua +++ b/mods/ITEMS/mcl_bows/bow.lua @@ -76,7 +76,7 @@ end local player_shoot_arrow = function(itemstack, player, power, damage, is_critical) local arrow_stack, arrow_stack_id = get_arrow(player) local arrow_itemstring - local has_infinity_enchantment = rawget(_G, "mcl_enchanting") and mcl_enchanting.get_enchantment(player:get_wielded_item(), "infinity") > 0 + local has_infinity_enchantment = mcl_enchanting.has_enchantment(player:get_wielded_item(), "infinity") if minetest.is_creative_enabled(player:get_player_name()) then if arrow_stack then @@ -165,7 +165,7 @@ for level=0, 2 do groups = {not_in_creative_inventory=1, not_in_craft_guide=1, bow=1}, on_drop = function(itemstack, dropper, pos) reset_bow_state(dropper) - if minetest.get_item_group(itemstack:get_name(), "enchanted") > 0 then + if mcl_enchanting.is_enchanted(itemstack) then itemstack:set_name("mcl_bows:bow_enchanted") else itemstack:set_name("mcl_bows:bow") @@ -190,7 +190,7 @@ controls.register_on_release(function(player, key, time) wielditem:get_name()=="mcl_bows:bow_0_enchanted" or wielditem:get_name()=="mcl_bows:bow_1_enchanted" or wielditem:get_name()=="mcl_bows:bow_2_enchanted") then local has_shot = false - local enchanted = minetest.get_item_group(wielditem:get_name(), "enchanted") > 0 + local enchanted = mcl_enchanting.is_enchanted(wielditem) local speed, damage local p_load = bow_load[player:get_player_name()] local charge @@ -253,7 +253,7 @@ controls.register_on_hold(function(player, key, time) local inv = minetest.get_inventory({type="player", name=name}) local wielditem = player:get_wielded_item() if bow_load[name] == nil and (wielditem:get_name()=="mcl_bows:bow" or wielditem:get_name()=="mcl_bows:bow_enchanted") and (creative or get_arrow(player)) then - local enchanted = (wielditem:get_name()=="mcl_bows:bow_enchanted") + local enchanted = mcl_enchanting.is_enchanted(wielditem) if enchanted then wielditem:set_name("mcl_bows:bow_0_enchanted") else diff --git a/mods/ITEMS/mcl_bows/depends.txt b/mods/ITEMS/mcl_bows/depends.txt index 130c4aceae..a797e71843 100644 --- a/mods/ITEMS/mcl_bows/depends.txt +++ b/mods/ITEMS/mcl_bows/depends.txt @@ -8,3 +8,4 @@ doc? doc_identifier? mesecons_button? mcl_particles +mcl_enchanting diff --git a/mods/PLAYER/mcl_death_drop/depends.txt b/mods/PLAYER/mcl_death_drop/depends.txt index 2bbf820fd6..4c2d1c21fd 100644 --- a/mods/PLAYER/mcl_death_drop/depends.txt +++ b/mods/PLAYER/mcl_death_drop/depends.txt @@ -1 +1,2 @@ mcl_armor +mcl_enchanting diff --git a/mods/PLAYER/mcl_death_drop/init.lua b/mods/PLAYER/mcl_death_drop/init.lua index 54672a5db1..adad4b1e71 100644 --- a/mods/PLAYER/mcl_death_drop/init.lua +++ b/mods/PLAYER/mcl_death_drop/init.lua @@ -23,7 +23,7 @@ minetest.register_on_dieplayer(function(player) local z = math.random(0, 9)/3 pos.x = pos.x + x pos.z = pos.z + z - if not void_deadly and drop then + if not void_deadly and drop and mcl_enchanting.get_enchantment(stack, "curse_of_vanishing") > 0 then local def = minetest.registered_items[stack:get_name()] if def and def.on_drop then stack = def.on_drop(stack, player, pos)