use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class BeeMutation method getChance.
@Override
public float getChance(IBeeHousing housing, IAlleleBeeSpecies allele0, IAlleleBeeSpecies allele1, IBeeGenome genome0, IBeeGenome genome1) {
World world = housing.getWorldObj();
BlockPos housingPos = housing.getCoordinates();
float processedChance = super.getChance(world, housingPos, allele0, allele1, genome0, genome1, housing);
if (processedChance <= 0) {
return 0;
}
IBeeModifier beeHousingModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
IBeeModifier beeModeModifier = BeeManager.beeRoot.getBeekeepingMode(world).getBeeModifier();
processedChance *= beeHousingModifier.getMutationModifier(genome0, genome1, processedChance);
processedChance *= beeModeModifier.getMutationModifier(genome0, genome1, processedChance);
return processedChance;
}
use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class Bee method age.
@Override
public void age(World world, float housingLifespanModifier) {
IBeekeepingMode mode = BeeManager.beeRoot.getBeekeepingMode(world);
IBeeModifier beeModifier = mode.getBeeModifier();
float finalModifier = housingLifespanModifier * beeModifier.getLifespanModifier(genome, mate, housingLifespanModifier);
super.age(world, finalModifier);
}
use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class TileApiary method getBeeModifiers.
@Override
public Collection<IBeeModifier> getBeeModifiers() {
List<IBeeModifier> beeModifiers = new ArrayList<>();
beeModifiers.add(beeModifier);
for (Tuple<IHiveFrame, ItemStack> frame : inventory.getFrames()) {
IHiveFrame hiveFrame = frame.getFirst();
ItemStack stack = frame.getSecond();
IBeeModifier beeModifier = hiveFrame.getBeeModifier(stack);
beeModifiers.add(beeModifier);
}
return beeModifiers;
}
use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class AlvearyController method getTemperature.
@Override
public EnumTemperature getTemperature() {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(this);
Biome biome = getBiome();
if (beeModifier.isHellish() || BiomeHelper.isBiomeHellish(biome)) {
if (tempChange >= 0) {
return EnumTemperature.HELLISH;
}
}
return EnumTemperature.getFromValue(getExactTemperature());
}
use of forestry.api.apiculture.IBeeModifier in project ForestryMC by ForestryMC.
the class Bee method pollinateRandom.
@Override
public boolean pollinateRandom(IBeeHousing housing, IIndividual pollen) {
IBeeModifier beeModifier = BeeManager.beeRoot.createBeeHousingModifier(housing);
int chance = (int) (genome.getFlowering() * beeModifier.getFloweringModifier(getGenome(), 1f));
World world = housing.getWorldObj();
Random random = world.rand;
// Correct speed
if (random.nextInt(100) >= chance) {
return false;
}
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 < 30; i++) {
BlockPos randomPos = VectUtil.getRandomPositionInArea(random, area);
BlockPos posBlock = VectUtil.add(housingPos, randomPos, offset);
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock);
if (checkPollinatable == null) {
continue;
}
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, checkPollinatable)) {
continue;
}
if (!checkPollinatable.canMateWith(pollen)) {
continue;
}
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwner(), world, posBlock, Config.pollinateVanillaTrees);
if (realPollinatable != null) {
realPollinatable.mateWith(pollen);
return true;
}
}
return false;
}
Aggregations