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