From 9df149c4892fdd908f1a5fd38ac03309cb006fa3 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 15 Feb 2013 15:32:49 -0800 Subject: [PATCH] Huge Mushrooms now work for Tree Feller (UNTESTED) --- Changelog.txt | 1 + .../java/com/gmail/nossr50/config/Config.java | 3 ++ .../nossr50/skills/acrobatics/Acrobatics.java | 2 +- .../axes/AxeBonusDamageEventHandler.java | 2 +- .../skills/woodcutting/TreeFeller.java | 29 +++++++++++++++++++ .../skills/woodcutting/Woodcutting.java | 13 +++++++++ .../com/gmail/nossr50/util/BlockChecks.java | 2 ++ src/main/resources/config.yml | 2 ++ 8 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index f942dfad3..d36ca754c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -73,6 +73,7 @@ Version 1.4.00-dev ! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent ! Moved Hylian Luck into a separate listener since it actually cancels the event and shouldn't just be on MONITOR. ! Changed how Tree Feller is handled, it should now put less stress on the CPU + ! Changed Tree Feller to work on huge mushrooms ! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values ! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API. ! Changed the way party commands work, use /party ? to check how to use the new commands diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 602e9f9c6..3f3face29 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -276,6 +276,9 @@ public class Config extends ConfigLoader { public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); } public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); } public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); } + public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); } + public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); } + public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); } public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); } diff --git a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java index da5551ab8..49b6cf57b 100644 --- a/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java +++ b/src/main/java/com/gmail/nossr50/skills/acrobatics/Acrobatics.java @@ -22,4 +22,4 @@ public class Acrobatics { public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled(); public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled(); -} +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java index 7c53f2529..2caf3edc1 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxeBonusDamageEventHandler.java @@ -28,4 +28,4 @@ public class AxeBonusDamageEventHandler { event.setDamage(damage + damageBonus); } -} +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index 478237fc3..9488939b9 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -175,6 +175,35 @@ public final class TreeFeller { } switch (block.getType()) { + case HUGE_MUSHROOM_1: + case HUGE_MUSHROOM_2: + Woodcutting.checkForDoubleDrop(mcMMOPlayer, block); + + try { + xp += Woodcutting.getExperienceFromLog(block, ExperienceGainMethod.TREE_FELLER); + } + catch (IllegalArgumentException exception) { + break; + } + + //Stems have a block data value of 15 and should not drop mushrooms + //0-2 mushrooms drop when you break a block + if(block.getData() != (byte) 15) { + switch(block.getType()) { + case HUGE_MUSHROOM_1: + Misc.randomDropItem(block.getLocation(), new ItemStack(Material.BROWN_MUSHROOM, 1), 50); + Misc.randomDropItem(block.getLocation(), new ItemStack(Material.BROWN_MUSHROOM, 1), 50); + break; + case HUGE_MUSHROOM_2: + Misc.randomDropItem(block.getLocation(), new ItemStack(Material.RED_MUSHROOM, 1), 50); + Misc.randomDropItem(block.getLocation(), new ItemStack(Material.RED_MUSHROOM, 1), 50); + break; + default: + break; + } + } + + break; case LOG: Woodcutting.checkForDoubleDrop(mcMMOPlayer, block); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 6fc07d39f..ec26bc39e 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -93,6 +93,19 @@ public final class Woodcutting { * @throws IllegalArgumentException if 'log' is invalid */ protected static int getExperienceFromLog(Block log, ExperienceGainMethod experienceGainMethod) { + + //Mushrooms aren't trees so we could never get species data from them + if(log.getType() == Material.HUGE_MUSHROOM_1 || log.getType() == Material.HUGE_MUSHROOM_2) { + switch(log.getType()) { + case HUGE_MUSHROOM_1: + return Config.getInstance().getWoodcuttingXPHugeBrownMushroom(); + case HUGE_MUSHROOM_2: + return Config.getInstance().getWoodcuttingXPHugeRedMushroom(); + default: + throw new IllegalArgumentException(); + } + } + TreeSpecies logType = TreeSpecies.getByData(extractLogItemData(log.getData())); // Apparently species can be null in certain cases (custom server mods?) diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index f67335a0b..c2e164ad2 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -300,6 +300,8 @@ public final class BlockChecks { switch (block.getType()) { case LOG: case LEAVES: + case HUGE_MUSHROOM_1: + case HUGE_MUSHROOM_2: return true; default: diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b4363f1b8..eda21059e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -271,6 +271,8 @@ Experience: Spruce: 80 Birch: 90 Jungle: 100 + Huge_Mushroom_Red: 70 + Huge_Mushroom_Brown: 70 Herbalism: Sugar_Cane: 30 Cactus: 30