use of com.minecolonies.coremod.colony.buildings.BuildingBaker in project minecolonies by Minecolonies.
the class EntityAIWorkBaker method bake.
/**
* Prepares the baker for baking and requests ingredients.
*
* @return the next AIState
*/
private AIState bake() {
final BuildingBaker building = getOwnBuilding();
if (currentFurnace == null || building.getFurnacesWithProduct().get(currentFurnace) != null) {
return PREPARING;
}
if (walkToBlock(currentFurnace)) {
return BAKER_BAKING;
}
final IBlockState furnace = world.getBlockState(currentFurnace);
final List<BakingProduct> bakingProducts = building.getTasks().get(ProductState.PREPARED);
if (!(furnace.getBlock() instanceof BlockFurnace)) {
if (bakingProducts.isEmpty()) {
building.removeFromTasks(ProductState.PREPARED, null);
} else {
building.removeFromFurnaces(currentFurnace);
}
return START_WORKING;
} else if (bakingProducts.isEmpty()) {
return START_WORKING;
}
final BakingProduct bakingProduct = bakingProducts.get(0);
building.removeFromTasks(ProductState.PREPARED, bakingProduct);
if (bakingProduct != null && bakingProduct.getState() == ProductState.PREPARED) {
building.putInFurnace(currentFurnace, bakingProduct);
bakingProduct.nextState();
world.setBlockState(currentFurnace, Blocks.LIT_FURNACE.getDefaultState().withProperty(BlockFurnace.FACING, furnace.getValue(BlockFurnace.FACING)));
}
return PREPARING;
}
Aggregations