From 40b609ccd8a4a49b278c5780fbb60be3e11e814a Mon Sep 17 00:00:00 2001 From: ezeiger92 Date: Thu, 15 Feb 2018 13:38:10 -0800 Subject: [PATCH 1/3] Respect unbreakable tag on items when attempting durability changes Fixes mcMMO-Dev/mcMMO#3327 Fixes mcMMO-Dev/mcMMO#3391 --- src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index e384d07bc..860a60117 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -188,6 +188,10 @@ public class SkillUtils { * @param maxDamageModifier the amount to adjust the max damage by */ public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier, double maxDamageModifier) { + if(itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { + return; + } + Material type = itemStack.getType(); short maxDurability = mcMMO.getRepairableManager().isRepairable(type) ? mcMMO.getRepairableManager().getRepairable(type).getMaximumDurability() : type.getMaxDurability(); durabilityModifier = (int) Math.min(durabilityModifier / (itemStack.getEnchantmentLevel(Enchantment.DURABILITY) + 1), maxDurability * maxDamageModifier); From 6d2003d57788f528bf3cbbf8e8953c0bfd28f360 Mon Sep 17 00:00:00 2001 From: ezeiger92 Date: Thu, 15 Feb 2018 13:59:10 -0800 Subject: [PATCH 2/3] Remove offhand fishing rod if not in main hand Fixes mcMMO-Dev/mcMMO#3342 Fixed style error in last commit --- .../java/com/gmail/nossr50/skills/fishing/FishingManager.java | 3 +++ src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 59e8b93cc..1322ee934 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -134,6 +134,9 @@ public class FishingManager extends SkillManager { if (player.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) { player.getInventory().setItemInMainHand(null); } + else if (player.getInventory().getItemInOffHand().getType() == Material.FISHING_ROD) { + player.getInventory().setItemInOffHand(null); + } LivingEntity kraken = (LivingEntity) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID)); kraken.setCustomName(AdvancedConfig.getInstance().getKrakenName()); diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index 860a60117..abf90f52f 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -188,7 +188,7 @@ public class SkillUtils { * @param maxDamageModifier the amount to adjust the max damage by */ public static void handleDurabilityChange(ItemStack itemStack, int durabilityModifier, double maxDamageModifier) { - if(itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { + if (itemStack.hasItemMeta() && itemStack.getItemMeta().isUnbreakable()) { return; } From feeb17d6f0ea39edcdc8be8afe616dff6b636fcc Mon Sep 17 00:00:00 2001 From: ezeiger92 Date: Thu, 15 Feb 2018 15:48:21 -0800 Subject: [PATCH 3/3] 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 --- src/main/java/com/gmail/nossr50/config/Config.java | 5 +++++ .../nossr50/skills/fishing/FishingManager.java | 13 ++++++++++++- src/main/resources/config.yml | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 53fee13c0..730527ce7 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -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")); } diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index 1322ee934..67475571e 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -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; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b03fea08a..26a7f973c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -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