use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner 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<WorkOrderBuildMiner> list = building.getColony().getWorkManager().getOrderedList(WorkOrderBuildMiner.class, building.getPosition());
buf.writeInt(list.size());
for (@NotNull final WorkOrderBuildMiner wo : list) {
wo.serializeViewNetworkData(buf);
}
}
use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner in project minecolonies by Minecolonies.
the class ColonyPackageManager method sendWorkOrderPackets.
@Override
public void sendWorkOrderPackets() {
final IWorkManager workManager = colony.getWorkManager();
if (workManager.isDirty() || !newSubscribers.isEmpty()) {
final Set<ServerPlayerEntity> players = new HashSet<>();
players.addAll(closeSubscribers);
players.addAll(newSubscribers);
List<IWorkOrder> workOrders = new ArrayList<>();
for (final IWorkOrder workOrder : workManager.getWorkOrders().values()) {
if (!(workOrder instanceof WorkOrderBuildMiner)) {
workOrders.add(workOrder);
}
}
players.forEach(player -> Network.getNetwork().sendToPlayer(new ColonyViewWorkOrderMessage(colony, workOrders), player));
workManager.setDirty(false);
}
}
use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner in project minecolonies by Minecolonies.
the class BuildingBuilder method searchWorkOrder.
@Override
public void searchWorkOrder() {
final ICitizenData citizen = getFirstModuleOccurance(WorkerBuildingModule.class).getFirstCitizen();
if (citizen == null) {
return;
}
final List<WorkOrderBuildDecoration> list = new ArrayList<>();
list.addAll(getColony().getWorkManager().getOrderedList(WorkOrderBuildRemoval.class, getPosition()));
// WorkOrderBuildDecoration is the superclass of BuildBuilding and thus returns both
list.addAll(getColony().getWorkManager().getOrderedList(WorkOrderBuildDecoration.class, getPosition()));
list.removeIf(order -> order instanceof WorkOrderBuildMiner);
final WorkOrderBuildDecoration order = list.stream().filter(w -> w.getClaimedBy() != null && w.getClaimedBy().equals(getPosition())).findFirst().orElse(null);
if (order != null) {
citizen.getJob(JobBuilder.class).setWorkOrder(order);
order.setClaimedBy(citizen);
return;
}
if (getManualMode()) {
return;
}
for (final WorkOrderBuildDecoration wo : list) {
double distanceToBuilder = Double.MAX_VALUE;
if (wo instanceof WorkOrderBuild && !(wo instanceof WorkOrderBuildRemoval) && !((WorkOrderBuild) wo).canBuild(citizen)) {
continue;
}
for (@NotNull final ICitizenData otherBuilder : getColony().getCitizenManager().getCitizens()) {
final JobBuilder job = otherBuilder.getJob(JobBuilder.class);
if (job == null || otherBuilder.getWorkBuilding() == null || citizen.getId() == otherBuilder.getId()) {
continue;
}
if (!job.hasWorkOrder() && wo instanceof WorkOrderBuild && ((WorkOrderBuild) wo).canBuild(otherBuilder)) {
final double distance = otherBuilder.getWorkBuilding().getID().distSqr(wo.getSchematicLocation());
if (distance < distanceToBuilder) {
distanceToBuilder = distance;
}
}
}
if (citizen.getWorkBuilding().getID().distSqr(wo.getSchematicLocation()) < distanceToBuilder) {
citizen.getJob(JobBuilder.class).setWorkOrder(wo);
wo.setClaimedBy(citizen);
return;
}
}
}
use of com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner 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 WorkOrderBuildMiner wo = new WorkOrderBuildMiner(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.WorkOrderBuildMiner 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 WorkOrderBuildMiner wo = new WorkOrderBuildMiner(name, name, quarry.getRotation(), quarry.getPosition().below(2), false, getOwnBuilding().getPosition());
getOwnBuilding().getColony().getWorkManager().addWorkOrder(wo, false);
job.setWorkOrder(wo);
}
return super.loadRequirements();
}
Aggregations