2.1.18 - It turns out Kelp is actually made up of 2 blocks mixed together

This commit is contained in:
nossr50 2019-03-16 20:26:26 -07:00
parent 8994594ed4
commit 2f0a58b968
5 changed files with 64 additions and 4 deletions

View File

@ -7,6 +7,13 @@ Key:
! Change ! Change
- Removal - 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 Version 2.1.17
Fixed a logic error that resulted in Drowned giving no XP 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 Fixed a bug that resulted in mob spawner entities to not be marked for no xp after being transforming into Drowned

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId> <groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.17</version> <version>2.1.18</version>
<name>mcMMO</name> <name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url> <url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm> <scm>

View File

@ -91,7 +91,7 @@ public class Herbalism {
} }
} else { } else {
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally // 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); Block relativeBlock = block.getRelative(BlockFace.UP, y);
if (relativeBlock.getType() != blockType) { if (relativeBlock.getType() != blockType) {
@ -109,6 +109,51 @@ public class Herbalism {
return dropAmount; 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. * Convert blocks affected by the Green Thumb & Green Terra abilities.
* *

View File

@ -126,7 +126,8 @@ public class HerbalismManager extends SkillManager {
public void herbalismBlockCheck(BlockState blockState) { public void herbalismBlockCheck(BlockState blockState) {
Player player = getPlayer(); Player player = getPlayer();
Material material = blockState.getType(); 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 // Prevents placing and immediately breaking blocks for exp
if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) { if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) {
@ -158,7 +159,13 @@ public class HerbalismManager extends SkillManager {
} }
if (!oneBlockPlant) { 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; xp *= amount;
} }

View File

@ -259,6 +259,7 @@ Experience:
Brown_Mushroom_Block: 70 Brown_Mushroom_Block: 70
Mushroom_Stem: 80 Mushroom_Stem: 80
Herbalism: Herbalism:
Kelp: 3
Kelp_Plant: 3 Kelp_Plant: 3
Tube_Coral_Fan: 80 Tube_Coral_Fan: 80
Brain_Coral: 90 Brain_Coral: 90