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;
}
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);
}
}
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);
}
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;
}
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;
}
Aggregations