Sharpness

This commit is contained in:
Elias Fleckenstein 2020-11-02 17:58:13 +01:00
parent b89ffb12f2
commit 8a406ad968
2 changed files with 28 additions and 20 deletions

View File

@ -69,7 +69,7 @@ mcl_enchanting.enchantments.curse_of_vanishing = {
disallow = {clock = true}, disallow = {clock = true},
incompatible = {}, incompatible = {},
weight = 1, weight = 1,
description = "Except when in creative mode, items cannot be removed from armor slots except due to death or breaking.", description = "Item destroyed on death.",
curse = true, curse = true,
on_enchant = function() end, on_enchant = function() end,
requires_tool = false, requires_tool = false,
@ -101,7 +101,7 @@ mcl_enchanting.enchantments.efficiency = {
weight = 10, weight = 10,
description = "Increases mining speed.", description = "Increases mining speed.",
curse = false, curse = false,
on_enchant = function(itemstack, level, itemdef) on_enchant = function(itemstack, level)
local tool_capabilities = itemstack:get_tool_capabilities() local tool_capabilities = itemstack:get_tool_capabilities()
local groupcaps = {} local groupcaps = {}
for group, capability in pairs(tool_capabilities.groupcaps) do for group, capability in pairs(tool_capabilities.groupcaps) do
@ -129,8 +129,8 @@ mcl_enchanting.enchantments.feather_falling = {
requires_tool = false, requires_tool = false,
} }
-- unimplemented -- requires missing MineClone2 feature
mcl_enchanting.enchantments.fire_aspect = { --[[mcl_enchanting.enchantments.fire_aspect = {
name = "Fire Aspect", name = "Fire Aspect",
max_level = 2, max_level = 2,
primary = {sword = true}, primary = {sword = true},
@ -142,7 +142,7 @@ mcl_enchanting.enchantments.fire_aspect = {
curse = false, curse = false,
on_enchant = function() end, on_enchant = function() end,
requires_tool = false, requires_tool = false,
} }]]--
-- unimplemented -- unimplemented
mcl_enchanting.enchantments.fire_protection = { mcl_enchanting.enchantments.fire_protection = {
@ -159,8 +159,8 @@ mcl_enchanting.enchantments.fire_protection = {
requires_tool = false, requires_tool = false,
} }
-- unimplemented -- requires missing MineClone2 feature
mcl_enchanting.enchantments.flame = { --[[mcl_enchanting.enchantments.flame = {
name = "Flame", name = "Flame",
max_level = 1, max_level = 1,
primary = {bow = true}, primary = {bow = true},
@ -172,7 +172,7 @@ mcl_enchanting.enchantments.flame = {
curse = false, curse = false,
on_enchant = function() end, on_enchant = function() end,
requires_tool = false, requires_tool = false,
} }]]--
-- unimplemented -- unimplemented
mcl_enchanting.enchantments.fortune = { mcl_enchanting.enchantments.fortune = {
@ -369,7 +369,7 @@ mcl_enchanting.enchantments.respiration = {
requires_tool = false, requires_tool = false,
} }
-- unimplemented -- implemented via on_enchant
mcl_enchanting.enchantments.sharpness = { mcl_enchanting.enchantments.sharpness = {
name = "Sharpness", name = "Sharpness",
max_level = 5, max_level = 5,
@ -378,9 +378,17 @@ mcl_enchanting.enchantments.sharpness = {
disallow = {}, disallow = {},
incompatible = {bane_of_anthropods = true, smite = true}, incompatible = {bane_of_anthropods = true, smite = true},
weight = 5, weight = 5,
description = "Increases damage and applies Slowness IV to arthropod mobs (spiders, cave spiders, silverfish and endermites).", description = "Increases damage.",
curse = false, curse = false,
on_enchant = function() end, on_enchant = function(itemstack, level)
local tool_capabilities = itemstack:get_tool_capabilities()
local damage_groups = {}
for group, damage in pairs(tool_capabilities.damage_groups) do
damage_groups[group] = damage + level * 0.5
end
tool_capabilities.damage_groups = damage_groups
itemstack:get_meta():set_tool_capabilities(tool_capabilities)
end,
requires_tool = false, requires_tool = false,
} }
@ -430,8 +438,8 @@ mcl_enchanting.enchantments.soul_speed = {
requires_tool = false, requires_tool = false,
} }
-- unimplemented -- requires missing MineClone2 feature
mcl_enchanting.enchantments.sweeping_edge = { --[[mcl_enchanting.enchantments.sweeping_edge = {
name = "Sweeping Edge", name = "Sweeping Edge",
max_level = 3, max_level = 3,
primary = {sword = true}, primary = {sword = true},
@ -443,7 +451,7 @@ mcl_enchanting.enchantments.sweeping_edge = {
curse = false, curse = false,
on_enchant = function() end, on_enchant = function() end,
requires_tool = false, requires_tool = false,
} }]]--
-- unimplemented -- unimplemented
mcl_enchanting.enchantments.thorns = { mcl_enchanting.enchantments.thorns = {
@ -471,13 +479,13 @@ mcl_enchanting.enchantments.unbreaking = {
weight = 5, weight = 5,
description = "Increases item durability.", description = "Increases item durability.",
curse = false, curse = false,
on_enchant = function(itemstack, level, itemdef) on_enchant = function(itemstack, level)
local new_capabilities = itemstack:get_tool_capabilities() local tool_capabilities = itemstack:get_tool_capabilities()
for group, capability in pairs(new_capabilities.groupcaps) do for group, capability in pairs(tool_capabilities.groupcaps) do
capability.uses = capability.uses * (1 + level) capability.uses = capability.uses * (1 + level)
end end
new_capabilities.punch_attack_uses = new_capabilities.punch_attack_uses * (1 + level) tool_capabilities.punch_attack_uses = tool_capabilities.punch_attack_uses * (1 + level)
itemstack:get_meta():set_tool_capabilities(new_capabilities) itemstack:get_meta():set_tool_capabilities(tool_capabilities)
end, end,
requires_tool = true, requires_tool = true,
} }

View File

@ -12,7 +12,7 @@ function mcl_enchanting.set_enchantments(itemstack, enchantments)
for enchantment, level in pairs(enchantments) do for enchantment, level in pairs(enchantments) do
local enchantment_def = mcl_enchanting.enchantments[enchantment] local enchantment_def = mcl_enchanting.enchantments[enchantment]
if enchantment_def.on_enchant then if enchantment_def.on_enchant then
enchantment_def.on_enchant(itemstack, level, itemdef) enchantment_def.on_enchant(itemstack, level)
end end
end end
end end