use of forestry.api.apiculture.IBeeHousing in project ForestryMC by ForestryMC.
the class MutationConditionRequiresResource method getChance.
@Override
public float getChance(World world, BlockPos pos, IAllele allele0, IAllele allele1, IGenome genome0, IGenome genome1, IClimateProvider climate) {
TileEntity tile;
do {
pos = pos.down();
tile = TileUtil.getTile(world, pos);
} while (tile instanceof IBeeHousing);
IBlockState blockState = world.getBlockState(pos);
return this.acceptedBlockStates.contains(blockState) ? 1 : 0;
}
use of forestry.api.apiculture.IBeeHousing in project ForestryMC by ForestryMC.
the class JubilanceRequiresResource method isJubilant.
@Override
public boolean isJubilant(IAlleleBeeSpecies species, IBeeGenome genome, IBeeHousing housing) {
World world = housing.getWorldObj();
BlockPos pos = housing.getCoordinates();
TileEntity tile;
do {
pos = pos.down();
tile = TileUtil.getTile(world, pos);
} while (tile instanceof IBeeHousing && pos.getY() > 0);
IBlockState blockState = world.getBlockState(pos);
return this.acceptedBlockStates.contains(blockState);
}
use of forestry.api.apiculture.IBeeHousing 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;
}
use of forestry.api.apiculture.IBeeHousing in project Binnie by ForestryMC.
the class AlvearyLogicHatchery method updateServer.
@Override
public void updateServer(TileEntityExtraBeesAlvearyPart tile) {
if (tile.getWorldObj().rand.nextInt(2400) == 0) {
final IBeeHousing house = tile.getMultiblockLogic().getController();
if (!house.getErrorLogic().hasErrors()) {
final ItemStack queenStack = house.getBeeInventory().getQueen();
IBeeRoot beeRoot = Utils.getBeeRoot();
final IBee queen = (queenStack.isEmpty()) ? null : beeRoot.getMember(queenStack);
if (queen != null) {
ItemStack larvae = beeRoot.getMemberStack(beeRoot.getBee(queen.getGenome()), EnumBeeType.LARVAE);
for (int i = 0; i < 5; i++) {
if (inv.insertItem(i, larvae, false).isEmpty()) {
return;
}
}
}
}
}
}
Aggregations