if (!ForestryItem.beeQueenGE.isItemEqual(housing.getQueen())) {
housing.setErrorState(EnumErrorCode.NOQUEEN.ordinal());
return;
}
IBee queen = PluginApiculture.beeInterface.getMember(housing.getQueen());
// Kill dying queens
if (!queen.isAlive()) {
killQueen(queen);
housing.setErrorState(EnumErrorCode.OK.ordinal());
return;
}
resetQueen(queen);
// Not while raining, at night or without light
EnumErrorCode state = EnumErrorCode.values()[queen.isWorking(housing)];
if (state != EnumErrorCode.OK) {
housing.setErrorState(state.ordinal());
return;
} else if (housing.getErrorOrdinal() != EnumErrorCode.NOFLOWER.ordinal())
housing.setErrorState(EnumErrorCode.OK.ordinal());
// Effects only fire when queen can work.
effectData = queen.doEffect(effectData, housing);
// We have a queen, work!
throttle++;
if (throttle >= PluginApiculture.beeCycleTicks)
throttle = 0;
else
return;
// Need a flower
if (!queen.hasFlower(housing)) {
housing.setErrorState(EnumErrorCode.NOFLOWER.ordinal());
return;
} else
housing.setErrorState(EnumErrorCode.OK.ordinal());
// Produce and add stacks
ItemStack[] products = queen.produceStacks(housing);
housing.wearOutEquipment(1);
for (ItemStack stack : products) {
housing.addProduct(stack, false);
}
// Plant a flower
queen.plantFlowerRandom(housing);
// Get pollen if none available yet
if (pollen == null) {
pollen = queen.retrievePollen(housing);
attemptedPollinations = 0;
if (pollen != null) {
if (housing.onPollenRetrieved(queen, pollen, false))
pollen = null;
}
}
if (pollen != null) {
attemptedPollinations++;
if (queen.pollinateRandom(housing, pollen)
|| attemptedPollinations >= MAX_POLLINATION_ATTEMPTS) {
pollen = null;
}
}
// Age the queen
queen.age(housing.getWorld(), housing.getLifespanModifier(queen.getGenome(), queen.getMate(), 0f));
// Write the changed queen back into the item stack.
NBTTagCompound nbttagcompound = new NBTTagCompound();
queen.writeToNBT(nbttagcompound);
housing.getQueen().setTagCompound(nbttagcompound);
return;
}