use of forestry.apiculture.blocks.BlockAlveary in project ForestryMC by ForestryMC.
the class AlleleEffectRadioactive method destroyEnvironment.
private static IEffectData destroyEnvironment(IBeeGenome genome, IEffectData storedData, IBeeHousing housing) {
World world = housing.getWorldObj();
Random rand = world.rand;
Vec3i area = VectUtil.scale(genome.getTerritory(), 2);
Vec3i offset = VectUtil.scale(area, -1 / 2.0f);
BlockPos posHousing = housing.getCoordinates();
for (int i = 0; i < 20; i++) {
BlockPos randomPos = VectUtil.getRandomPositionInArea(rand, area);
BlockPos posBlock = randomPos.add(posHousing);
posBlock = posBlock.add(offset);
if (posBlock.getY() <= 1 || posBlock.getY() >= world.getActualHeight()) {
continue;
}
// Don't destroy ourselves or blocks below us.
if (posBlock.getX() == posHousing.getX() && posBlock.getZ() == posHousing.getZ() && posBlock.getY() <= posHousing.getY()) {
continue;
}
if (!world.isBlockLoaded(posBlock) || world.isAirBlock(posBlock)) {
continue;
}
IBlockState blockState = world.getBlockState(posBlock);
Block block = blockState.getBlock();
if (block instanceof BlockAlveary) {
continue;
}
TileEntity tile = TileUtil.getTile(world, posBlock);
if (tile instanceof IBeeHousing) {
continue;
}
if (blockState.getBlockHardness(world, posBlock) < 0) {
continue;
}
BlockUtil.setBlockToAirWithSound(world, posBlock, blockState);
break;
}
return storedData;
}
Aggregations