From a7ff5be28b0ee981b7147c6526e635a0f1aa702c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 23 Dec 2020 15:18:20 +0100 Subject: [PATCH] Luck of the Sea --- mods/ITEMS/mcl_enchanting/enchantments.lua | 5 ++--- mods/ITEMS/mcl_fishing/init.lua | 11 ++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_enchanting/enchantments.lua b/mods/ITEMS/mcl_enchanting/enchantments.lua index 1e09fabed2..7d53f012bb 100644 --- a/mods/ITEMS/mcl_enchanting/enchantments.lua +++ b/mods/ITEMS/mcl_enchanting/enchantments.lua @@ -375,8 +375,7 @@ end power_range_table = {{12, 50}, {19, 50}, {26, 50}}, }]]-- --- unimplemented ---[[mcl_enchanting.enchantments.luck_of_the_sea = { +mcl_enchanting.enchantments.luck_of_the_sea = { name = S("Luck of the Sea"), max_level = 3, primary = {fishing_rod = true}, @@ -390,7 +389,7 @@ end requires_tool = false, treasure = false, power_range_table = {{15, 61}, {24, 71}, {33, 81}}, -}]]-- +} -- implemented in mcl_fishing mcl_enchanting.enchantments.lure = { diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index 4fbc1d0b26..c95dd20e51 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -52,10 +52,15 @@ local fish = function(itemstack, player) local items local itemcount = 1 local itemwear = 0 - -- FIXME: Maybe use a better seeding local pr = PseudoRandom(os.time() * math.random(1, 100)) local r = pr:next(1, 100) - if r <= 85 then + local fish_values = {85, 84.8, 84.7, 84.5} + local junk_values = {10, 8.1, 6.1, 4.2} + local luck_of_the_sea = math.min(mcl_enchanting.get_enchantment(itemstack, "luck_of_the_sea"), 3) + local index = luck_of_the_sea + 1 + local fish_value = fish_values[index] + local junk_value = junk_values[index] + fish_value + if r <= fish_value then -- Fish items = mcl_loot.get_loot({ items = { @@ -65,7 +70,7 @@ local fish = function(itemstack, player) { itemstring = "mcl_fishing:pufferfish_raw", weight = 13 }, } }, pr) - elseif r <= 95 then + elseif r <= junk_value then -- Junk items = mcl_loot.get_loot({ items = {