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;
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations