Search in sources :

Example 6 with FUEL_LIST

use of com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST in project minecolonies by Minecolonies.

the class InteractionValidatorInitializer method init.

/**
 * Init method called on startup.
 */
public static void init() {
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(FURNACE_USER_NO_FUEL), citizen -> citizen.getWorkBuilding() != null && citizen.getWorkBuilding().hasModule(FurnaceUserModule.class) && citizen.getWorkBuilding().getModuleMatching(ItemListModule.class, m -> m.getId().equals(FUEL_LIST)).getList().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(BAKER_HAS_NO_FURNACES_MESSAGE), citizen -> citizen.getWorkBuilding() != null && citizen.getWorkBuilding().hasModule(FurnaceUserModule.class) && citizen.getWorkBuilding().getFirstModuleOccurance(FurnaceUserModule.class).getFurnaces().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(RAW_FOOD), citizen -> InventoryUtils.findFirstSlotInItemHandlerNotEmptyWith(citizen.getInventory(), ISCOOKABLE) != -1 && InventoryUtils.findFirstSlotInItemHandlerNotEmptyWith(citizen.getInventory(), stack -> CAN_EAT.test(stack) && (citizen.getWorkBuilding() == null || citizen.getWorkBuilding().canEat(stack))) == -1);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(BETTER_FOOD), citizen -> citizen.getSaturation() == 0 && !citizen.isChild() && citizen.needsBetterFood());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(BETTER_FOOD_CHILDREN), citizen -> citizen.getSaturation() == 0 && citizen.isChild() && citizen.needsBetterFood());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_RESTAURANT), citizen -> citizen.getColony() != null && citizen.getSaturation() <= LOW_SATURATION && citizen.getEntity().isPresent() && citizen.getColony().getBuildingManager().getBestBuilding(citizen.getEntity().get(), BuildingCook.class) == null && InventoryUtils.findFirstSlotInItemHandlerNotEmptyWith(citizen.getInventory(), ISFOOD) == -1);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_HOSPITAL), citizen -> citizen.getColony() != null && citizen.getEntity().isPresent() && citizen.getEntity().get().getCitizenDiseaseHandler().isSick() && citizen.getColony().getBuildingManager().getBestBuilding(citizen.getEntity().get(), BuildingHospital.class) == null);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(WAITING_FOR_CURE), citizen -> citizen.getColony() != null && citizen.getEntity().isPresent() && !citizen.getEntity().get().getCitizenDiseaseHandler().getDisease().isEmpty());
    InteractionValidatorRegistry.registerPosBasedPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_JOB_DELIVERYMAN_CHESTFULL), (citizen, pos) -> {
        if (citizen.getJob() instanceof JobDeliveryman) {
            final IColony colony = citizen.getColony();
            if (colony != null) {
                final IBuilding building = colony.getBuildingManager().getBuilding(pos);
                if (building != null) {
                    final IItemHandler inv = building.getCapability(ITEM_HANDLER_CAPABILITY, null).resolve().orElse(null);
                    if (inv != null) {
                        return InventoryUtils.openSlotCount(inv) > 0;
                    }
                }
            }
        }
        return false;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_JOB_DELIVERYMAN_NOWAREHOUSE), cit -> {
        if (cit.getJob() instanceof JobDeliveryman && cit.getWorkBuilding() != null) {
            return ((JobDeliveryman) cit.getJob()).findWareHouse() == null;
        }
        return false;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_FREE_FIELDS), citizen -> citizen.getWorkBuilding() instanceof BuildingFarmer && ((BuildingFarmer) citizen.getWorkBuilding()).getFirstModuleOccurance(FarmerFieldModule.class).hasNoFields());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(INVALID_MINESHAFT), citizen -> citizen.getWorkBuilding() instanceof BuildingMiner && citizen.getJob() instanceof JobMiner && (((BuildingMiner) citizen.getWorkBuilding()).getCobbleLocation() == null || ((BuildingMiner) citizen.getWorkBuilding()).getLadderLocation() == null));
    InteractionValidatorRegistry.registerPosBasedPredicate(new TranslationTextComponent(NO_SEED_SET), (citizen, pos) -> {
        if (citizen.getJob() instanceof JobFarmer) {
            final IColony colony = citizen.getColony();
            if (colony != null) {
                final World world = colony.getWorld();
                if (world != null) {
                    final TileEntity tileEntity = world.getBlockEntity(pos);
                    if (tileEntity instanceof ScarecrowTileEntity) {
                        return ((ScarecrowTileEntity) tileEntity).getSeed() == null;
                    }
                }
            }
        }
        return false;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_WORKER_INVENTORYFULLCHEST), citizen -> citizen.getWorkBuilding() != null && InventoryUtils.isProviderFull(citizen.getWorkBuilding()));
    InteractionValidatorRegistry.registerPosBasedPredicate(new TranslationTextComponent(REQUEST_SYSTEM_BUILDING_LEVEL_TOO_LOW), (citizen, pos) -> {
        final IBuilding workBuilding = citizen.getWorkBuilding();
        if (workBuilding != null) {
            final IColony colony = citizen.getColony();
            if (colony != null) {
                final World world = colony.getWorld();
                if (world != null) {
                    return workBuilding.getMaxToolLevel() < WorkerUtil.getCorrectHarvestLevelForBlock(world.getBlockState(pos));
                }
            }
        }
        return false;
    });
    InteractionValidatorRegistry.registerTokenBasedPredicate(new TranslationTextComponent(REQUEST_RESOLVER_NORMAL), (citizen, token) -> {
        final IColony colony = citizen.getColony();
        if (colony != null) {
            return RequestUtils.requestChainNeedsPlayer(token, citizen.getColony().getRequestManager());
        }
        return false;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(FURNACE_USER_NO_ORE), citizen -> {
        if (citizen.getWorkBuilding() instanceof BuildingSmeltery) {
            final List<ItemStorage> oreList = ((BuildingSmeltery) citizen.getWorkBuilding()).getModuleMatching(ItemListModule.class, m -> m.getId().equals(ORE_LIST)).getList();
            for (final ItemStorage storage : IColonyManager.getInstance().getCompatibilityManager().getSmeltableOres()) {
                if (!oreList.contains(storage)) {
                    return true;
                }
            }
        }
        return false;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(PATIENT_FULL_INVENTORY), citizen -> citizen.getEntity().isPresent() && citizen.getEntity().get().getCitizenDiseaseHandler().isSick() && InventoryUtils.isItemHandlerFull(citizen.getEntity().get().getInventoryCitizen()));
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(PUPIL_NO_CARPET), citizen -> citizen.getEntity().isPresent() && citizen.isChild() && citizen.getWorkBuilding() instanceof BuildingSchool && ((BuildingSchool) citizen.getWorkBuilding()).getRandomPlaceToSit() == null);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(WATER_TOO_FAR), citizen -> citizen.getJob() instanceof JobFisherman && ((JobFisherman) citizen.getJob()).getPonds().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(FURNACE_USER_NO_FUEL), citizen -> citizen.getWorkBuilding() != null && citizen.getWorkBuilding().hasModule(FurnaceUserModule.class) && citizen.getWorkBuilding().getModuleMatching(ItemListModule.class, m -> m.getId().equals(FUEL_LIST)).getList().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(FURNACE_USER_NO_FOOD), citizen -> {
        if (!(citizen.getWorkBuilding() instanceof BuildingCook)) {
            return false;
        }
        final ImmutableList<ItemStorage> exclusionList = ((BuildingCook) citizen.getWorkBuilding()).getModuleMatching(ItemListModule.class, m -> m.getId().equals(FOOD_EXCLUSION_LIST)).getList();
        for (final ItemStorage storage : IColonyManager.getInstance().getCompatibilityManager().getEdibles(citizen.getWorkBuilding().getBuildingLevel() - 1)) {
            if (!exclusionList.contains(storage)) {
                return false;
            }
        }
        return true;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(SIFTER_NO_MESH), citizen -> {
        if (!(citizen.getWorkBuilding() instanceof BuildingSifter)) {
            return false;
        }
        return InventoryUtils.getItemCountInProvider(citizen.getWorkBuilding(), item -> ModTags.meshes.contains(item.getItem())) <= 0 && InventoryUtils.getItemCountInItemHandler(citizen.getInventory(), item -> ModTags.meshes.contains(item.getItem())) <= 0;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(BAKER_HAS_NO_FURNACES_MESSAGE), citizen -> citizen.getWorkBuilding() instanceof BuildingBaker && citizen.getWorkBuilding().getFirstModuleOccurance(FurnaceUserModule.class).getFurnaces().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_HIVES), citizen -> citizen.getWorkBuilding() instanceof BuildingBeekeeper && ((BuildingBeekeeper) citizen.getWorkBuilding()).getHives().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_BEES), citizen -> citizen.getWorkBuilding() instanceof BuildingBeekeeper && citizen.getJob(JobBeekeeper.class).checkForBeeInteraction());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_WORKERS_TO_DRAIN_SET), citizen -> citizen.getWorkBuilding() instanceof BuildingEnchanter && ((BuildingEnchanter) citizen.getWorkBuilding()).getFirstModuleOccurance(EnchanterStationsModule.class).getBuildingsToGatherFrom().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_PLANT_GROUND_FLORIST), citizen -> citizen.getWorkBuilding() instanceof BuildingFlorist && ((BuildingFlorist) citizen.getWorkBuilding()).getPlantGround().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_FLOWERS_IN_CONFIG), citizen -> citizen.getWorkBuilding() instanceof BuildingFlorist && ItemStackUtils.isEmpty(((BuildingFlorist) citizen.getWorkBuilding()).getFlowerToGrow()));
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO_COMPOST), citizen -> {
        final IBuilding buildingFlorist = citizen.getWorkBuilding();
        if (buildingFlorist instanceof BuildingFlorist && buildingFlorist.getColony().getWorld() != null) {
            return InventoryUtils.getItemCountInItemHandler(citizen.getInventory(), IS_COMPOST) == 0 && !isThereCompostedLand((BuildingFlorist) buildingFlorist, buildingFlorist.getColony().getWorld());
        }
        return false;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NEEDS_BETTER_HUT), citizen -> {
        final AbstractBuilding buildingMiner = (AbstractBuilding) citizen.getWorkBuilding();
        if (buildingMiner instanceof BuildingMiner && citizen.getColony() != null && citizen.getColony().getWorld() != null && citizen.getJob() instanceof JobMiner) {
            return getLastLadder(((BuildingMiner) buildingMiner).getLadderLocation(), citizen.getColony().getWorld()) < ((BuildingMiner) buildingMiner).getDepthLimit() && ((BuildingMiner) buildingMiner).getFirstModuleOccurance(MinerLevelManagementModule.class).getNumberOfLevels() == 0;
        }
        return false;
    });
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(WORKER_AI_EXCEPTION), citizen -> citizen.getJob() != null && ((AbstractEntityAIBasic<?, ?>) citizen.getJob().getWorkerAI()).getExceptionTimer() > 1);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(DEMANDS + HOMELESSNESS), citizen -> (citizen.getCitizenHappinessHandler()).getModifier(HOMELESSNESS).getDays() > DEMANDS_DAYS_WITHOUT_HOUSE && citizen.getHomeBuilding() == null);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO + HOMELESSNESS), citizen -> (citizen.getCitizenHappinessHandler()).getModifier(HOMELESSNESS).getDays() > COMPLAIN_DAYS_WITHOUT_HOUSE && (citizen.getCitizenHappinessHandler()).getModifier(HOMELESSNESS).getDays() <= DEMANDS_DAYS_WITHOUT_HOUSE && citizen.getHomeBuilding() == null);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(DEMANDS + UNEMPLOYMENT), citizen -> (citizen.getCitizenHappinessHandler()).getModifier(UNEMPLOYMENT).getDays() > DEMANDS_DAYS_WITHOUT_JOB && citizen.getJob() == null);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO + UNEMPLOYMENT), citizen -> (citizen.getCitizenHappinessHandler()).getModifier(UNEMPLOYMENT).getDays() > COMPLAIN_DAYS_WITHOUT_JOB && (citizen.getCitizenHappinessHandler()).getModifier(UNEMPLOYMENT).getDays() <= DEMANDS_DAYS_WITHOUT_JOB && citizen.getJob() == null);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(DEMANDS + IDLEATJOB), citizen -> citizen.getJob() != null && (citizen.getCitizenHappinessHandler()).getModifier(IDLEATJOB).getDays() > citizen.getJob().getIdleSeverity(true));
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO + IDLEATJOB), citizen -> citizen.getJob() != null && citizen.getCitizenHappinessHandler().getModifier(IDLEATJOB).getDays() > citizen.getJob().getIdleSeverity(false) && citizen.getCitizenHappinessHandler().getModifier(IDLEATJOB).getDays() <= citizen.getJob().getIdleSeverity(true));
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(NO + SLEPTTONIGHT), citizen -> !(citizen.getJob() instanceof AbstractJobGuard) && citizen.getCitizenHappinessHandler().getModifier(SLEPTTONIGHT).getDays() <= 0);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_BEEKEEPER_NOFLOWERS), citizen -> citizen.getWorkBuilding() instanceof BuildingBeekeeper && ((BuildingBeekeeper) citizen.getWorkBuilding()).getModuleMatching(ItemListModule.class, m -> m.getId().equals(BUILDING_FLOWER_LIST)).getList().isEmpty());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_RAINING), citizen -> citizen.getEntity().isPresent() && citizen.getEntity().get().getCommandSenderWorld().isRaining() && !citizen.getColony().getRaiderManager().isRaided() && !citizen.getCitizenMournHandler().isMourning());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_RAID), citizen -> citizen.getEntity().isPresent() && citizen.getColony().getRaiderManager().isRaided());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_SLEEPING), citizen -> citizen.getEntity().isPresent() && citizen.isAsleep());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_CITIZEN_MOURNING), citizen -> citizen.getEntity().isPresent() && citizen.getCitizenMournHandler().isMourning() && !citizen.getColony().getRaiderManager().isRaided());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(CITIZEN_NOT_GUARD_NEAR_WORK), citizen -> citizen.getWorkBuilding() != null && !citizen.getWorkBuilding().isGuardBuildingNear());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(CITIZEN_NOT_GUARD_NEAR_HOME), citizen -> citizen.getHomeBuilding() != null && !citizen.getHomeBuilding().isGuardBuildingNear());
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(QUARRY_MINER_NO_QUARRY), citizen -> citizen.getJob() instanceof JobQuarrier && ((JobQuarrier) citizen.getJob()).findQuarry() == null);
    InteractionValidatorRegistry.registerStandardPredicate(new TranslationTextComponent(QUARRY_MINER_FINISHED_QUARRY), citizen -> citizen.getJob() instanceof JobQuarrier && ((JobQuarrier) citizen.getJob()).findQuarry() != null && ((JobQuarrier) citizen.getJob()).findQuarry().getFirstModuleOccurance(QuarryModule.class).isFinished());
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) WorkerUtil.isThereCompostedLand(com.minecolonies.coremod.util.WorkerUtil.isThereCompostedLand) HappinessConstants(com.minecolonies.api.util.constant.HappinessConstants) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) BUILDING_FLOWER_LIST(com.minecolonies.api.util.constant.BuildingConstants.BUILDING_FLOWER_LIST) LOW_SATURATION(com.minecolonies.api.util.constant.CitizenConstants.LOW_SATURATION) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) FOOD_EXCLUSION_LIST(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingCook.FOOD_EXCLUSION_LIST) AbstractEntityAIBasic(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIBasic) com.minecolonies.coremod.colony.buildings.workerbuildings(com.minecolonies.coremod.colony.buildings.workerbuildings) ImmutableList(com.google.common.collect.ImmutableList) WorkerUtil.getLastLadder(com.minecolonies.coremod.util.WorkerUtil.getLastLadder) ITEM_HANDLER_CAPABILITY(net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) FUEL_LIST(com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) REQUEST_RESOLVER_NORMAL(com.minecolonies.api.util.constant.translation.RequestSystemTranslationConstants.REQUEST_RESOLVER_NORMAL) ModTags(com.minecolonies.api.items.ModTags) World(net.minecraft.world.World) IColonyManager(com.minecolonies.api.colony.IColonyManager) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) InteractionValidatorRegistry(com.minecolonies.api.colony.interactionhandling.InteractionValidatorRegistry) List(java.util.List) RequestUtils(com.minecolonies.api.colony.requestsystem.request.RequestUtils) WorkerUtil(com.minecolonies.coremod.util.WorkerUtil) REQUEST_SYSTEM_BUILDING_LEVEL_TOO_LOW(com.minecolonies.api.util.constant.translation.RequestSystemTranslationConstants.REQUEST_SYSTEM_BUILDING_LEVEL_TOO_LOW) ORE_LIST(com.minecolonies.coremod.entity.ai.citizen.smelter.EntityAIWorkSmelter.ORE_LIST) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) InventoryUtils(com.minecolonies.api.util.InventoryUtils) IColony(com.minecolonies.api.colony.IColony) TileEntity(net.minecraft.tileentity.TileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage) com.minecolonies.coremod.colony.jobs(com.minecolonies.coremod.colony.jobs) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) com.minecolonies.coremod.colony.buildings.modules(com.minecolonies.coremod.colony.buildings.modules) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) World(net.minecraft.world.World) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage) TileEntity(net.minecraft.tileentity.TileEntity) ScarecrowTileEntity(com.minecolonies.coremod.tileentities.ScarecrowTileEntity) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) IItemHandler(net.minecraftforge.items.IItemHandler) IColony(com.minecolonies.api.colony.IColony)

Example 7 with FUEL_LIST

use of com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST in project minecolonies by Minecolonies.

the class BuildingCook method buildingRequiresCertainAmountOfItem.

@Override
public int buildingRequiresCertainAmountOfItem(final ItemStack stack, final List<ItemStorage> localAlreadyKept, final boolean inventory) {
    if (stack.isEmpty()) {
        return 0;
    }
    if (inventory && getFirstModuleOccurance(MinimumStockModule.class).isStocked(stack)) {
        return stack.getCount();
    }
    if (isAllowedFood(stack) && (localAlreadyKept.stream().filter(storage -> ISFOOD.test(storage.getItemStack())).mapToInt(ItemStorage::getAmount).sum() < STACKSIZE || !inventory)) {
        final ItemStorage kept = new ItemStorage(stack);
        if (localAlreadyKept.contains(kept)) {
            kept.setAmount(localAlreadyKept.remove(localAlreadyKept.indexOf(kept)).getAmount());
        }
        localAlreadyKept.add(kept);
        return 0;
    }
    final Predicate<ItemStack> allowedFuel = theStack -> getModuleMatching(ItemListModule.class, m -> m.getId().equals(FUEL_LIST)).isItemInList(new ItemStorage(theStack));
    if (allowedFuel.test(stack) && (localAlreadyKept.stream().filter(storage -> allowedFuel.test(storage.getItemStack())).mapToInt(ItemStorage::getAmount).sum() < STACKSIZE || !inventory)) {
        final ItemStorage kept = new ItemStorage(stack);
        if (localAlreadyKept.contains(kept)) {
            kept.setAmount(localAlreadyKept.remove(localAlreadyKept.indexOf(kept)).getAmount());
        }
        localAlreadyKept.add(kept);
        return 0;
    }
    return super.buildingRequiresCertainAmountOfItem(stack, localAlreadyKept, inventory);
}
Also used : IItemHandler(net.minecraftforge.items.IItemHandler) java.util(java.util) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) Item(net.minecraft.item.Item) IRecipeStorage(com.minecolonies.api.crafting.IRecipeStorage) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) ICitizenData(com.minecolonies.api.colony.ICitizenData) ISFOOD(com.minecolonies.api.util.ItemStackUtils.ISFOOD) AbstractJobCrafter(com.minecolonies.coremod.colony.jobs.AbstractJobCrafter) IGenericRecipe(com.minecolonies.api.crafting.IGenericRecipe) CRAFTING_COOK(com.minecolonies.api.util.constant.TagConstants.CRAFTING_COOK) MinecoloniesAPIProxy(com.minecolonies.api.MinecoloniesAPIProxy) ItemStack(net.minecraft.item.ItemStack) TAG_SITTING(com.minecolonies.api.util.constant.SchematicTagConstants.TAG_SITTING) GenericRecipe(com.minecolonies.api.crafting.GenericRecipe) MinimumStockModule(com.minecolonies.coremod.colony.buildings.modules.MinimumStockModule) CraftingWorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.CraftingWorkerBuildingModule) ModJobs(com.minecolonies.api.colony.jobs.ModJobs) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) OptionalPredicate(com.minecolonies.api.util.OptionalPredicate) FUEL_LIST(com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST) IBlueprintDataProvider(com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) ModTags(com.minecolonies.api.items.ModTags) STACKSIZE(com.minecolonies.api.util.constant.Constants.STACKSIZE) Predicate(java.util.function.Predicate) CraftingUtils(com.minecolonies.api.util.CraftingUtils) FurnaceRecipes(com.minecolonies.coremod.util.FurnaceRecipes) Tuple(net.minecraft.util.Tuple) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) Nullable(org.jetbrains.annotations.Nullable) OVERRIDE_EQUALS(com.minecolonies.api.util.constant.Suppression.OVERRIDE_EQUALS) AbstractCraftingBuildingModule(com.minecolonies.coremod.colony.buildings.modules.AbstractCraftingBuildingModule) IColony(com.minecolonies.api.colony.IColony) ItemStorage(com.minecolonies.api.crafting.ItemStorage) NotNull(org.jetbrains.annotations.NotNull) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 8 with FUEL_LIST

use of com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST in project minecolonies by Minecolonies.

the class AbstractEntityAIUsesFurnace method getAllowedFuel.

/**
 * Get a copy of the list of allowed fuel.
 * @return the list.
 */
private List<ItemStack> getAllowedFuel() {
    final List<ItemStack> list = new ArrayList<>();
    for (final ItemStorage storage : building.getModuleMatching(ItemListModule.class, m -> m.getId().equals(FUEL_LIST)).getList()) {
        final ItemStack stack = storage.getItemStack().copy();
        stack.setCount(stack.getMaxStackSize());
        list.add(stack);
    }
    return list;
}
Also used : ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) StackList(com.minecolonies.api.colony.requestsystem.requestable.StackList) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) FurnaceUserModule(com.minecolonies.coremod.colony.buildings.modules.FurnaceUserModule) AbstractJob(com.minecolonies.coremod.colony.jobs.AbstractJob) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) Tuple(com.minecolonies.api.util.Tuple) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) RequestSystemTranslationConstants(com.minecolonies.api.util.constant.translation.RequestSystemTranslationConstants) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) FUEL_LIST(com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) Constants(com.minecolonies.api.util.constant.Constants) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) AIEventTarget(com.minecolonies.api.entity.ai.statemachine.AIEventTarget) World(net.minecraft.world.World) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) AIBlockingEventType(com.minecolonies.api.entity.ai.statemachine.states.AIBlockingEventType) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) BlockPos(net.minecraft.util.math.BlockPos) FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) IRequestable(com.minecolonies.api.colony.requestsystem.requestable.IRequestable) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) Blocks(net.minecraft.block.Blocks) List(java.util.List) InventoryUtils(com.minecolonies.api.util.InventoryUtils) TileEntity(net.minecraft.tileentity.TileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage) WorldUtil(com.minecolonies.api.util.WorldUtil) FurnaceBlock(net.minecraft.block.FurnaceBlock) NotNull(org.jetbrains.annotations.NotNull) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 9 with FUEL_LIST

use of com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST in project minecolonies by Minecolonies.

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 (building.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 = building.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;
}
Also used : FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) StackList(com.minecolonies.api.colony.requestsystem.requestable.StackList) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) FurnaceUserModule(com.minecolonies.coremod.colony.buildings.modules.FurnaceUserModule) AbstractJob(com.minecolonies.coremod.colony.jobs.AbstractJob) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) Tuple(com.minecolonies.api.util.Tuple) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) RequestSystemTranslationConstants(com.minecolonies.api.util.constant.translation.RequestSystemTranslationConstants) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) FUEL_LIST(com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) Constants(com.minecolonies.api.util.constant.Constants) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) AIEventTarget(com.minecolonies.api.entity.ai.statemachine.AIEventTarget) World(net.minecraft.world.World) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) AIBlockingEventType(com.minecolonies.api.entity.ai.statemachine.states.AIBlockingEventType) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) BlockPos(net.minecraft.util.math.BlockPos) FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) IRequestable(com.minecolonies.api.colony.requestsystem.requestable.IRequestable) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) Blocks(net.minecraft.block.Blocks) List(java.util.List) InventoryUtils(com.minecolonies.api.util.InventoryUtils) TileEntity(net.minecraft.tileentity.TileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage) WorldUtil(com.minecolonies.api.util.WorldUtil) FurnaceBlock(net.minecraft.block.FurnaceBlock) NotNull(org.jetbrains.annotations.NotNull) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Example 10 with FUEL_LIST

use of com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST in project minecolonies by Minecolonies.

the class AbstractEntityAIRequestSmelter method getAllowedFuel.

/**
 * Get a copy of the list of allowed fuel.
 * @return the list.
 */
private List<ItemStack> getAllowedFuel() {
    final List<ItemStack> list = new ArrayList<>();
    for (final ItemStorage storage : building.getModuleMatching(ItemListModule.class, m -> m.getId().equals(FUEL_LIST)).getList()) {
        final ItemStack stack = storage.getItemStack().copy();
        stack.setCount(stack.getMaxStackSize());
        list.add(stack);
    }
    return list;
}
Also used : ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) TICKS_20(com.minecolonies.api.util.constant.CitizenConstants.TICKS_20) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) StackList(com.minecolonies.api.colony.requestsystem.requestable.StackList) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) IRecipeStorage(com.minecolonies.api.crafting.IRecipeStorage) TypeToken(com.google.common.reflect.TypeToken) FurnaceUserModule(com.minecolonies.coremod.colony.buildings.modules.FurnaceUserModule) AbstractJobCrafter(com.minecolonies.coremod.colony.jobs.AbstractJobCrafter) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) Tuple(com.minecolonies.api.util.Tuple) ImmutableList(com.google.common.collect.ImmutableList) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) RequestSystemTranslationConstants(com.minecolonies.api.util.constant.translation.RequestSystemTranslationConstants) Hand(net.minecraft.util.Hand) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) FUEL_LIST(com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST) ItemListModule(com.minecolonies.coremod.colony.buildings.modules.ItemListModule) Constants(com.minecolonies.api.util.constant.Constants) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) AIEventTarget(com.minecolonies.api.entity.ai.statemachine.AIEventTarget) World(net.minecraft.world.World) Predicate(java.util.function.Predicate) RequestState(com.minecolonies.api.colony.requestsystem.request.RequestState) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) AIBlockingEventType(com.minecolonies.api.entity.ai.statemachine.states.AIBlockingEventType) AbstractBuilding(com.minecolonies.coremod.colony.buildings.AbstractBuilding) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) BlockPos(net.minecraft.util.math.BlockPos) FurnaceTileEntity(net.minecraft.tileentity.FurnaceTileEntity) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) Blocks(net.minecraft.block.Blocks) List(java.util.List) PublicCrafting(com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting) InventoryUtils(com.minecolonies.api.util.InventoryUtils) TileEntity(net.minecraft.tileentity.TileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage) WorldUtil(com.minecolonies.api.util.WorldUtil) FurnaceBlock(net.minecraft.block.FurnaceBlock) NotNull(org.jetbrains.annotations.NotNull) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) ItemStorage(com.minecolonies.api.crafting.ItemStorage)

Aggregations

FUEL_LIST (com.minecolonies.api.util.constant.BuildingConstants.FUEL_LIST)13 AbstractBuilding (com.minecolonies.coremod.colony.buildings.AbstractBuilding)13 ItemStorage (com.minecolonies.api.crafting.ItemStorage)11 ItemStackUtils (com.minecolonies.api.util.ItemStackUtils)11 ItemStack (net.minecraft.item.ItemStack)11 TranslationConstants (com.minecolonies.api.util.constant.TranslationConstants)10 InventoryUtils (com.minecolonies.api.util.InventoryUtils)8 ItemListModule (com.minecolonies.coremod.colony.buildings.modules.ItemListModule)7 BlockPos (net.minecraft.util.math.BlockPos)7 NotNull (org.jetbrains.annotations.NotNull)7 ChatPriority (com.minecolonies.api.colony.interactionhandling.ChatPriority)6 StackList (com.minecolonies.api.colony.requestsystem.requestable.StackList)6 AIEventTarget (com.minecolonies.api.entity.ai.statemachine.AIEventTarget)6 AITarget (com.minecolonies.api.entity.ai.statemachine.AITarget)6 AIBlockingEventType (com.minecolonies.api.entity.ai.statemachine.states.AIBlockingEventType)6 AIWorkerState (com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState)6 IAIState (com.minecolonies.api.entity.ai.statemachine.states.IAIState)6 Tuple (com.minecolonies.api.util.Tuple)6 WorldUtil (com.minecolonies.api.util.WorldUtil)6 Constants (com.minecolonies.api.util.constant.Constants)6