Search in sources :

Example 11 with ICitizenData

use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.

the class RestartCitizenMessage method onExecute.

@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony) {
    final ServerPlayerEntity player = ctxIn.getSender();
    if (player == null) {
        return;
    }
    final ICitizenData citizen = colony.getCitizenManager().getCivilian(citizenID);
    // Restart also worker building and AI
    citizen.scheduleRestart(player);
    LanguageHandler.sendPlayerMessage(player, "com.minecolonies.coremod.gui.hiring.restartMessage", citizen.getName());
}
Also used : ICitizenData(com.minecolonies.api.colony.ICitizenData) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 12 with ICitizenData

use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.

the class HireFireMessage method onExecute.

@Override
protected void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony, final IBuilding building) {
    final ICitizenData citizen = colony.getCitizenManager().getCivilian(citizenID);
    citizen.setPaused(false);
    if (hire) {
        building.getModuleMatching(IAssignsJob.class, m -> m.getJobEntry() == entry).assignCitizen(citizen);
    } else {
        building.getModuleMatching(IAssignsJob.class, m -> m.getJobEntry() == entry).removeCitizen(citizen);
    }
}
Also used : AbstractBuildingServerMessage(com.minecolonies.coremod.network.messages.server.AbstractBuildingServerMessage) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) IColony(com.minecolonies.api.colony.IColony) IAssignsJob(com.minecolonies.api.colony.buildings.modules.IAssignsJob) NetworkEvent(net.minecraftforge.fml.network.NetworkEvent) ICitizenData(com.minecolonies.api.colony.ICitizenData) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) NotNull(org.jetbrains.annotations.NotNull) PacketBuffer(net.minecraft.network.PacketBuffer) IAssignsJob(com.minecolonies.api.colony.buildings.modules.IAssignsJob) ICitizenData(com.minecolonies.api.colony.ICitizenData)

Example 13 with ICitizenData

use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.

the class AbstractBuilding method removeWorkOrder.

/**
 * Remove the work order for the building.
 * <p>
 * Remove either the upgrade or repair work order
 */
@Override
public void removeWorkOrder() {
    for (@NotNull final WorkOrderBuild o : colony.getWorkManager().getWorkOrdersOfType(WorkOrderBuild.class)) {
        if (o.getSchematicLocation().equals(getID()) && (o instanceof WorkOrderBuildBuilding || o instanceof WorkOrderBuildRemoval)) {
            colony.getWorkManager().removeWorkOrder(o.getID());
            markDirty();
            final BlockPos buildingPos = o.getClaimedBy();
            final IBuilding building = colony.getBuildingManager().getBuilding(buildingPos);
            if (building != null) {
                for (final AbstractAssignedCitizenModule module : building.getModules(AbstractAssignedCitizenModule.class)) {
                    for (final ICitizenData citizen : module.getAssignedCitizen()) {
                        building.cancelAllRequestsOfCitizen(citizen);
                    }
                }
            }
            return;
        }
    }
}
Also used : WorkOrderBuild(com.minecolonies.coremod.colony.workorders.WorkOrderBuild) WorkOrderBuildBuilding(com.minecolonies.coremod.colony.workorders.WorkOrderBuildBuilding) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) WorkOrderBuildRemoval(com.minecolonies.coremod.colony.workorders.WorkOrderBuildRemoval) ICitizenData(com.minecolonies.api.colony.ICitizenData) BlockPos(net.minecraft.util.math.BlockPos) AbstractAssignedCitizenModule(com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule) NotNull(org.jetbrains.annotations.NotNull)

Example 14 with ICitizenData

use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.

the class AbstractBuildingGuards method onUpgradeComplete.

// // ---- NBT Overrides ---- \\\\
/**
 * We use this to set possible health multipliers and give achievements.
 *
 * @param newLevel The new level.
 */
@Override
public void onUpgradeComplete(final int newLevel) {
    if (getAllAssignedCitizen() != null) {
        for (final ICitizenData optCitizen : getAllAssignedCitizen()) {
            if (optCitizen.getEntity().isPresent()) {
                final AttributeModifier healthModBuildingHP = new AttributeModifier(GUARD_HEALTH_MOD_BUILDING_NAME, getBonusHealth(), AttributeModifier.Operation.ADDITION);
                AttributeModifierUtils.addHealthModifier(optCitizen.getEntity().get(), healthModBuildingHP);
            }
        }
    }
    super.onUpgradeComplete(newLevel);
}
Also used : ICitizenData(com.minecolonies.api.colony.ICitizenData) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier)

Example 15 with ICitizenData

use of com.minecolonies.api.colony.ICitizenData in project minecolonies by Minecolonies.

the class AbstractCraftingBuildingModule method getPendingRequestQueue.

/**
 * Get a list of all recipeStorages of the pending requests in the crafters queues.
 * @return the list.
 */
private List<Tuple<IRecipeStorage, Integer>> getPendingRequestQueue() {
    final List<Tuple<IRecipeStorage, Integer>> recipes = new ArrayList<>();
    for (final ICitizenData citizen : building.getAllAssignedCitizen()) {
        if (citizen.getJob() instanceof AbstractJobCrafter) {
            final List<IToken<?>> assignedTasks = new ArrayList<>(citizen.getJob(AbstractJobCrafter.class).getAssignedTasks());
            assignedTasks.addAll(citizen.getJob(AbstractJobCrafter.class).getTaskQueue());
            for (final IToken<?> taskToken : assignedTasks) {
                final IRequest<? extends PublicCrafting> request = (IRequest<? extends PublicCrafting>) building.getColony().getRequestManager().getRequestForToken(taskToken);
                final IRecipeStorage recipeStorage = IColonyManager.getInstance().getRecipeManager().getRecipes().get(request.getRequest().getRecipeID());
                if (holdsRecipe(request.getRequest().getRecipeID()) && recipeStorage != null) {
                    recipes.add(new Tuple<>(recipeStorage, request.getRequest().getCount()));
                }
            }
        }
    }
    return recipes;
}
Also used : ICitizenData(com.minecolonies.api.colony.ICitizenData) IToken(com.minecolonies.api.colony.requestsystem.token.IToken) PublicCrafting(com.minecolonies.api.colony.requestsystem.requestable.crafting.PublicCrafting) IRequest(com.minecolonies.api.colony.requestsystem.request.IRequest) Tuple(net.minecraft.util.Tuple) AbstractJobCrafter(com.minecolonies.coremod.colony.jobs.AbstractJobCrafter)

Aggregations

ICitizenData (com.minecolonies.api.colony.ICitizenData)175 NotNull (org.jetbrains.annotations.NotNull)47 IColony (com.minecolonies.api.colony.IColony)45 BlockPos (net.minecraft.util.math.BlockPos)45 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)40 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)30 ItemStack (net.minecraft.item.ItemStack)28 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)27 PlayerEntity (net.minecraft.entity.player.PlayerEntity)26 IRequest (com.minecolonies.api.colony.requestsystem.request.IRequest)22 WorkerBuildingModule (com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule)22 Nullable (org.jetbrains.annotations.Nullable)22 CompoundNBT (net.minecraft.nbt.CompoundNBT)17 ArrayList (java.util.ArrayList)16 Colony (com.minecolonies.coremod.colony.Colony)15 AbstractJobCrafter (com.minecolonies.coremod.colony.jobs.AbstractJobCrafter)14 EntityCitizen (com.minecolonies.coremod.entity.citizen.EntityCitizen)14 AbstractAssignedCitizenModule (com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule)12 java.util (java.util)12 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)12