From 2f0a58b968dea3c99fe615749294881025f07f65 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sat, 16 Mar 2019 20:26:26 -0700 Subject: [PATCH] 2.1.18 - It turns out Kelp is actually made up of 2 blocks mixed together --- Changelog.txt | 7 +++ pom.xml | 2 +- .../nossr50/skills/herbalism/Herbalism.java | 47 ++++++++++++++++++- .../skills/herbalism/HerbalismManager.java | 11 ++++- src/main/resources/experience.yml | 1 + 5 files changed, 64 insertions(+), 4 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index a236199f7..6ea5050be 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -7,6 +7,13 @@ Key: ! Change - Removal +Version 2.1.18 + You will need to add Kelp to your experience.yml file for this fix to be fully functional + Breaking Kelp will now properly count its XP + Added "Kelp" to experience.yml (Kelp is actually made up of two blocks mixed together) + It is recommended that Kelp and Kelp_Plant have the same XP value in experience.yml + mcMMO will now calculate XP for plants that are taller than naturally allowed (Cactus above 3 block height, etc) + Version 2.1.17 Fixed a logic error that resulted in Drowned giving no XP Fixed a bug that resulted in mob spawner entities to not be marked for no xp after being transforming into Drowned diff --git a/pom.xml b/pom.xml index 19905621b..edb8ea5d2 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.17 + 2.1.18 mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index bae27e8fd..c0901efb4 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -91,7 +91,7 @@ public class Herbalism { } } else { // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally - for (int y = 1; y < 3; y++) { + for (int y = 1; y < 256; y++) { Block relativeBlock = block.getRelative(BlockFace.UP, y); if (relativeBlock.getType() != blockType) { @@ -109,6 +109,51 @@ public class Herbalism { return dropAmount; } + /** + * Calculate the drop amounts for kelp plants based on the blocks + * relative to them. + * + * @param blockState + * The {@link BlockState} of the bottom block of the plant + * @return the number of bonus drops to award from the blocks in this plant + */ + protected static int calculateKelpPlantDrops(BlockState blockState) { + Block block = blockState.getBlock(); + + int dropAmount = mcMMO.getPlaceStore().isTrue(block) ? 0 : 1; + + int kelpMaxHeight = 256; + + // Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally + for (int y = 1; y < kelpMaxHeight; y++) { + Block relativeUpBlock = block.getRelative(BlockFace.UP, y); + + if(!isKelp(relativeUpBlock)) + break; + + dropAmount = addKelpDrops(dropAmount, relativeUpBlock); + } + + return dropAmount; + } + + private static int addKelpDrops(int dropAmount, Block relativeBlock) { + if (isKelp(relativeBlock) && !mcMMO.getPlaceStore().isTrue(relativeBlock)) { + dropAmount++; + } else { + mcMMO.getPlaceStore().setFalse(relativeBlock); + } + + return dropAmount; + } + + private static boolean isKelp(Block relativeBlock) { + Material kelptype_1 = Material.KELP_PLANT; + Material kelptype_2 = Material.KELP; + + return relativeBlock.getType() == kelptype_1 || relativeBlock.getType() == kelptype_2; + } + /** * Convert blocks affected by the Green Thumb & Green Terra abilities. * diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java index ebff6c26e..09d095509 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/HerbalismManager.java @@ -126,7 +126,8 @@ public class HerbalismManager extends SkillManager { public void herbalismBlockCheck(BlockState blockState) { Player player = getPlayer(); Material material = blockState.getType(); - boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.CHORUS_PLANT || material == Material.SUGAR_CANE || material == Material.KELP_PLANT); + boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.CHORUS_PLANT + || material == Material.SUGAR_CANE || material == Material.KELP_PLANT || material == Material.KELP); // Prevents placing and immediately breaking blocks for exp if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) { @@ -158,7 +159,13 @@ public class HerbalismManager extends SkillManager { } if (!oneBlockPlant) { - amount = Herbalism.calculateMultiBlockPlantDrops(blockState); + //Kelp is actually two blocks mixed together + if(material == Material.KELP_PLANT || material == Material.KELP) { + amount = Herbalism.calculateKelpPlantDrops(blockState); + } else { + amount = Herbalism.calculateMultiBlockPlantDrops(blockState); + } + xp *= amount; } diff --git a/src/main/resources/experience.yml b/src/main/resources/experience.yml index 63cfbf5e9..dd8119e1e 100644 --- a/src/main/resources/experience.yml +++ b/src/main/resources/experience.yml @@ -259,6 +259,7 @@ Experience: Brown_Mushroom_Block: 70 Mushroom_Stem: 80 Herbalism: + Kelp: 3 Kelp_Plant: 3 Tube_Coral_Fan: 80 Brain_Coral: 90