Search in sources :

Example 1 with WorkOrderMiner

use of com.minecolonies.coremod.colony.workorders.WorkOrderMiner in project minecolonies by Minecolonies.

the class BuildingMiner method initStructure.

/**
 * Initiates structure loading.
 *
 * @param mineNode     the node to load it for.
 * @param rotateTimes  The amount of time to rotate the structure.
 * @param structurePos The position of the structure.
 */
public static void initStructure(final Node mineNode, final int rotateTimes, final BlockPos structurePos, final BuildingMiner buildingMiner, final World world, final JobMiner job) {
    final String style = buildingMiner.getStyle();
    String requiredName = null;
    int rotateCount = 0;
    if (mineNode == null) {
        rotateCount = getRotationFromVector(buildingMiner);
        requiredName = getCorrectStyleLocation(style, Node.NodeType.SHAFT.getSchematicName(), world, buildingMiner);
    } else {
        rotateCount = rotateTimes;
        requiredName = getCorrectStyleLocation(style, mineNode.getStyle().getSchematicName(), world, buildingMiner);
    }
    if (requiredName != null && (job == null || job.getWorkOrder() == null)) {
        final WorkOrderMiner wo = new WorkOrderMiner(requiredName, requiredName, rotateCount, structurePos, false, buildingMiner.getPosition());
        wo.setClaimedBy(buildingMiner.getPosition());
        buildingMiner.getColony().getWorkManager().addWorkOrder(wo, false);
        if (job != null) {
            job.setWorkOrder(wo);
        } else {
            wo.setClaimedBy(buildingMiner.getPosition());
        }
    }
    buildingMiner.markDirty();
}
Also used : WorkOrderMiner(com.minecolonies.coremod.colony.workorders.WorkOrderMiner)

Example 2 with WorkOrderMiner

use of com.minecolonies.coremod.colony.workorders.WorkOrderMiner in project minecolonies by Minecolonies.

the class AbstractEntityAIStructureWithWorkOrder method loadRequirements.

/**
 * Takes the existing workorder, loads the structure and tests the worker order if it is valid.
 */
@Override
public IAIState loadRequirements() {
    if (!job.hasBlueprint() || structurePlacer == null) {
        loadStructure();
        final IWorkOrder wo = job.getWorkOrder();
        if (wo == null) {
            Log.getLogger().error(String.format("Worker (%d:%d) ERROR - Starting and missing work order(%d)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), job.getWorkOrderId()), new Exception());
            job.setWorkOrder(null);
            return IDLE;
        }
        if (wo instanceof WorkOrderBuilding) {
            final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getLocation());
            if (building == null) {
                Log.getLogger().error(String.format("Worker (%d:%d) ERROR - Starting and missing building(%s)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), wo.getLocation()), new Exception());
                return IDLE;
            }
            worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILD_START, job.getWorkOrder().getDisplayName());
            // Don't go through the CLEAR stage for repairs and upgrades
            if (building.getBuildingLevel() > 0) {
                wo.setCleared(true);
            }
        } else if (!(wo instanceof WorkOrderMiner)) {
            worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILD_START, job.getWorkOrder().getDisplayName());
        }
        return getState();
    }
    if (job.getWorkOrder().isRequested()) {
        return afterStructureLoading();
    }
    // We need to deal with materials
    requestMaterialsState();
    return getState();
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) WorkOrderMiner(com.minecolonies.coremod.colony.workorders.WorkOrderMiner) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkOrderBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuilding)

Example 3 with WorkOrderMiner

use of com.minecolonies.coremod.colony.workorders.WorkOrderMiner in project minecolonies by Minecolonies.

the class MinerLevelManagementModule method serializeToView.

@Override
public void serializeToView(final PacketBuffer buf) {
    buf.writeInt(currentLevel);
    buf.writeInt(levels.size());
    for (@NotNull final Level level : levels) {
        buf.writeInt(level.getNumberOfBuiltNodes());
        buf.writeInt(level.getDepth());
    }
    final List<WorkOrderMiner> list = building.getColony().getWorkManager().getOrderedList(WorkOrderMiner.class, building.getPosition());
    buf.writeInt(list.size());
    for (@NotNull final WorkOrderMiner wo : list) {
        wo.serializeViewNetworkData(buf);
    }
}
Also used : WorkOrderMiner(com.minecolonies.coremod.colony.workorders.WorkOrderMiner) Level(com.minecolonies.coremod.entity.ai.citizen.miner.Level) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with WorkOrderMiner

use of com.minecolonies.coremod.colony.workorders.WorkOrderMiner in project minecolonies by Minecolonies.

the class EntityAIQuarrier method loadRequirements.

@Override
public IAIState loadRequirements() {
    if (job.getWorkOrder() == null) {
        final IBuilding quarry = job.findQuarry();
        if (quarry == null || quarry.getFirstModuleOccurance(QuarryModule.class).isFinished()) {
            return IDLE;
        }
        final String name = Structures.SCHEMATICS_PREFIX + "/" + quarry.getStyle() + "/" + quarry.getSchematicName() + "shaft1";
        final WorkOrderMiner wo = new WorkOrderMiner(name, name, quarry.getRotation(), quarry.getPosition().below(2), false, building.getPosition());
        building.getColony().getWorkManager().addWorkOrder(wo, false);
        job.setWorkOrder(wo);
    }
    return super.loadRequirements();
}
Also used : WorkOrderMiner(com.minecolonies.coremod.colony.workorders.WorkOrderMiner) IBuilding(com.minecolonies.api.colony.buildings.IBuilding)

Example 5 with WorkOrderMiner

use of com.minecolonies.coremod.colony.workorders.WorkOrderMiner in project minecolonies by Minecolonies.

the class BuildingMiner method searchWorkOrder.

@Override
public void searchWorkOrder() {
    final ICitizenData citizen = getFirstModuleOccurance(WorkerBuildingModule.class).getFirstCitizen();
    if (citizen == null) {
        return;
    }
    final List<WorkOrderMiner> list = getColony().getWorkManager().getOrderedList(WorkOrderMiner.class, getPosition());
    for (final WorkOrderMiner wo : list) {
        if (this.getID().equals(wo.getMinerBuilding())) {
            citizen.getJob(JobMiner.class).setWorkOrder(wo);
            wo.setClaimedBy(citizen);
            return;
        }
    }
}
Also used : WorkOrderMiner(com.minecolonies.coremod.colony.workorders.WorkOrderMiner) JobMiner(com.minecolonies.coremod.colony.jobs.JobMiner) WorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule) ICitizenData(com.minecolonies.api.colony.ICitizenData)

Aggregations

WorkOrderMiner (com.minecolonies.coremod.colony.workorders.WorkOrderMiner)5 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 ICitizenData (com.minecolonies.api.colony.ICitizenData)1 IWorkOrder (com.minecolonies.api.colony.workorders.IWorkOrder)1 WorkerBuildingModule (com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule)1 JobMiner (com.minecolonies.coremod.colony.jobs.JobMiner)1 WorkOrderBuilding (com.minecolonies.coremod.colony.workorders.WorkOrderBuilding)1 Level (com.minecolonies.coremod.entity.ai.citizen.miner.Level)1 NotNull (org.jetbrains.annotations.NotNull)1