Search in sources :

Example 1 with Sapling

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);
            }
        }
    }
}
Also used : Sapling(org.bukkit.material.Sapling) TreeType(org.bukkit.TreeType) MaterialData(org.bukkit.material.MaterialData)

Aggregations

TreeType (org.bukkit.TreeType)1 MaterialData (org.bukkit.material.MaterialData)1 Sapling (org.bukkit.material.Sapling)1