From 04224b309a042d36f58f23797132fc91be95f2fc Mon Sep 17 00:00:00 2001 From: GJ Date: Thu, 11 Jul 2013 14:41:23 -0400 Subject: [PATCH] Add snow to excavation. No treasures will drop from snow by default, but they can be added to the treasures.yml file by specifying "Drops_From: Snow: true" Adds #1229 --- Changelog.txt | 1 + .../config/treasure/TreasureConfig.java | 23 +++++++++++++------ .../treasure/ExcavationTreasure.java | 15 +++++++++++- .../com/gmail/nossr50/util/BlockUtils.java | 2 ++ src/main/resources/config.yml | 2 ++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 165d3d4ff..405e9a19c 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.07-dev + + Added snow to excavation ! Improved profile saving ! Updated localization files diff --git a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java index 18428d050..bf2bd655e 100644 --- a/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java +++ b/src/main/java/com/gmail/nossr50/config/treasure/TreasureConfig.java @@ -25,13 +25,14 @@ import com.gmail.nossr50.datatypes.treasure.Treasure; public class TreasureConfig extends ConfigLoader { private static TreasureConfig instance; - public List excavationFromDirt = new ArrayList(); - public List excavationFromGrass = new ArrayList(); - public List excavationFromSand = new ArrayList(); - public List excavationFromGravel = new ArrayList(); - public List excavationFromClay = new ArrayList(); - public List excavationFromMycel = new ArrayList(); - public List excavationFromSoulSand = new ArrayList(); + public List excavationFromDirt = new ArrayList(); + public List excavationFromGrass = new ArrayList(); + public List excavationFromSand = new ArrayList(); + public List excavationFromGravel = new ArrayList(); + public List excavationFromClay = new ArrayList(); + public List excavationFromMycel = new ArrayList(); + public List excavationFromSoulSand = new ArrayList(); + public List excavationFromSnow = new ArrayList(); public List hylianFromBushes = new ArrayList(); public List hylianFromFlowers = new ArrayList(); @@ -248,6 +249,10 @@ public class TreasureConfig extends ConfigLoader { eTreasure.setDropsFromSoulSand(); } + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Snow", false)) { + eTreasure.setDropsFromSnow(); + } + if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) { hTreasure.setDropsFromBushes(); } @@ -437,6 +442,10 @@ public class TreasureConfig extends ConfigLoader { if (eTreasure.getDropsFromSoulSand()) { excavationFromSoulSand.add(eTreasure); } + + if (eTreasure.getDropsFromSnow()) { + excavationFromSnow.add(eTreasure); + } } } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java b/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java index efe495aaa..75d28f40b 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java +++ b/src/main/java/com/gmail/nossr50/datatypes/treasure/ExcavationTreasure.java @@ -3,7 +3,7 @@ package com.gmail.nossr50.datatypes.treasure; import org.bukkit.inventory.ItemStack; public class ExcavationTreasure extends Treasure { - // dirt | grass | sand | gravel | clay | mycel | soulsand + // dirt | grass | sand | gravel | clay | mycel | soulsand | snow // 00000001 - dirt 1 // 00000010 - grass 2 // 00000100 - sand 4 @@ -11,6 +11,7 @@ public class ExcavationTreasure extends Treasure { // 00010000 - clay 16 // 00100000 - mycel 32 // 01000000 - soulsand 64 + // 10000000 - snow 128 private byte dropsFrom = 0x0; public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) { @@ -55,6 +56,10 @@ public class ExcavationTreasure extends Treasure { return getDropFromMask(64); } + public boolean getDropsFromSnow() { + return getDropFromMask(128); + } + private boolean getDropFromMask(int mask) { return ((dropsFrom & mask) > 0) ? true : false; } @@ -88,6 +93,10 @@ public class ExcavationTreasure extends Treasure { setDropFromMask(64); } + public void setDropsFromSnow() { + setDropFromMask(128); + } + private void setDropFromMask(int mask) { dropsFrom |= mask; } @@ -121,6 +130,10 @@ public class ExcavationTreasure extends Treasure { unsetDropFromMask(64); } + public void unsetDropsFromSnow() { + unsetDropFromMask(128); + } + private void unsetDropFromMask(int mask) { dropsFrom &= ~mask; } diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index d53c0468e..f816f86ff 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -180,6 +180,8 @@ public final class BlockUtils { case GRAVEL: case MYCEL: case SAND: + case SNOW: + case SNOW_BLOCK: case SOUL_SAND: return true; diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9154898af..c22fbd2bf 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -313,6 +313,8 @@ Experience: Gravel: 40 Mycel: 40 Sand: 40 + Snow: 20 + Snow_Block: 40 Soul_Sand: 40 Woodcutting: Oak: 70