Search in sources :

Example 11 with IToken

use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.

the class EntityAIWorkDeliveryman method dump.

/**
 * Dump the inventory into the warehouse.
 *
 * @return the next state to go to.
 */
public AIState dump() {
    worker.setLatestStatus(new TextComponentTranslation("com.minecolonies.coremod.status.dumping"));
    if (!worker.isWorkerAtSiteWithMove(getWareHouse().getLocation(), MIN_DISTANCE_TO_WAREHOUSE)) {
        return DUMPING;
    }
    getWareHouse().getTileEntity().dumpInventoryIntoWareHouse(worker.getInventoryCitizen());
    gatherTarget = null;
    worker.setHeldItem(SLOT_HAND);
    final Set<IToken> finallyAssignedTokens = worker.getColony().getRequestManager().getPlayerResolver().getAllAssignedRequests().stream().collect(Collectors.toSet());
    finallyAssignedTokens.forEach(iToken -> worker.getColony().getRequestManager().reassignRequest(iToken, ImmutableList.of()));
    if (job.isReturning()) {
        job.setReturning(false);
    }
    return START_WORKING;
}
Also used : TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IToken(com.minecolonies.api.colony.requestsystem.token.IToken)

Example 12 with IToken

use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.

the class AbstractBuildingWorker method switchIndex.

/**
 * Switch indices of two recipes because of the priority.
 * @param i the first index.
 * @param j the second index.
 */
public void switchIndex(final int i, final int j) {
    if (i < recipes.size() && j < recipes.size() && i >= 0 && j >= 0) {
        final IToken storage = recipes.get(i);
        recipes.set(i, recipes.get(j));
        recipes.set(j, storage);
    }
}
Also used : IToken(com.minecolonies.api.colony.requestsystem.token.IToken)

Example 13 with IToken

use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.

the class AbstractBuildingWorker method writeToNBT.

@Override
public void writeToNBT(@NotNull final NBTTagCompound compound) {
    super.writeToNBT(compound);
    if (!workers.isEmpty()) {
        @NotNull final NBTTagList workersTagList = new NBTTagList();
        for (@NotNull final CitizenData data : workers) {
            if (data != null) {
                final NBTTagCompound idCompound = new NBTTagCompound();
                idCompound.setInteger(TAG_ID, data.getId());
                workersTagList.appendTag(idCompound);
            }
        }
        compound.setTag(TAG_WORKER, workersTagList);
    }
    @NotNull final NBTTagList recipesTagList = recipes.stream().map(iToken -> StandardFactoryController.getInstance().serialize(iToken)).collect(NBTUtils.toNBTTagList());
    compound.setTag(TAG_RECIPES, recipesTagList);
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) PrivateWorkerCraftingRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PrivateWorkerCraftingRequestResolver) IItemHandler(net.minecraftforge.items.IItemHandler) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) BuildingRequestResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.BuildingRequestResolver) java.util(java.util) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) Constants(net.minecraftforge.common.util.Constants) IRecipeStorage(com.minecolonies.api.crafting.IRecipeStorage) ImmutableCollection(com.google.common.collect.ImmutableCollection) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) AbstractJob(com.minecolonies.coremod.colony.jobs.AbstractJob) ColonyView(com.minecolonies.coremod.colony.ColonyView) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) TOOL_LEVEL_MAXIMUM(com.minecolonies.api.util.constant.ToolLevelConstants.TOOL_LEVEL_MAXIMUM) ItemStack(net.minecraft.item.ItemStack) InvWrapper(net.minecraftforge.items.wrapper.InvWrapper) CitizenData(com.minecolonies.coremod.colony.CitizenData) EntityCitizen(com.minecolonies.coremod.entity.EntityCitizen) NBTTagList(net.minecraft.nbt.NBTTagList) ImmutableList(com.google.common.collect.ImmutableList) ColonyManager(com.minecolonies.coremod.colony.ColonyManager) ByteBuf(io.netty.buffer.ByteBuf) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Colony(com.minecolonies.coremod.colony.Colony) TOOL_LEVEL_WOOD_OR_GOLD(com.minecolonies.api.util.constant.ToolLevelConstants.TOOL_LEVEL_WOOD_OR_GOLD) ItemFood(net.minecraft.item.ItemFood) BlockPos(net.minecraft.util.math.BlockPos) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) IRequestResolver(com.minecolonies.api.colony.requestsystem.resolver.IRequestResolver) TypeConstants(com.minecolonies.api.util.constant.TypeConstants) MineColonies(com.minecolonies.coremod.MineColonies) InventoryUtils(com.minecolonies.api.util.InventoryUtils) NBTUtils(com.minecolonies.api.util.NBTUtils) ByteBufUtils(net.minecraftforge.fml.common.network.ByteBufUtils) TileEntity(net.minecraft.tileentity.TileEntity) TickEvent(net.minecraftforge.fml.common.gameevent.TickEvent) NotNull(org.jetbrains.annotations.NotNull) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) CitizenData(com.minecolonies.coremod.colony.CitizenData) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with IToken

use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.

the class CitizenData method createRequestAsync.

public <R extends IRequestable> IToken createRequestAsync(@NotNull final R requested) {
    final IToken requestedToken = getWorkBuilding().createRequest(this, requested);
    job.getAsyncRequests().add(requestedToken);
    return requestedToken;
}
Also used : IToken(com.minecolonies.api.colony.requestsystem.token.IToken)

Example 15 with IToken

use of com.minecolonies.api.colony.requestsystem.token.IToken in project minecolonies by Minecolonies.

the class AbstractBuilding method createRequest.

public <R extends IRequestable> IToken<?> createRequest(@NotNull final CitizenData citizenData, @NotNull final R requested) {
    IToken requestToken = colony.getRequestManager().createRequest(requester, requested);
    addRequestToMaps(citizenData.getId(), requestToken, TypeToken.of(requested.getClass()));
    colony.getRequestManager().assignRequest(requestToken);
    markDirty();
    return requestToken;
}
Also used : IToken(com.minecolonies.api.colony.requestsystem.token.IToken)

Aggregations

IToken (com.minecolonies.api.colony.requestsystem.token.IToken)25 NotNull (org.jetbrains.annotations.NotNull)12 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)7 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)6 TypeToken (com.google.common.reflect.TypeToken)5 Collectors (java.util.stream.Collectors)5 MineColonies (com.minecolonies.coremod.MineColonies)4 NBTTagList (net.minecraft.nbt.NBTTagList)4 ImmutableList (com.google.common.collect.ImmutableList)3 IRequestManager (com.minecolonies.api.colony.requestsystem.manager.IRequestManager)3 RequestState (com.minecolonies.api.colony.requestsystem.request.RequestState)3 IRequester (com.minecolonies.api.colony.requestsystem.requester.IRequester)3 StandardToken (com.minecolonies.api.colony.requestsystem.token.StandardToken)3 NBTUtils (com.minecolonies.api.util.NBTUtils)3 TypeConstants (com.minecolonies.api.util.constant.TypeConstants)3 CitizenData (com.minecolonies.coremod.colony.CitizenData)3 Colony (com.minecolonies.coremod.colony.Colony)3 java.util (java.util)3 Nullable (org.jetbrains.annotations.Nullable)3