Fix bonus drops on multi-block crops

This commit is contained in:
nossr50
2019-05-14 16:14:01 -07:00
parent e70e5b04b5
commit 95652efbaa
6 changed files with 56 additions and 17 deletions

View File

@ -87,7 +87,9 @@ public class Herbalism {
protected static int countAndMarkDoubleDropsMultiBlockPlant(BlockState blockState, boolean triple, HerbalismManager herbalismManager) {
Block block = blockState.getBlock();
Material blockType = blockState.getType();
int dropAmount = mcMMO.getPlaceStore().isTrue(block) ? 0 : 1;
int dropAmount = 0;
int bonusDropAmount = 0;
int bonusAdd = triple ? 2 : 1;
if (blockType == Material.CHORUS_PLANT) {
dropAmount = 1;
@ -96,6 +98,17 @@ public class Herbalism {
dropAmount = calculateChorusPlantDrops(block, triple, herbalismManager);
}
} else {
//Check the block itself first
if(!mcMMO.getPlaceStore().isTrue(block))
{
dropAmount++;
if(herbalismManager.checkDoubleDrop(blockState))
bonusDropAmount+=bonusAdd;
} else {
mcMMO.getPlaceStore().setFalse(blockState);
}
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < 255; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
@ -110,11 +123,14 @@ public class Herbalism {
dropAmount++;
if(herbalismManager.checkDoubleDrop(relativeBlock.getState()))
BlockUtils.markDropsAsBonus(relativeBlock.getState(), triple);
bonusDropAmount+=bonusAdd;
}
}
}
//Mark the original block for bonus drops
BlockUtils.markDropsAsBonus(blockState, bonusDropAmount);
return dropAmount;
}