Search in sources :

Example 1 with BuildingBaker

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;
}
Also used : BlockFurnace(net.minecraft.block.BlockFurnace) IBlockState(net.minecraft.block.state.IBlockState) BuildingBaker(com.minecolonies.coremod.colony.buildings.BuildingBaker)

Aggregations

BuildingBaker (com.minecolonies.coremod.colony.buildings.BuildingBaker)1 BlockFurnace (net.minecraft.block.BlockFurnace)1 IBlockState (net.minecraft.block.state.IBlockState)1