Search in sources :

Example 1 with DirtType

use of org.bukkit.material.types.DirtType in project Glowstone by GlowstoneMC.

the class MegaPineTree method generatePodzolPatch.

private void generatePodzolPatch(int sourceX, int sourceY, int sourceZ) {
    for (int x = -2; x <= 2; x++) {
        for (int z = -2; z <= 2; z++) {
            if (Math.abs(x) != 2 || Math.abs(z) != 2) {
                for (int y = 2; y >= -3; y--) {
                    Block block = loc.getWorld().getBlockAt(sourceX + x, sourceY + y, sourceZ + z);
                    if (block.getType() == Material.GRASS || block.getType() == Material.DIRT) {
                        BlockState state = block.getState();
                        state.setType(Material.DIRT);
                        DirtType dirtType = DirtType.PODZOL;
                        if (loc.getWorld().getBlockAt(sourceX + x, sourceY + y + 1, sourceZ + z).getType().isOccluding()) {
                            dirtType = DirtType.NORMAL;
                        }
                        state.setData(new Dirt(dirtType));
                        state.update(true);
                    } else if (!block.isEmpty() && sourceY + y < sourceY) {
                        break;
                    }
                }
            }
        }
    }
}
Also used : DirtType(org.bukkit.material.types.DirtType) BlockState(org.bukkit.block.BlockState) Dirt(org.bukkit.material.Dirt) Block(org.bukkit.block.Block)

Aggregations

Block (org.bukkit.block.Block)1 BlockState (org.bukkit.block.BlockState)1 Dirt (org.bukkit.material.Dirt)1 DirtType (org.bukkit.material.types.DirtType)1