use of com.minecolonies.coremod.colony.jobs.AbstractJobCrafter in project minecolonies by ldtteam.
the class PublicWorkerCraftingProductionResolver method resolveForBuilding.
@Override
public void resolveForBuilding(@NotNull final IRequestManager manager, @NotNull final IRequest<? extends PublicCrafting> request, @NotNull final AbstractBuilding building) {
if (manager.getColony().getWorld().isClientSide) {
return;
}
final ICitizenData freeCrafter = building.getModuleMatching(CraftingWorkerBuildingModule.class, m -> m.getJobEntry() == getJobEntry()).getAssignedCitizen().stream().filter(c -> c.getJob() instanceof AbstractJobCrafter && ((AbstractJobCrafter<?, ?>) c.getJob()).getAssignedTasks().contains(request.getId())).findFirst().orElse(null);
if (freeCrafter == null) {
onAssignedRequestBeingCancelled(manager, request);
return;
}
final AbstractJobCrafter<?, ?> job = (AbstractJobCrafter<?, ?>) freeCrafter.getJob();
job.onTaskBeingResolved(request.getId());
}
use of com.minecolonies.coremod.colony.jobs.AbstractJobCrafter in project minecolonies by ldtteam.
the class PublicWorkerCraftingProductionResolver method onAssignedToThisResolverForBuilding.
@Override
protected void onAssignedToThisResolverForBuilding(@NotNull final IRequestManager manager, @NotNull final IRequest<? extends PublicCrafting> request, final boolean simulation, @NotNull final AbstractBuilding building) {
if (manager.getColony().getWorld().isClientSide) {
return;
}
final ICitizenData freeCrafter = building.getModuleMatching(CraftingWorkerBuildingModule.class, m -> m.getJobEntry() == getJobEntry()).getAssignedCitizen().stream().filter(c -> c.getJob() instanceof AbstractJobCrafter).min(Comparator.comparing((ICitizenData c) -> ((AbstractJobCrafter<?, ?>) c.getJob()).getTaskQueue().size() + ((AbstractJobCrafter<?, ?>) c.getJob()).getAssignedTasks().size())).orElse(null);
if (freeCrafter == null) {
onAssignedRequestBeingCancelled(manager, request);
return;
}
final AbstractJobCrafter<?, ?> job = (AbstractJobCrafter<?, ?>) freeCrafter.getJob();
job.onTaskBeingScheduled(request.getId());
}
use of com.minecolonies.coremod.colony.jobs.AbstractJobCrafter in project minecolonies by ldtteam.
the class PublicWorkerCraftingProductionResolver method removeRequestFromTaskList.
private void removeRequestFromTaskList(@NotNull final IRequest<? extends PublicCrafting> completedRequest, final IColony colony) {
final ICitizenData holdingCrafter = colony.getCitizenManager().getCitizens().stream().filter(c -> c.getJob() instanceof AbstractJobCrafter && (((AbstractJobCrafter<?, ?>) c.getJob()).getTaskQueue().contains(completedRequest.getId()) || ((AbstractJobCrafter<?, ?>) c.getJob()).getAssignedTasks().contains(completedRequest.getId()))).findFirst().orElse(null);
if (holdingCrafter != null) {
final AbstractJobCrafter<?, ?> job = (AbstractJobCrafter<?, ?>) holdingCrafter.getJob();
job.onTaskDeletion(completedRequest.getId());
}
}
Aggregations