Search in sources :

Example 1 with Flower

use of forestry.apiculture.flowers.Flower in project ForestryMC by ForestryMC.

the class VillageApiaristHouse method plantFlowerGarden.

private void plantFlowerGarden(World world, StructureBoundingBox box, int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
    if (structureType == 1) {
        // desert
        setBlockState(world, Blocks.CACTUS.getDefaultState(), 4, 1, 7, box);
        return;
    }
    for (int i = minY; i <= maxY; ++i) {
        for (int j = minX; j <= maxX; ++j) {
            for (int k = minZ; k <= maxZ; ++k) {
                if (world.rand.nextBoolean()) {
                    int xCoord = getXWithOffset(j, k);
                    int yCoord = getYWithOffset(i);
                    int zCoord = getZWithOffset(j, k);
                    BlockPos pos = new BlockPos(xCoord, yCoord, zCoord);
                    IBlockState blockState = world.getBlockState(pos);
                    if (!Blocks.RED_FLOWER.canBlockStay(world, pos, blockState)) {
                        continue;
                    }
                    FlowerRegistry flowerRegistry = (FlowerRegistry) FlowerManager.flowerRegistry;
                    Flower flower = flowerRegistry.getRandomPlantableFlower(FlowerManager.FlowerTypeVanilla, world.rand);
                    if (flower != null) {
                        setBlockState(world, flower.getBlockState(), j, i, k, box);
                    }
                }
            }
        }
    }
}
Also used : Flower(forestry.apiculture.flowers.Flower) IBlockState(net.minecraft.block.state.IBlockState) FlowerRegistry(forestry.apiculture.flowers.FlowerRegistry) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

Flower (forestry.apiculture.flowers.Flower)1 FlowerRegistry (forestry.apiculture.flowers.FlowerRegistry)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1