Search in sources :

Example 16 with IWorkOrder

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;
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkOrderBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuilding)

Example 17 with IWorkOrder

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);
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) BlockPos(net.minecraft.util.math.BlockPos)

Example 18 with IWorkOrder

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());
    }
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) BlockPos(net.minecraft.util.math.BlockPos)

Example 19 with IWorkOrder

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);
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) BlockPos(net.minecraft.util.math.BlockPos) WorkOrderBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuilding)

Example 20 with IWorkOrder

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();
    }
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) WorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule) JobBuilder(com.minecolonies.coremod.colony.jobs.JobBuilder) ICitizenData(com.minecolonies.api.colony.ICitizenData)

Aggregations

IWorkOrder (com.minecolonies.api.colony.workorders.IWorkOrder)27 NotNull (org.jetbrains.annotations.NotNull)9 BlockPos (net.minecraft.util.math.BlockPos)7 ICitizenData (com.minecolonies.api.colony.ICitizenData)5 IColony (com.minecolonies.api.colony.IColony)5 WorkOrderBuilding (com.minecolonies.coremod.colony.workorders.WorkOrderBuilding)5 Nullable (org.jetbrains.annotations.Nullable)5 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)3 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)3 IWorkManager (com.minecolonies.api.colony.workorders.IWorkManager)3 LoadOnlyStructureHandler (com.minecolonies.api.util.LoadOnlyStructureHandler)3 Log (com.minecolonies.api.util.Log)3 WorkerBuildingModule (com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule)3 JobBuilder (com.minecolonies.coremod.colony.jobs.JobBuilder)3 CompoundNBT (net.minecraft.nbt.CompoundNBT)3 ListNBT (net.minecraft.nbt.ListNBT)3 Blueprint (com.ldtteam.structures.blueprints.v1.Blueprint)2 StructureName (com.ldtteam.structurize.management.StructureName)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 Action (com.minecolonies.api.colony.permissions.Action)2