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