Scale fishing drop chance by lure rather than subtracting 1

Fixes mcMMO-Dev/mcMMO#3383
Added config option for lure enchantment modifier
Fixes lure enchantment having no effect on drops from offhand
This commit is contained in:
ezeiger92 2018-02-15 15:48:21 -08:00
parent 6d2003d577
commit feeb17d6f0
3 changed files with 18 additions and 1 deletions

View File

@ -178,6 +178,10 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getFishingLureModifier() < 0) {
reason.add("Abilities.Fishing.Lure_Modifier should be at least 0!");
}
if (getDetonatorItem() == null) {
reason.add("Skills.Mining.Detonator_Item is invalid!");
}
@ -481,6 +485,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
public boolean getFishingOverrideTreasures() { return config.getBoolean("Skills.Fishing.Override_Vanilla_Treasures", true); }
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
public double getFishingLureModifier() { return config.getDouble("Skills.Fishing.Lure_Modifier", 4.0D); }
/* Mining */
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }

View File

@ -478,7 +478,18 @@ public class FishingManager extends SkillManager {
*/
private FishingTreasure getFishingTreasure() {
double diceRoll = Misc.getRandom().nextDouble() * 100;
diceRoll -= getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
int luck;
if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
}
else {
// We know something was caught, so if the rod wasn't in the main hand it must be in the offhand
luck = getPlayer().getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK);
}
// Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck.
diceRoll *= (1.0 - luck * Config.getInstance().getFishingLureModifier() / 100);
FishingTreasure treasure = null;

View File

@ -330,6 +330,7 @@ Skills:
Override_Vanilla_Treasures: true
# Always catch fish, even when treasure is found
Extra_Fish: false
Lure_Modifier: 4.0
Herbalism:
Level_Cap: 0
Prevent_AFK_Leveling: true