Search in sources :

Example 1 with OUT_OF_COLONY

use of com.minecolonies.api.util.constant.TranslationConstants.OUT_OF_COLONY in project minecolonies by Minecolonies.

the class WorkManager method addWorkOrder.

/**
 * Adds work order to the work manager.
 *
 * @param order          Order adding.
 * @param readingFromNbt if being read from NBT.
 */
@Override
public void addWorkOrder(@NotNull final IWorkOrder order, final boolean readingFromNbt) {
    dirty = true;
    if (!(order instanceof WorkOrderMiner)) {
        for (final IWorkOrder or : workOrders.values()) {
            if (or.getLocation().equals(order.getLocation()) && or.getStructureName().equals(order.getStructureName())) {
                Log.getLogger().warn("Avoiding adding duplicate workOrder");
                removeWorkOrder(or);
                break;
            }
        }
        if (!readingFromNbt && !isWorkOrderWithinColony(order)) {
            MessageUtils.format(OUT_OF_COLONY, order.getDisplayName(), order.getLocation().getX(), order.getLocation().getZ()).sendTo(colony).forAllPlayers();
            return;
        }
    }
    if (order.getID() == 0) {
        topWorkOrderId++;
        order.setID(topWorkOrderId);
    }
    if (!readingFromNbt) {
        final StructureName structureName = new StructureName(order.getStructureName());
        if (order instanceof WorkOrderBuilding) {
            final int level = order.getTargetLevel();
            AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.CREATE_BUILD_REQUEST.trigger(player, structureName, level));
        } else if (order instanceof WorkOrderDecoration) {
            AdvancementUtils.TriggerAdvancementPlayersForColony(colony, player -> AdvancementTriggers.CREATE_BUILD_REQUEST.trigger(player, structureName, 0));
        }
    }
    workOrders.put(order.getID(), order);
    order.onAdded(colony, readingFromNbt);
}
Also used : IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) java.util(java.util) ColonyUtils(com.minecolonies.coremod.util.ColonyUtils) CompoundNBT(net.minecraft.nbt.CompoundNBT) CLOSE_COLONY_CAP(com.minecolonies.coremod.MineColonies.CLOSE_COLONY_CAP) ICitizenData(com.minecolonies.api.colony.ICitizenData) LoadOnlyStructureHandler(com.minecolonies.api.util.LoadOnlyStructureHandler) AdvancementUtils(com.minecolonies.coremod.util.AdvancementUtils) Log(com.minecolonies.api.util.Log) ListNBT(net.minecraft.nbt.ListNBT) MessageUtils(com.minecolonies.api.util.MessageUtils) StructureName(com.ldtteam.structurize.management.StructureName) Colony(com.minecolonies.coremod.colony.Colony) World(net.minecraft.world.World) Predicate(java.util.function.Predicate) IColonyTagCapability(com.minecolonies.api.colony.IColonyTagCapability) Tuple(net.minecraft.util.Tuple) ChunkPos(net.minecraft.util.math.ChunkPos) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) Collectors(java.util.stream.Collectors) Nullable(org.jetbrains.annotations.Nullable) AdvancementTriggers(com.minecolonies.api.advancements.AdvancementTriggers) NBT(net.minecraftforge.common.util.Constants.NBT) IColony(com.minecolonies.api.colony.IColony) OUT_OF_COLONY(com.minecolonies.api.util.constant.TranslationConstants.OUT_OF_COLONY) NotNull(org.jetbrains.annotations.NotNull) IWorkManager(com.minecolonies.api.colony.workorders.IWorkManager) IWorkOrder(com.minecolonies.api.colony.workorders.IWorkOrder) StructureName(com.ldtteam.structurize.management.StructureName)

Aggregations

StructureName (com.ldtteam.structurize.management.StructureName)1 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)1 AdvancementTriggers (com.minecolonies.api.advancements.AdvancementTriggers)1 ICitizenData (com.minecolonies.api.colony.ICitizenData)1 IColony (com.minecolonies.api.colony.IColony)1 IColonyTagCapability (com.minecolonies.api.colony.IColonyTagCapability)1 IWorkManager (com.minecolonies.api.colony.workorders.IWorkManager)1 IWorkOrder (com.minecolonies.api.colony.workorders.IWorkOrder)1 LoadOnlyStructureHandler (com.minecolonies.api.util.LoadOnlyStructureHandler)1 Log (com.minecolonies.api.util.Log)1 MessageUtils (com.minecolonies.api.util.MessageUtils)1 OUT_OF_COLONY (com.minecolonies.api.util.constant.TranslationConstants.OUT_OF_COLONY)1 CLOSE_COLONY_CAP (com.minecolonies.coremod.MineColonies.CLOSE_COLONY_CAP)1 Colony (com.minecolonies.coremod.colony.Colony)1 AdvancementUtils (com.minecolonies.coremod.util.AdvancementUtils)1 ColonyUtils (com.minecolonies.coremod.util.ColonyUtils)1 java.util (java.util)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 CompoundNBT (net.minecraft.nbt.CompoundNBT)1