Fix #499 broken pollination with non-Forestry bees

This commit is contained in:
mezz committed 2015-02-05 20:09:46 -08:00
1 parent 4d43e918f1
commit f5245e766b
4 files changed
+42 -6

No files matched your search

@@ -42,11 +42,9 @@ public class FlowerProvider implements IFlowerProvider {
@Override
public boolean isAcceptedPollinatable(World world, IPollinatable pollinatable) {
return isAcceptedPollinatable(world, pollinatable.getPlantType());
}
@Override
public boolean isAcceptedPollinatable(World world, EnumSet<EnumPlantType> plantTypes) {
EnumSet<EnumPlantType> plantTypes = pollinatable.getPlantType();
if (flowerType.equals(FlowerManager.FlowerTypeNether)) {
return plantTypes.contains(EnumPlantType.Nether);
} else if (flowerType.equals(FlowerManager.FlowerTypeCacti)) {
@@ -45,6 +45,7 @@ import forestry.api.genetics.IFlowerProvider;
import forestry.api.genetics.IGenome;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
import forestry.arboriculture.genetics.FakePollinatable;
import forestry.arboriculture.genetics.ICheckPollinatable;
import forestry.core.EnumErrorCode;
import forestry.core.config.Defaults;
@@ -726,7 +727,7 @@ public class Bee extends IndividualLiving implements IBee {
continue;
}
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, checkPollinatable.getPlantType())) {
if (!genome.getFlowerProvider().isAcceptedPollinatable(world, new FakePollinatable(checkPollinatable))) {
continue;
}
if (!checkPollinatable.canMateWith(pollen)) {
@@ -0,0 +1,37 @@
package forestry.arboriculture.genetics;
import java.util.EnumSet;
import net.minecraftforge.common.EnumPlantType;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IPollinatable;
public class FakePollinatable implements IPollinatable {
private final ICheckPollinatable checkPollinatable;
public FakePollinatable(ICheckPollinatable checkPollinatable) {
this.checkPollinatable = checkPollinatable;
}
@Override
public EnumSet<EnumPlantType> getPlantType() {
return checkPollinatable.getPlantType();
}
@Override
public IIndividual getPollen() {
return checkPollinatable.getPollen();
}
@Override
public boolean canMateWith(IIndividual pollen) {
return checkPollinatable.canMateWith(pollen);
}
@Override
public void mateWith(IIndividual pollen) {
}
}