Reduces the amount of bonemeal required for plants

https://github.com/BentoBoxWorld/Greenhouses/issues/16
This commit is contained in:
tastybento 2019-09-14 18:33:54 -07:00
parent 1601acdeef
commit f28a50eb5f
2 changed files with 7 additions and 3 deletions

View File

@ -328,7 +328,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
return false;
}
return getRandomPlant().map(p -> {
if (bl.getY() != 0 && p.getPlantGrownOn().map(m -> m.equals(bl.getRelative(BlockFace.DOWN).getType())).orElse(true)) {
if (bl.getY() != 0 && p.getPlantGrownOn().map(m -> m.equals(bl.getRelative(BlockFace.DOWN).getType())).orElse(false)) {
bl.setType(p.getPlantMaterial());
bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2);
return true;

View File

@ -25,6 +25,7 @@ import world.bentobox.greenhouses.data.Greenhouse;
*/
public class EcoSystemManager {
private static final int PLANTS_PER_BONEMEAL = 6;
private final Greenhouses addon;
private final GreenhouseManager g;
private BukkitTask plantTask;
@ -132,8 +133,11 @@ public class EcoSystemManager {
int bonemeal = getBoneMeal(gh);
if (bonemeal > 0) {
// Get a list of all available blocks
int bonemealUsed = getAvailableBlocks(gh).stream().limit(bonemeal).mapToInt(bl -> gh.getBiomeRecipe().growPlant(bl) ? 1 : 0).sum();
setBoneMeal(gh, bonemeal - bonemealUsed);
int plantsGrown = getAvailableBlocks(gh).stream().limit(bonemeal).mapToInt(bl -> gh.getBiomeRecipe().growPlant(bl) ? 1 : 0).sum();
if (plantsGrown > 0) {
setBoneMeal(gh, bonemeal - (int)Math.ceil((double)plantsGrown / PLANTS_PER_BONEMEAL ));
}
}
}