use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by Minecolonies.
the class EntityAIStructureBuilder method checkForWorkOrder.
/**
* Checks if we got a valid workorder.
*
* @return true if we got a workorder to work with
*/
private boolean checkForWorkOrder() {
if (!job.hasWorkOrder()) {
building.searchWorkOrder();
building.setProgressPos(null, BuildingStructureHandler.Stage.CLEAR);
return false;
}
final IWorkOrder wo = job.getWorkOrder();
if (wo == null) {
job.setWorkOrder(null);
building.setProgressPos(null, null);
return false;
}
final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getLocation());
if (building == null && wo instanceof WorkOrderBuilding && wo.getWorkOrderType() != WorkOrderType.REMOVE) {
job.complete();
return false;
}
return true;
}
use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by Minecolonies.
the class EntityAIStructureBuilder method sendCompletionMessage.
@Override
protected void sendCompletionMessage(final IWorkOrder wo) {
super.sendCompletionMessage(wo);
final BlockPos position = wo.getLocation();
boolean showManualSuffix = false;
if (building.getManualMode()) {
showManualSuffix = true;
for (final IWorkOrder workorder : building.getColony().getWorkManager().getWorkOrders().values()) {
if (workorder.getID() != wo.getID() && workorder.isClaimedBy(worker.getCitizenData())) {
showManualSuffix = false;
}
}
}
TranslationTextComponent message;
switch(wo.getWorkOrderType()) {
case REPAIR:
message = new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_REPAIRING_COMPLETE, wo.getDisplayName(), position.getX(), position.getY(), position.getZ());
break;
case REMOVE:
message = new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECONSTRUCTION_COMPLETE, wo.getDisplayName(), position.getX(), position.getY(), position.getZ());
break;
default:
message = new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILD_COMPLETE, wo.getDisplayName(), position.getX(), position.getY(), position.getZ());
break;
}
if (showManualSuffix) {
message.append(new TranslationTextComponent(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_MANUAL_SUFFIX));
}
worker.getCitizenChatHandler().sendLocalizedChat(message);
}
use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by Minecolonies.
the class EntityAIStructureBuilder method sendCompletionMessage.
@Override
protected void sendCompletionMessage(final WorkOrderBuildDecoration wo) {
super.sendCompletionMessage(wo);
final BlockPos position = wo.getSchematicLocation();
if (getOwnBuilding().getManualMode()) {
boolean hasInQueue = false;
for (final IWorkOrder workorder : getOwnBuilding().getColony().getWorkManager().getWorkOrders().values()) {
if (workorder.getID() != wo.getID() && workorder.isClaimedBy(worker.getCitizenData())) {
hasInQueue = true;
}
}
if (!hasInQueue) {
if (wo instanceof WorkOrderBuildBuilding) {
worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILDCOMPLETE_MANUAL, wo.getDisplayName(), position.getX(), position.getY(), position.getZ());
} else {
worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECOCOMPLETE_MANUAL, wo.getDisplayName(), position.getX(), position.getY(), position.getZ());
}
return;
}
}
if (wo instanceof WorkOrderBuildBuilding) {
worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILDCOMPLETE, wo.getDisplayName(), position.getX(), position.getY(), position.getZ());
} else {
worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECOCOMPLETE, wo.getDisplayName(), position.getX(), position.getY(), position.getZ());
}
}
use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by Minecolonies.
the class AbstractEntityAIStructureWithWorkOrder method loadStructure.
/**
* Load the structure into the AI.
*/
private void loadStructure() {
final IWorkOrder workOrder = job.getWorkOrder();
if (workOrder == null) {
return;
}
final BlockPos pos = workOrder.getLocation();
if (workOrder instanceof WorkOrderBuilding && worker.getCitizenColonyHandler().getColony().getBuildingManager().getBuilding(pos) == null) {
Log.getLogger().warn("AbstractBuilding does not exist - removing build request");
worker.getCitizenColonyHandler().getColony().getWorkManager().removeWorkOrder(workOrder);
return;
}
final int tempRotation = workOrder.getRotation();
final boolean removal = workOrder.getWorkOrderType() == WorkOrderType.REMOVE;
loadStructure(workOrder.getStructureName(), tempRotation, pos, workOrder.isMirrored(), removal);
workOrder.setCleared(false);
workOrder.setRequested(removal);
}
use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by Minecolonies.
the class BuildingBuilder method setWorkOrder.
/**
* Sets the work order with the given id as the work order for this buildings citizen.
*
* @param orderId the id of the work order to select.
*/
public void setWorkOrder(int orderId) {
final ICitizenData citizen = getFirstModuleOccurance(WorkerBuildingModule.class).getFirstCitizen();
if (citizen == null) {
return;
}
IWorkOrder wo = getColony().getWorkManager().getWorkOrder(orderId);
if (wo == null || (wo.getClaimedBy() != null && !wo.getClaimedBy().equals(getPosition()))) {
return;
}
if (citizen.getJob(JobBuilder.class).hasWorkOrder()) {
wo.setClaimedBy(citizen);
getColony().getWorkManager().setDirty(true);
return;
}
if (wo.canBeMadeBy(citizen.getJob())) {
citizen.getJob(JobBuilder.class).setWorkOrder(wo);
wo.setClaimedBy(citizen);
getColony().getWorkManager().setDirty(true);
markDirty();
}
}
Aggregations