use of org.bukkit.material.Sapling in project Glowstone by GlowstoneMC.
the class BlockSapling method updateBlock.
@Override
public void updateBlock(GlowBlock block) {
if (block.getRelative(BlockFace.UP).getLightLevel() >= 9 && random.nextInt(7) == 0) {
int dataValue = block.getData();
if ((dataValue & 8) == 0) {
block.setData((byte) (dataValue | 8));
} else {
MaterialData data = block.getState().getData();
if (data instanceof Sapling) {
Sapling sapling = (Sapling) data;
TreeType type = getTreeType(sapling.getSpecies());
block.setType(Material.AIR);
int saplingData = block.getData() & 0x7;
if (!block.getWorld().generateTree(block.getLocation(), type)) {
block.setType(Material.SAPLING);
block.setData((byte) saplingData);
}
} else {
warnMaterialData(Sapling.class, data);
}
}
}
}
Aggregations