Search in sources :

Example 1 with IWorkOrder

use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by Minecolonies.

the class WorkManager method write.

/**
 * Save the Work Manager.
 *
 * @param compound Compound to save to.
 */
@Override
public void write(@NotNull final CompoundNBT compound) {
    // Work Orders
    @NotNull final ListNBT list = new ListNBT();
    for (@NotNull final IWorkOrder o : workOrders.values()) {
        @NotNull final CompoundNBT orderCompound = new CompoundNBT();
        o.write(orderCompound);
        list.add(orderCompound);
    }
    compound.put(TAG_WORK_ORDERS, list);
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) CompoundNBT(net.minecraft.nbt.CompoundNBT) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with IWorkOrder

use of com.minecolonies.api.colony.workorders.IWorkOrder 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);
    }
}
Also used : IWorkManager(com.minecolonies.api.colony.workorders.IWorkManager) IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) ArrayList(java.util.ArrayList) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ColonyViewWorkOrderMessage(com.minecolonies.coremod.network.messages.client.colony.ColonyViewWorkOrderMessage) WorkOrderBuildMiner(com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner) HashSet(java.util.HashSet)

Example 3 with IWorkOrder

use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by ldtteam.

the class WorkManager method write.

/**
 * Save the Work Manager.
 *
 * @param compound Compound to save to.
 */
@Override
public void write(@NotNull final CompoundNBT compound) {
    // Work Orders
    @NotNull final ListNBT list = new ListNBT();
    for (@NotNull final IWorkOrder o : workOrders.values()) {
        @NotNull final CompoundNBT orderCompound = new CompoundNBT();
        o.write(orderCompound);
        list.add(orderCompound);
    }
    compound.put(TAG_WORK_ORDERS, list);
}
Also used : ListNBT(net.minecraft.nbt.ListNBT) IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) CompoundNBT(net.minecraft.nbt.CompoundNBT) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with IWorkOrder

use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by ldtteam.

the class WorkManager method onColonyTick.

/**
 * Process updates on the Colony Tick. Currently, does periodic Work Order cleanup.
 *
 * @param colony the colony being ticked.
 */
@Override
public void onColonyTick(@NotNull final IColony colony) {
    @NotNull final Iterator<IWorkOrder> iter = workOrders.values().iterator();
    while (iter.hasNext()) {
        final IWorkOrder o = iter.next();
        if (!o.isValid(this.colony)) {
            iter.remove();
            dirty = true;
        } else if (o.hasChanged()) {
            dirty = true;
            o.resetChange();
        }
    }
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with IWorkOrder

use of com.minecolonies.api.colony.workorders.IWorkOrder in project minecolonies by ldtteam.

the class WorkManager method removeWorkOrder.

/**
 * Removes a work order from the work manager.
 *
 * @param orderId ID of the order to remove
 */
@Override
public void removeWorkOrder(final int orderId) {
    final IWorkOrder workOrder = workOrders.get(orderId);
    if (workOrder != null) {
        workOrders.remove(orderId);
        colony.removeWorkOrderInView(orderId);
        workOrder.onRemoved(colony);
        colony.markDirty();
    }
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder)

Aggregations

IWorkOrder (com.minecolonies.api.colony.workorders.IWorkOrder)16 NotNull (org.jetbrains.annotations.NotNull)6 WorkOrderBuildDecoration (com.minecolonies.coremod.colony.workorders.WorkOrderBuildDecoration)4 BlockPos (net.minecraft.util.math.BlockPos)4 Blueprint (com.ldtteam.structures.blueprints.v1.Blueprint)2 StructureName (com.ldtteam.structurize.management.StructureName)2 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)2 ICitizenData (com.minecolonies.api.colony.ICitizenData)2 IColony (com.minecolonies.api.colony.IColony)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 Action (com.minecolonies.api.colony.permissions.Action)2 IWorkManager (com.minecolonies.api.colony.workorders.IWorkManager)2 IMessage (com.minecolonies.api.network.IMessage)2 LoadOnlyStructureHandler (com.minecolonies.api.util.LoadOnlyStructureHandler)2 Log (com.minecolonies.api.util.Log)2 BlockDecorationController (com.minecolonies.coremod.blocks.BlockDecorationController)2 WorkerBuildingModule (com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule)2 JobBuilder (com.minecolonies.coremod.colony.jobs.JobBuilder)2 WorkOrderBuildMiner (com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner)2 ColonyViewWorkOrderMessage (com.minecolonies.coremod.network.messages.client.colony.ColonyViewWorkOrderMessage)2