mirror of
https://github.com/BentoBoxWorld/Greenhouses.git
synced 2024-11-26 04:25:31 +01:00
Reduces the amount of bonemeal required for plants
https://github.com/BentoBoxWorld/Greenhouses/issues/16
This commit is contained in:
parent
1601acdeef
commit
f28a50eb5f
@ -328,7 +328,7 @@ public class BiomeRecipe implements Comparable<BiomeRecipe> {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return getRandomPlant().map(p -> {
|
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.setType(p.getPlantMaterial());
|
||||||
bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2);
|
bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2);
|
||||||
return true;
|
return true;
|
||||||
|
@ -25,6 +25,7 @@ import world.bentobox.greenhouses.data.Greenhouse;
|
|||||||
*/
|
*/
|
||||||
public class EcoSystemManager {
|
public class EcoSystemManager {
|
||||||
|
|
||||||
|
private static final int PLANTS_PER_BONEMEAL = 6;
|
||||||
private final Greenhouses addon;
|
private final Greenhouses addon;
|
||||||
private final GreenhouseManager g;
|
private final GreenhouseManager g;
|
||||||
private BukkitTask plantTask;
|
private BukkitTask plantTask;
|
||||||
@ -132,8 +133,11 @@ public class EcoSystemManager {
|
|||||||
int bonemeal = getBoneMeal(gh);
|
int bonemeal = getBoneMeal(gh);
|
||||||
if (bonemeal > 0) {
|
if (bonemeal > 0) {
|
||||||
// Get a list of all available blocks
|
// Get a list of all available blocks
|
||||||
int bonemealUsed = getAvailableBlocks(gh).stream().limit(bonemeal).mapToInt(bl -> gh.getBiomeRecipe().growPlant(bl) ? 1 : 0).sum();
|
int plantsGrown = getAvailableBlocks(gh).stream().limit(bonemeal).mapToInt(bl -> gh.getBiomeRecipe().growPlant(bl) ? 1 : 0).sum();
|
||||||
setBoneMeal(gh, bonemeal - bonemealUsed);
|
if (plantsGrown > 0) {
|
||||||
|
setBoneMeal(gh, bonemeal - (int)Math.ceil((double)plantsGrown / PLANTS_PER_BONEMEAL ));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user