Search in sources :

Example 1 with BlockBOPDecoration

use of biomesoplenty.common.block.BlockBOPDecoration in project BiomesOPlenty by Glitchfiend.

the class GeneratorDoubleFlora method generate.

@Override
public boolean generate(World world, Random random, BlockPos pos) {
    Block bottomBlock = this.with.getBlock();
    for (int i = 0; i < this.generationAttempts; ++i) {
        BlockPos genPos = pos.add(random.nextInt(8) - random.nextInt(8), random.nextInt(4) - random.nextInt(4), random.nextInt(8) - random.nextInt(8));
        if (this.placeOn.matches(world, genPos.down()) && this.replace.matches(world, genPos) && this.replace.matches(world, genPos.up()) && genPos.getY() < 254) {
            boolean canStay;
            if (bottomBlock instanceof BlockBOPDecoration) {
                canStay = ((BlockBOPDecoration) bottomBlock).canBlockStay(world, genPos, this.with);
            } else if (bottomBlock instanceof BlockBush) {
                canStay = bottomBlock.canPlaceBlockAt(world, genPos);
            } else {
                canStay = bottomBlock.canPlaceBlockAt(world, genPos);
            }
            if (canStay) {
                world.setBlockState(genPos, this.with, 2);
                world.setBlockState(genPos.up(), this.withTop, 2);
            }
        }
    }
    return true;
}
Also used : BlockBOPDecoration(biomesoplenty.common.block.BlockBOPDecoration) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockBush(net.minecraft.block.BlockBush)

Aggregations

BlockBOPDecoration (biomesoplenty.common.block.BlockBOPDecoration)1 Block (net.minecraft.block.Block)1 BlockBush (net.minecraft.block.BlockBush)1 BlockPos (net.minecraft.util.math.BlockPos)1