mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-25 04:13:44 +01:00
Make it possible to craft a banner on an enchanted shield
This commit is contained in:
parent
60d877b718
commit
fc9e83c059
@ -301,7 +301,8 @@ function mcl_enchanting.initialize()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_enchanting.random(pr, ...)
|
function
|
||||||
|
(pr, ...)
|
||||||
local r = pr and pr:next(...) or math.random(...)
|
local r = pr and pr:next(...) or math.random(...)
|
||||||
|
|
||||||
if pr and not ({...})[1] then
|
if pr and not ({...})[1] then
|
||||||
@ -326,7 +327,8 @@ function mcl_enchanting.get_random_enchantment(itemstack, treasure, weighted, ex
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return #possible > 0 and possible[mcl_enchanting.random(pr, 1, #possible)]
|
return #possible > 0 and possible[
|
||||||
|
(pr, 1, #possible)]
|
||||||
end
|
end
|
||||||
|
|
||||||
function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr)
|
function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_level, treasure, no_reduced_bonus_chance, ignore_already_enchanted, pr)
|
||||||
@ -339,10 +341,14 @@ function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_leve
|
|||||||
itemstack = ItemStack(itemstack)
|
itemstack = ItemStack(itemstack)
|
||||||
|
|
||||||
local enchantability = minetest.get_item_group(itemname, "enchantability")
|
local enchantability = minetest.get_item_group(itemname, "enchantability")
|
||||||
enchantability = 1 + mcl_enchanting.random(pr, 0, math.floor(enchantability / 4)) + mcl_enchanting.random(pr, 0, math.floor(enchantability / 4))
|
enchantability = 1 +
|
||||||
|
(pr, 0, math.floor(enchantability / 4)) +
|
||||||
|
(pr, 0, math.floor(enchantability / 4))
|
||||||
|
|
||||||
enchantment_level = enchantment_level + enchantability
|
enchantment_level = enchantment_level + enchantability
|
||||||
enchantment_level = enchantment_level + enchantment_level * (mcl_enchanting.random(pr) + mcl_enchanting.random(pr) - 1) * 0.15
|
enchantment_level = enchantment_level + enchantment_level * (
|
||||||
|
(pr) +
|
||||||
|
(pr) - 1) * 0.15
|
||||||
enchantment_level = math.max(math.floor(enchantment_level + 0.5), 1)
|
enchantment_level = math.max(math.floor(enchantment_level + 0.5), 1)
|
||||||
|
|
||||||
local enchantments = {}
|
local enchantments = {}
|
||||||
@ -389,7 +395,8 @@ function mcl_enchanting.generate_random_enchantments(itemstack, enchantment_leve
|
|||||||
mcl_enchanting.enchant(itemstack, selected_enchantment, enchantment_power)
|
mcl_enchanting.enchant(itemstack, selected_enchantment, enchantment_power)
|
||||||
end
|
end
|
||||||
|
|
||||||
until not no_reduced_bonus_chance and mcl_enchanting.random(pr) >= (enchantment_level + 1) / 50
|
until not no_reduced_bonus_chance and
|
||||||
|
(pr) >= (enchantment_level + 1) / 50
|
||||||
|
|
||||||
return enchantments, description
|
return enchantments, description
|
||||||
end
|
end
|
||||||
@ -417,7 +424,8 @@ function mcl_enchanting.enchant_uniform_randomly(stack, exclude, pr)
|
|||||||
local enchantment = mcl_enchanting.get_random_enchantment(stack, true, false, exclude, pr)
|
local enchantment = mcl_enchanting.get_random_enchantment(stack, true, false, exclude, pr)
|
||||||
|
|
||||||
if enchantment then
|
if enchantment then
|
||||||
mcl_enchanting.enchant(stack, enchantment, mcl_enchanting.random(pr, 1, mcl_enchanting.enchantments[enchantment].max_level))
|
mcl_enchanting.enchant(stack, enchantment,
|
||||||
|
(pr, 1, mcl_enchanting.enchantments[enchantment].max_level))
|
||||||
end
|
end
|
||||||
|
|
||||||
return stack
|
return stack
|
||||||
|
Loading…
Reference in New Issue
Block a user