diff --git a/plugin.yml b/plugin.yml index a2144697..a0fbbb3a 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,4 +1,4 @@ name: RealisticBiomes main: com.untamedears.realisticbiomes.RealisticBiomes load: STARTUP -version: 0.6.4.1 +version: 0.6.4.3 diff --git a/src/com/untamedears/realisticbiomes/RealisticBiomes.java b/src/com/untamedears/realisticbiomes/RealisticBiomes.java index 8f750159..1e38871c 100644 --- a/src/com/untamedears/realisticbiomes/RealisticBiomes.java +++ b/src/com/untamedears/realisticbiomes/RealisticBiomes.java @@ -400,6 +400,11 @@ public double growAndPersistBlock(Block block, boolean naturalGrowEvent) { return 0.0; } + // Only persistent crops should be grown in this manner + if (!growthConfig.isPersistent()) { + return 0.0; + } + RealisticBiomes.doLog(Level.FINER, "Realisticbiomes.growAndPersistBlock(): plantManager.get() returned: " + plant + " for coords: " + blockCoords); if (plant == null) { @@ -441,16 +446,22 @@ public GrowthConfig getGrowthConfig(TreeType species) { return materialGrowth.get(treeTypeMap.get(species)); } - public GrowthConfig getGrowthConfig(Block block) { - Material m = block.getType(); + public GrowthConfig getGrowthConfig(Material m) { return materialGrowth.get(m); } - public boolean hasGrowthConfig(Block block) { - Material m = block.getType(); + public GrowthConfig getGrowthConfig(Block b) { + return materialGrowth.get(b.getType()); + } + + public boolean hasGrowthConfig(Material m) { return materialGrowth.containsKey(m); } + public boolean hasGrowthConfig(Block b) { + return materialGrowth.containsKey(b.getType()); + } + public boolean hasGrowthConfig(TreeType species) { return materialGrowth.containsKey(treeTypeMap.get(species)); } diff --git a/src/com/untamedears/realisticbiomes/listener/GrowListener.java b/src/com/untamedears/realisticbiomes/listener/GrowListener.java index e83a71cd..bdf78121 100644 --- a/src/com/untamedears/realisticbiomes/listener/GrowListener.java +++ b/src/com/untamedears/realisticbiomes/listener/GrowListener.java @@ -49,6 +49,7 @@ public GrowListener(RealisticBiomes plugin) { */ @EventHandler(ignoreCancelled = true) public void onBlockGrow(BlockGrowEvent event) { + Material m = event.getNewState().getType(); Block b = event.getBlock(); GrowthConfig growthConfig = plugin.getGrowthConfig(b); @@ -57,7 +58,7 @@ public void onBlockGrow(BlockGrowEvent event) { event.setCancelled(true); } - else if (!willGrow(b)) { + else if (!willGrow(m, b)) { event.setCancelled(true); } } @@ -155,14 +156,18 @@ public void onBlockDispense(BlockDispenseEvent event) { * Determines if a plant {@link Material | @link TreeType} will grow, given the current conditions * @param m The material type of the plant * @param b The block that the plant is on - * @return Whether the plant will grow this tick + * @return true if the block should grow this material, otherwise false */ - private boolean willGrow(Block b) { - if(plugin.hasGrowthConfig(b)) { - boolean willGrow = Math.random() < plugin.getGrowthConfig(b).getRate(b); - return willGrow; + private boolean willGrow(Material m, Block b) { + GrowthConfig config = plugin.getGrowthConfig(m); + + // Returns true if the random value is within the growth rate + if (config != null) { + return Math.random() < config.getRate(b); } - return true; + + // Default to no growth + return false; }