Move self pollination into main pollination method

- Only happens if normal pollination can't occur
- Will not cause return otherwise would worsen chance for cross pollination
This commit is contained in:
temp1011 committed 2018-02-26 21:39:19 +00:00
1 parent 7dba583c26
commit bef36c15b0
3 files changed
+7 -55

No files matched your search

@@ -114,10 +114,5 @@ public interface IBee extends IIndividualLiving {
IIndividual retrievePollen(IBeeHousing housing);
boolean pollinateRandom(IBeeHousing housing, IIndividual pollen);
//TODO - implement fully in 1.13
default void selfPollinate(IBeeHousing housing) {
return;
}
}
@@ -50,7 +50,6 @@ import forestry.api.core.IErrorLogic;
import forestry.api.core.IErrorState;
import forestry.api.genetics.IEffectData;
import forestry.api.genetics.IIndividual;
import forestry.apiculture.genetics.Bee;
import forestry.apiculture.network.packets.PacketBeeLogicActive;
import forestry.apiculture.network.packets.PacketBeeLogicActiveEntity;
import forestry.core.config.Constants;
@@ -571,11 +570,6 @@ public class BeekeepingLogic implements IBeekeepingLogic {
pollen = null;
}
}
//Other things may implement IBee
if(ModuleApiculture.doSelfPollination) {
queen.selfPollinate(beeHousing);
}
}
}
@@ -715,6 +715,13 @@ public class Bee extends IndividualLiving implements IBee {
continue;
}
if (!checkPollinatable.canMateWith(pollen)) {
if(checkPollinatable.canMateWith(checkPollinatable.getPollen())) {
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwner(), world, posBlock, Config.pollinateVanillaTrees);
if (realPollinatable != null) {
realPollinatable.mateWith(realPollinatable.getPollen());
}
}
continue;
}
@@ -728,50 +735,6 @@ public class Bee extends IndividualLiving implements IBee {
return false;
}
public void selfPollinate(IBeeHousing housing) {
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;
}
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);
ICheckPollinatable checkPollinatable = GeneticsUtil.getCheckPollinatable(world, posBlock);
if (checkPollinatable == null) {
continue;
}
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, checkPollinatable)) {
continue;
}
if (!checkPollinatable.canMateWith(checkPollinatable.getPollen())) {
continue;
}
IPollinatable realPollinatable = GeneticsUtil.getOrCreatePollinatable(housing.getOwner(), world, posBlock, Config.pollinateVanillaTrees);
if (realPollinatable != null) {
realPollinatable.mateWith(realPollinatable.getPollen());
return;
}
}
}
@Override
public void plantFlowerRandom(IBeeHousing housing) {