Search in sources :

Example 1 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.

the class AbstractTeachingGuiHandler method getRecipeCategory.

@Nullable
protected JobBasedRecipeCategory<?> getRecipeCategory(@NotNull final AbstractBuildingView view) {
    for (final CraftingModuleView moduleView : view.getModuleViews(CraftingModuleView.class)) {
        if (!isSupportedCraftingModule(moduleView))
            continue;
        final JobEntry jobEntry = moduleView.getJobEntry();
        if (jobEntry != null) {
            final ResourceLocation uid = ICraftingBuildingModule.getUid(jobEntry, moduleView.getId());
            final JobBasedRecipeCategory<?> category = this.categories.get(uid);
            if (category != null) {
                return category;
            }
        }
    }
    return null;
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ResourceLocation(net.minecraft.util.ResourceLocation) CraftingModuleView(com.minecolonies.coremod.colony.buildings.moduleviews.CraftingModuleView) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.

the class EventListener method onUpdateEntityRadar.

@SubscribeEvent
public void onUpdateEntityRadar(@NotNull final EntityRadarUpdateEvent event) {
    final WrappedEntity wrapper = event.getWrappedEntity();
    final LivingEntity entity = wrapper.getEntityLivingRef().get();
    if (entity instanceof AbstractEntityCitizen) {
        final boolean isVisitor = entity instanceof VisitorCitizen;
        TextComponent jobName;
        if (isVisitor) {
            if (!JourneymapOptions.getShowVisitors(this.jmap.getOptions())) {
                wrapper.setDisable(true);
                return;
            }
            jobName = new TranslationTextComponent(COM_MINECOLONIES_JMAP_PREFIX + "visitor");
        } else {
            final String jobId = entity.getEntityData().get(DATA_JOB);
            final JobEntry jobEntry = IJobRegistry.getInstance().getValue(new ResourceLocation(jobId));
            final IJob<?> job = jobEntry == null ? null : jobEntry.produceJob(null);
            if (job instanceof AbstractJobGuard ? !JourneymapOptions.getShowGuards(this.jmap.getOptions()) : !JourneymapOptions.getShowCitizens(this.jmap.getOptions())) {
                wrapper.setDisable(true);
                return;
            }
            jobName = new TranslationTextComponent(jobEntry == null ? COM_MINECOLONIES_JMAP_PREFIX + "unemployed" : jobEntry.getTranslationKey());
        }
        if (JourneymapOptions.getShowColonistTooltip(this.jmap.getOptions())) {
            ITextComponent name = entity.getCustomName();
            if (name != null) {
                wrapper.setEntityToolTips(Arrays.asList(name, jobName.setStyle(JOB_TOOLTIP)));
            }
        }
        final boolean showName = event.getActiveUiState().ui.equals(Context.UI.Minimap) ? JourneymapOptions.getShowColonistNameMinimap(this.jmap.getOptions()) : JourneymapOptions.getShowColonistNameFullscreen(this.jmap.getOptions());
        if (!showName) {
            wrapper.setCustomName("");
        }
        if (!isVisitor && JourneymapOptions.getShowColonistTeamColour(this.jmap.getOptions())) {
            wrapper.setColor(entity.getTeamColor());
        }
    }
}
Also used : AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) WrappedEntity(journeymap.client.api.model.WrappedEntity) VisitorCitizen(com.minecolonies.coremod.entity.citizen.VisitorCitizen) LivingEntity(net.minecraft.entity.LivingEntity) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) AbstractJobGuard(com.minecolonies.coremod.colony.jobs.AbstractJobGuard) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 3 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.

the class AssignUnassignMessage method onExecute.

@Override
public void onExecute(final NetworkEvent.Context ctxIn, final boolean isLogicalServer, final IColony colony, final DefaultBuildingInstance building) {
    final ICitizenData citizen = colony.getCitizenManager().getCivilian(citizenID);
    final AbstractAssignedCitizenModule module;
    if (jobEntry == null) {
        module = building.getFirstModuleOccurance(LivingBuildingModule.class);
    } else {
        module = building.getModuleMatching(WorkerBuildingModule.class, m -> m.getJobEntry() == jobEntry);
    }
    if (assign && !module.isFull() && !building.equals(citizen.getHomeBuilding())) {
        if (citizen.getHomeBuilding() != null) {
            citizen.getHomeBuilding().getFirstModuleOccurance(LivingBuildingModule.class).removeCitizen(citizen);
        }
        module.assignCitizen(citizen);
    } else if (module.hasAssignedCitizen(citizen)) {
        module.removeCitizen(citizen);
    }
}
Also used : DefaultBuildingInstance(com.minecolonies.coremod.colony.buildings.DefaultBuildingInstance) WorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule) AbstractAssignedCitizenModule(com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule) AbstractBuildingServerMessage(com.minecolonies.coremod.network.messages.server.AbstractBuildingServerMessage) IBuildingView(com.minecolonies.api.colony.buildings.views.IBuildingView) IColony(com.minecolonies.api.colony.IColony) NetworkEvent(net.minecraftforge.fml.network.NetworkEvent) ICitizenData(com.minecolonies.api.colony.ICitizenData) JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) LivingBuildingModule(com.minecolonies.coremod.colony.buildings.modules.LivingBuildingModule) NotNull(org.jetbrains.annotations.NotNull) PacketBuffer(net.minecraft.network.PacketBuffer) LivingBuildingModule(com.minecolonies.coremod.colony.buildings.modules.LivingBuildingModule) WorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule) ICitizenData(com.minecolonies.api.colony.ICitizenData) AbstractAssignedCitizenModule(com.minecolonies.coremod.colony.buildings.modules.AbstractAssignedCitizenModule)

Example 4 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.

the class PrivateWorkerCraftingProductionResolverFactory method deserialize.

@NotNull
@Override
public PrivateWorkerCraftingProductionResolver deserialize(@NotNull final IFactoryController controller, @NotNull final CompoundNBT nbt) {
    final IToken<?> token = controller.deserialize(nbt.getCompound(NBT_TOKEN));
    final ILocation location = controller.deserialize(nbt.getCompound(NBT_LOCATION));
    final JobEntry entry = IJobRegistry.getInstance().getValue(new ResourceLocation(nbt.getString(NBT_JOB)));
    return new PrivateWorkerCraftingProductionResolver(location, token, entry);
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) PrivateWorkerCraftingProductionResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PrivateWorkerCraftingProductionResolver) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) ResourceLocation(net.minecraft.util.ResourceLocation) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with JobEntry

use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.

the class PublicWorkerCraftingProductionResolverFactory method deserialize.

@Override
public PublicWorkerCraftingProductionResolver deserialize(IFactoryController controller, PacketBuffer buffer) throws Throwable {
    final IToken<?> token = controller.deserialize(buffer);
    final ILocation location = controller.deserialize(buffer);
    final JobEntry entry = buffer.readRegistryId();
    return new PublicWorkerCraftingProductionResolver(location, token, entry);
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) PublicWorkerCraftingProductionResolver(com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingProductionResolver)

Aggregations

JobEntry (com.minecolonies.api.colony.jobs.registry.JobEntry)36 ResourceLocation (net.minecraft.util.ResourceLocation)18 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)16 NotNull (org.jetbrains.annotations.NotNull)12 PublicWorkerCraftingRequestResolver (com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingRequestResolver)6 Nullable (org.jetbrains.annotations.Nullable)6 PublicWorkerCraftingProductionResolver (com.minecolonies.coremod.colony.requestsystem.resolvers.PublicWorkerCraftingProductionResolver)5 ICitizenData (com.minecolonies.api.colony.ICitizenData)4 IColony (com.minecolonies.api.colony.IColony)4 AbstractEntityCitizen (com.minecolonies.api.entity.citizen.AbstractEntityCitizen)4 RaiderType (com.minecolonies.api.entity.mobs.RaiderType)4 PrivateWorkerCraftingRequestResolver (com.minecolonies.coremod.colony.requestsystem.resolvers.PrivateWorkerCraftingRequestResolver)3 PacketBuffer (net.minecraft.network.PacketBuffer)3 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)3 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 com.minecolonies.api.colony.buildings.modules (com.minecolonies.api.colony.buildings.modules)2 ISettingKey (com.minecolonies.api.colony.buildings.modules.settings.ISettingKey)2 BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)2 IWareHouse (com.minecolonies.api.colony.buildings.workerbuildings.IWareHouse)2