Skip to content

Commit

Permalink
Reduces the amount of bonemeal required for plants
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Sep 15, 2019
1 parent 1601acd commit f28a50e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public boolean growPlant(Block bl) {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*/
public class EcoSystemManager {

private static final int PLANTS_PER_BONEMEAL = 6;
private final Greenhouses addon;
private final GreenhouseManager g;
private BukkitTask plantTask;
Expand Down Expand Up @@ -132,8 +133,11 @@ private void growPlants(Greenhouse gh) {
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 ));
}

}

}
Expand Down

0 comments on commit f28a50e

Please sign in to comment.