use of forestry.api.genetics.IFlowerProvider in project ForestryMC by ForestryMC.
the class Bee method plantFlowerRandom.
@Override
public BlockPos plantFlowerRandom(IBeeHousing housing, @Nullable List<IBlockState> potentialFlowers) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
int chance = Math.round(genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
World world = housing.getWorldObj();
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance) {
return null;
}
// Gather required info
IFlowerProvider provider = genome.getFlowerProvider();
Vec3i area = getArea(genome, beeModifier);
Vec3i offset = new Vec3i(-area.getX() / 2, -area.getY() / 4, -area.getZ() / 2);
BlockPos housingPos = housing.getCoordinates();
for (int i = 0; i < 10; i++) {
BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area);
BlockPos posBlock = VectUtil.add(housingPos, randomPos, offset);
if (potentialFlowers != null) {
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock, potentialFlowers)) {
return posBlock;
}
} else {
// noinspection deprecation
if (FlowerManager.flowerRegistry.growFlower(provider.getFlowerType(), world, this, posBlock)) {
return posBlock;
}
}
}
return null;
}
Aggregations