Skip to content

Commit

Permalink
Fixes support for double-height plants
Browse files Browse the repository at this point in the history
  • Loading branch information
tastybento committed Sep 19, 2019
1 parent 228644d commit 60f9b3e
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType;

import world.bentobox.bentobox.util.Util;
Expand Down Expand Up @@ -329,7 +331,18 @@ public boolean growPlant(Block bl) {
}
return getRandomPlant().map(p -> {
if (bl.getY() != 0 && p.getPlantGrownOn().map(m -> m.equals(bl.getRelative(BlockFace.DOWN).getType())).orElse(false)) {
bl.setType(p.getPlantMaterial());
BlockData dataBottom = p.getPlantMaterial().createBlockData();
if (dataBottom instanceof Bisected) {
((Bisected) dataBottom).setHalf(Bisected.Half.BOTTOM);
BlockData dataTop = p.getPlantMaterial().createBlockData();
((Bisected) dataTop).setHalf(Bisected.Half.TOP);
if (bl.getRelative(BlockFace.UP).getType().equals(Material.AIR)) {
bl.setBlockData(dataBottom, false);
bl.getRelative(BlockFace.UP).setBlockData(dataTop, false);
}
} else {
bl.setBlockData(dataBottom, false);
}
bl.getWorld().spawnParticle(Particle.SNOWBALL, bl.getLocation(), 10, 2, 2, 2);
return true;
}
Expand Down

0 comments on commit 60f9b3e

Please sign in to comment.