Search in sources :

Example 11 with BlockBush

use of net.minecraft.block.BlockBush in project Gaia-Dimension by Andromander.

the class GDSoftGrass method grow.

@Override
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state) {
    BlockPos blockpos = pos.up();
    for (int i = 0; i < 128; ++i) {
        BlockPos blockpos1 = blockpos;
        int j = 0;
        while (true) {
            if (j >= i / 16) {
                if (worldIn.isAirBlock(blockpos1)) {
                    if (rand.nextInt(8) == 0) {
                        worldIn.getBiome(blockpos1).plantFlower(worldIn, rand, blockpos1);
                    } else {
                        IBlockState iblockstate = GDBlocks.crystal_growth_aura.getDefaultState();
                        if (((BlockBush) GDBlocks.crystal_growth_aura).canBlockStay(worldIn, blockpos1, iblockstate)) {
                            worldIn.setBlockState(blockpos1, iblockstate, 3);
                        }
                    }
                }
                break;
            }
            blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
            if (worldIn.getBlockState(blockpos1.down()).getBlock() != GDBlocks.soft_grass || worldIn.getBlockState(blockpos1).isNormalCube()) {
                break;
            }
            ++j;
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) BlockBush(net.minecraft.block.BlockBush)

Example 12 with BlockBush

use of net.minecraft.block.BlockBush in project Almura by AlmuraDev.

the class FlowerFeature method canPlace.

private boolean canPlace(final IBlockAccess access, final BlockPos pos, final IBlockState toPlaceState, final List<LazyBlockState> requires) {
    World world;
    if (access instanceof ChunkCache) {
        world = ((ChunkCacheAccessor) access).accessor$getWorld();
    } else {
        world = (World) access;
    }
    final Block toPlaceBlock = toPlaceState.getBlock();
    boolean canPlace = true;
    if (!requires.isEmpty()) {
        final IBlockState underState = access.getBlockState(pos.down());
        boolean found = false;
        for (final LazyBlockState lbs : requires) {
            if (lbs.partialTest(underState)) {
                found = true;
                break;
            }
        }
        canPlace = found;
    }
    if (canPlace) {
        // Why Vanilla lol
        if (toPlaceBlock instanceof BlockCactus) {
            canPlace = ((BlockCactus) toPlaceBlock).canBlockStay(world, pos);
        } else if (toPlaceBlock instanceof BlockBush) {
            canPlace = ((BlockBush) toPlaceBlock).canBlockStay(world, pos, toPlaceState);
        }
    }
    return canPlace;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ChunkCache(net.minecraft.world.ChunkCache) Block(net.minecraft.block.Block) World(net.minecraft.world.World) BlockCactus(net.minecraft.block.BlockCactus) WeightedLazyBlockState(com.almuradev.content.util.WeightedLazyBlockState) LazyBlockState(com.almuradev.content.type.block.state.LazyBlockState) BlockBush(net.minecraft.block.BlockBush)

Example 13 with BlockBush

use of net.minecraft.block.BlockBush in project Almura by AlmuraDev.

the class DeadBushFeature method canPlace.

private boolean canPlace(final IBlockAccess access, final BlockPos pos, final IBlockState toPlaceState, final List<LazyBlockState> requires) {
    World world;
    if (access instanceof ChunkCache) {
        world = ((ChunkCacheAccessor) access).accessor$getWorld();
    } else {
        world = (World) access;
    }
    final Block toPlaceBlock = toPlaceState.getBlock();
    boolean canPlace = true;
    if (!requires.isEmpty()) {
        final IBlockState underState = access.getBlockState(pos.down());
        boolean found = false;
        for (final LazyBlockState lbs : requires) {
            if (lbs.partialTest(underState)) {
                found = true;
                break;
            }
        }
        canPlace = found;
    }
    if (canPlace) {
        // Why Vanilla lol
        if (toPlaceBlock instanceof BlockCactus) {
            canPlace = ((BlockCactus) toPlaceBlock).canBlockStay(world, pos);
        } else if (toPlaceBlock instanceof BlockBush) {
            canPlace = ((BlockBush) toPlaceBlock).canBlockStay(world, pos, toPlaceState);
        }
    }
    return canPlace;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) ChunkCache(net.minecraft.world.ChunkCache) Block(net.minecraft.block.Block) World(net.minecraft.world.World) BlockCactus(net.minecraft.block.BlockCactus) WeightedLazyBlockState(com.almuradev.content.util.WeightedLazyBlockState) LazyBlockState(com.almuradev.content.type.block.state.LazyBlockState) BlockBush(net.minecraft.block.BlockBush)

Example 14 with BlockBush

use of net.minecraft.block.BlockBush in project Traverse by ProfessorProspector.

the class WorldGenPlant method generate.

public boolean generate(World worldIn, Random rand, BlockPos position) {
    for (IBlockState iblockstate = worldIn.getBlockState(position); (iblockstate.getBlock().isAir(iblockstate, worldIn, position) || iblockstate.getBlock().isLeaves(iblockstate, worldIn, position)) && position.getY() > 0; iblockstate = worldIn.getBlockState(position)) {
        position = position.down();
    }
    for (int i = 0; i < 128; ++i) {
        BlockPos blockpos = position.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
        boolean canStay = true;
        if (state.getBlock() instanceof BlockBush && !(((BlockBush) state.getBlock()).canBlockStay(worldIn, blockpos, this.state))) {
            canStay = false;
        }
        if (worldIn.isAirBlock(blockpos) && canStay) {
            worldIn.setBlockState(blockpos, this.state, 2);
        }
    }
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) BlockBush(net.minecraft.block.BlockBush)

Example 15 with BlockBush

use of net.minecraft.block.BlockBush in project ConvenientAdditions by Necr0.

the class BlockCompostSoil method canSustainPlant.

@Override
public boolean canSustainPlant(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing side, IPlantable plantable) {
    BlockPos plantPos = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
    EnumPlantType plantType = plantable.getPlantType(world, plantPos);
    if (plantable instanceof BlockBush)
        return true;
    switch(plantType) {
        case Desert:
            return true;
        case Nether:
            return false;
        case Crop:
            return false;
        case Cave:
            return true;
        case Plains:
            return true;
        case Water:
            return false;
        case Beach:
            boolean hasWater = (world.getBlockState(pos.east()).getMaterial() == Material.WATER || world.getBlockState(pos.west()).getMaterial() == Material.WATER || world.getBlockState(pos.north()).getMaterial() == Material.WATER || world.getBlockState(pos.south()).getMaterial() == Material.WATER);
            return hasWater;
    }
    return false;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) EnumPlantType(net.minecraftforge.common.EnumPlantType) BlockBush(net.minecraft.block.BlockBush)

Aggregations

BlockBush (net.minecraft.block.BlockBush)15 Block (net.minecraft.block.Block)9 IBlockState (net.minecraft.block.state.IBlockState)8 BlockPos (net.minecraft.util.math.BlockPos)7 LazyBlockState (com.almuradev.content.type.block.state.LazyBlockState)4 WeightedLazyBlockState (com.almuradev.content.util.WeightedLazyBlockState)4 ChunkCache (net.minecraft.world.ChunkCache)4 World (net.minecraft.world.World)4 BlockCactus (net.minecraft.block.BlockCactus)3 ItemStack (net.minecraft.item.ItemStack)2 BlockBOPDecoration (biomesoplenty.common.block.BlockBOPDecoration)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 ITerraformableBlock (micdoodle8.mods.galacticraft.api.block.ITerraformableBlock)1 BlockLilyPad (net.minecraft.block.BlockLilyPad)1 BlockSapling (net.minecraft.block.BlockSapling)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Item (net.minecraft.item.Item)1 BlockPos (net.minecraft.util.BlockPos)1 WorldGenBush (net.minecraft.world.gen.feature.WorldGenBush)1