use of net.minecraft.block.BlockBush in project Almura by AlmuraDev.
the class GrassFeature 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) {
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 CactusFeature 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 Gaia-Dimension by Andromander.
the class GDGlitterGrass 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 normalGrowth = GDBlocks.crystal_growth.getDefaultState();
IBlockState mutantGrowth = GDBlocks.crystal_growth_mutant.getDefaultState();
if (((BlockBush) GDBlocks.crystal_growth).canBlockStay(worldIn, blockpos1, normalGrowth)) {
if (worldIn.getBiome(pos) instanceof GDMutantAgateWildwood) {
worldIn.setBlockState(blockpos1, mutantGrowth, 3);
} else {
worldIn.setBlockState(blockpos1, normalGrowth, 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.glitter_grass || worldIn.getBlockState(blockpos1).isNormalCube()) {
break;
}
++j;
}
}
}
use of net.minecraft.block.BlockBush in project BluePower by Qmunity.
the class ItemSickle method onBlockDestroyed.
@Override
public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase entityLiving) {
boolean used = false;
if (!(entityLiving instanceof EntityPlayer))
return false;
EntityPlayer player = (EntityPlayer) entityLiving;
if ((block != null) && (block.isLeaves(world, x, y, z))) {
for (int i = -1; i <= 1; i++) {
for (int j = -1; j <= 1; j++) {
for (int k = -1; k <= 1; k++) {
Block blockToCheck = world.getBlock(x + i, y + j, z + k);
int meta = world.getBlockMetadata(x + i, y + j, z + k);
if ((blockToCheck != null) && (blockToCheck.isLeaves(world, x + i, y + j, z + k))) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y + j, z + k, meta);
}
world.setBlock(x + i, y + j, z + k, Blocks.air);
used = true;
}
}
}
}
if (used) {
itemStack.damageItem(1, entityLiving);
}
return used;
}
if ((block != null) && (block instanceof BlockLilyPad)) {
for (int i = -2; i <= 2; i++) {
for (int j = -2; j <= 2; j++) {
Block blockToCheck = world.getBlock(x + i, y, z + j);
int meta = world.getBlockMetadata(x + i, y, z + j);
if (blockToCheck != null && blockToCheck instanceof BlockLilyPad) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y, z + j, meta);
}
world.setBlock(x + i, y, z + j, Blocks.air);
used = true;
}
}
}
}
if ((block != null) && !(block instanceof BlockLilyPad)) {
for (int i = -2; i <= 2; i++) {
for (int j = -2; j <= 2; j++) {
Block blockToCheck = world.getBlock(x + i, y, z + j);
int meta = world.getBlockMetadata(x + i, y, z + j);
if (blockToCheck != null) {
if (blockToCheck instanceof BlockBush && !(blockToCheck instanceof BlockLilyPad)) {
if (blockToCheck.canHarvestBlock(player, meta)) {
blockToCheck.harvestBlock(world, player, x + i, y, z + j, meta);
}
world.setBlock(x + i, y, z + j, Blocks.air);
used = true;
}
}
}
}
}
if (used) {
itemStack.damageItem(1, entityLiving);
}
return used;
}
use of net.minecraft.block.BlockBush in project Gaia-Dimension by Andromander.
the class GDCorruptGrass 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 blackGrowth = GDBlocks.crystal_growth_black.getDefaultState();
IBlockState redGrowth = GDBlocks.crystal_growth_red.getDefaultState();
if (((BlockBush) GDBlocks.crystal_growth_black).canBlockStay(worldIn, blockpos1, blackGrowth)) {
if (rand.nextInt(2) == 0) {
worldIn.setBlockState(blockpos1, blackGrowth, 3);
} else {
worldIn.setBlockState(blockpos1, redGrowth, 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.corrupt_grass || worldIn.getBlockState(blockpos1).isNormalCube()) {
break;
}
++j;
}
}
}
Aggregations