use of com.minecolonies.api.colony.requestsystem.requestable.Burnable in project minecolonies by Minecolonies.
the class AbstractEntityAIUsesFurnace method startWorking.
/**
* Central method of the furnace user, he decides about what to do next from here.
* First check if any of the workers has important tasks to handle first.
* If not check if there is an oven with an item which has to be retrieved.
* If not check if fuel and smeltable are available and request if necessary and get into inventory.
* Then check if able to smelt already.
* @return the next state to go to.
*/
private AIState startWorking() {
worker.setLatestStatus(new TextComponentTranslation(COM_MINECOLONIES_COREMOD_STATUS_DECIDING));
final AIState nextState = checkForImportantJobs();
if (nextState != START_WORKING) {
return nextState;
}
final BlockPos posOfOven = getPositionOfOvenToRetrieveFrom();
if (posOfOven != null) {
walkTo = posOfOven;
worker.setLatestStatus(new TextComponentTranslation("com.minecolonies.coremod.status.retrieving"));
return RETRIEVING_END_PRODUCT_FROM_FURNACE;
}
final int amountOfSmeltableInBuilding = InventoryUtils.getItemCountInProvider(getOwnBuilding(), this::isSmeltable);
final int amountOfSmeltableInInv = InventoryUtils.getItemCountInItemHandler(new InvWrapper(worker.getInventoryCitizen()), this::isSmeltable);
final int amountOfFuelInBuilding = InventoryUtils.getItemCountInProvider(getOwnBuilding(), TileEntityFurnace::isItemFuel);
final int amountOfFuelInInv = InventoryUtils.getItemCountInItemHandler(new InvWrapper(worker.getInventoryCitizen()), TileEntityFurnace::isItemFuel);
if (amountOfSmeltableInBuilding + amountOfSmeltableInInv <= 0 && !getOwnBuilding().hasWorkerOpenRequestsOfType(worker.getCitizenData(), TypeToken.of(getSmeltAbleClass().getClass()))) {
worker.getCitizenData().createRequestAsync(getSmeltAbleClass());
} else if (amountOfFuelInBuilding + amountOfFuelInInv <= 0 && !getOwnBuilding().hasWorkerOpenRequestsOfType(worker.getCitizenData(), TypeToken.of(Burnable.class))) {
worker.getCitizenData().createRequestAsync(new Burnable(STACKSIZE));
}
if (amountOfSmeltableInBuilding > 0 && amountOfFuelInInv == 0) {
needsCurrently = this::isSmeltable;
return GATHERING_REQUIRED_MATERIALS;
} else if (amountOfFuelInBuilding > 0 && amountOfFuelInInv == 0) {
needsCurrently = TileEntityFurnace::isItemFuel;
return GATHERING_REQUIRED_MATERIALS;
}
return checkIfAbleToSmelt(amountOfFuelInBuilding + amountOfFuelInInv, amountOfSmeltableInBuilding + amountOfSmeltableInInv);
}
Aggregations