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