use of com.minecolonies.coremod.colony.buildings.modules.ItemListModule in project minecolonies by ldtteam.
the class AbstractEntityAIUsesFurnace method fillUpFurnace.
/**
* Smelt the smeltable after the required items are in the inv.
*
* @return the next state to go to.
*/
private IAIState fillUpFurnace() {
if (getOwnBuilding().getFirstModuleOccurance(FurnaceUserModule.class).getFurnaces().isEmpty()) {
if (worker.getCitizenData() != null) {
worker.getCitizenData().triggerInteraction(new StandardInteraction(new TranslationTextComponent(BAKER_HAS_NO_FURNACES_MESSAGE), ChatPriority.BLOCKING));
}
return START_WORKING;
}
if (walkTo == null || world.getBlockState(walkTo).getBlock() != Blocks.FURNACE) {
walkTo = null;
return START_WORKING;
}
if (walkToBlock(walkTo)) {
return getState();
}
final TileEntity entity = world.getBlockEntity(walkTo);
if (entity instanceof FurnaceTileEntity) {
final FurnaceTileEntity furnace = (FurnaceTileEntity) entity;
if (InventoryUtils.hasItemInItemHandler((worker.getInventoryCitizen()), this::isSmeltable) && (hasFuelInFurnaceAndNoSmeltable(furnace) || hasNeitherFuelNorSmeltAble(furnace))) {
InventoryUtils.transferXOfFirstSlotInItemHandlerWithIntoInItemHandler((worker.getInventoryCitizen()), this::isSmeltable, STACKSIZE, new InvWrapper(furnace), SMELTABLE_SLOT);
}
final ItemListModule module = getOwnBuilding().getModuleMatching(ItemListModule.class, m -> m.getId().equals(FUEL_LIST));
if (InventoryUtils.hasItemInItemHandler((worker.getInventoryCitizen()), stack -> module.isItemInList(new ItemStorage(stack))) && (hasSmeltableInFurnaceAndNoFuel(furnace) || hasNeitherFuelNorSmeltAble(furnace))) {
InventoryUtils.transferXOfFirstSlotInItemHandlerWithIntoInItemHandler((worker.getInventoryCitizen()), stack -> module.isItemInList(new ItemStorage(stack)), STACKSIZE, new InvWrapper(furnace), FUEL_SLOT);
}
}
walkTo = null;
return START_WORKING;
}
Aggregations