use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by ldtteam.
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 ldtteam.
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 ldtteam.
the class WindowHireWorker method onOpened.
/**
* Called when the GUI has been opened. Will fill the fields and lists.
*/
@Override
public void onOpened() {
updateCitizens();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).off();
citizenList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return citizens.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
@NotNull final ICitizenDataView citizen = citizens.get(index);
final Button isPaused = rowPane.findPaneOfTypeByID(BUTTON_PAUSE, Button.class);
if (selectedModule.canAssign(citizen) && !selectedModule.isFull() && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).on();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else if ((selectedModule.isFull()) && !selectedModule.getAssignedCitizens().contains(citizen.getId())) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
isPaused.off();
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
} else {
rowPane.findPaneOfTypeByID(BUTTON_DONE, Button.class).off();
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).on();
if ((!selectedModule.getColony().isManualHiring() && selectedModule.getHiringMode() == HiringMode.DEFAULT) || (selectedModule.getHiringMode() == HiringMode.AUTO)) {
rowPane.findPaneOfTypeByID(BUTTON_FIRE, Button.class).disable();
findPaneOfTypeByID(AUTO_HIRE_WARN, Text.class).on();
}
isPaused.on();
isPaused.setText(LanguageHandler.format(citizen.isPaused() ? COM_MINECOLONIES_COREMOD_GUI_HIRE_UNPAUSE : COM_MINECOLONIES_COREMOD_GUI_HIRE_PAUSE));
}
if (citizen.isPaused()) {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).on();
} else {
rowPane.findPaneOfTypeByID(BUTTON_RESTART, Button.class).off();
}
final StringTextComponent intermString = new StringTextComponent(" ");
final TextBuilder textBuilder = PaneBuilders.textBuilder();
textBuilder.append(new StringTextComponent(""));
int skillCount = citizen.getCitizenSkillHandler().getSkills().entrySet().size();
final Skill primary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getPrimarySkill() : null;
final Skill secondary = selectedModule instanceof WorkerBuildingModuleView ? ((WorkerBuildingModuleView) selectedModule).getSecondarySkill() : null;
for (final Map.Entry<Skill, Tuple<Integer, Double>> entry : citizen.getCitizenSkillHandler().getSkills().entrySet()) {
final String skillName = entry.getKey().name().toLowerCase(Locale.US);
final int skillLevel = entry.getValue().getA();
final Style skillStyle = createColor(primary, secondary, entry.getKey());
textBuilder.append(new TranslationTextComponent("com.minecolonies.coremod.gui.citizen.skills." + skillName).setStyle(skillStyle));
textBuilder.append(new StringTextComponent(": " + skillLevel).setStyle(skillStyle));
if (--skillCount > 0) {
textBuilder.append(intermString);
}
}
// finish the current line
textBuilder.newLine();
rowPane.findPaneOfTypeByID(CITIZEN_LABEL, Text.class).setText((citizen.getJob().isEmpty() ? "" : LanguageHandler.format(citizen.getJob()) + ": ") + citizen.getName());
rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Text.class).setText(textBuilder.getText());
final JobEntry entry = selectedModule.getJobEntry();
PaneBuilders.tooltipBuilder().hoverPane(rowPane.findPaneOfTypeByID(ATTRIBUTES_LABEL, Text.class)).build().setText(new TranslationTextComponent(entry.getKey().toString() + ".skills.desc"));
}
});
jobList.setDataProvider(new ScrollingList.DataProvider() {
@Override
public int getElementCount() {
return moduleViews.size();
}
@Override
public void updateElement(final int index, @NotNull final Pane rowPane) {
final JobEntry entry = moduleViews.get(index).getJobEntry();
final Button button = rowPane.findPaneOfTypeByID(BUTTON_JOB, Button.class);
button.setText(new TranslationTextComponent(entry.getTranslationKey()));
if (entry.equals(selectedModule.getJobEntry())) {
button.disable();
} else {
button.enable();
}
PaneBuilders.tooltipBuilder().hoverPane(button).build().setText(new TranslationTextComponent(entry.getKey().toString() + ".job.desc"));
}
});
}
use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.
the class ICraftingBuildingModule method getUid.
/**
* Gets a unique identifier for this crafting module, based on
* the job and disambiguation suffix. May be null where there
* was no job.
* @return The unique id or null.
*/
@Nullable
default ResourceLocation getUid() {
final IJob<?> job = getCraftingJob();
if (job == null)
return null;
final JobEntry entry = job.getJobRegistryEntry();
return getUid(entry, getId());
}
use of com.minecolonies.api.colony.jobs.registry.JobEntry in project minecolonies by Minecolonies.
the class DefaultSoundProvider method run.
@Override
public void run(@NotNull final DirectoryCache cache) throws IOException {
sounds = new JsonObject();
final List<String> defaultMaleSounds = new ArrayList<>();
defaultMaleSounds.add("minecolonies:mob/citizen/male/say1");
defaultMaleSounds.add("minecolonies:mob/citizen/male/say2");
defaultMaleSounds.add("minecolonies:mob/citizen/male/say3");
final List<String> defaultFemaleSounds = new ArrayList<>();
defaultFemaleSounds.add("minecolonies:mob/citizen/female/say1");
defaultFemaleSounds.add("minecolonies:mob/citizen/female/say2");
defaultFemaleSounds.add("minecolonies:mob/citizen/female/say3");
final List<String> childSounds = new ArrayList<>();
childSounds.add("minecolonies:mob/citizen/child/laugh1");
childSounds.add("minecolonies:mob/citizen/child/laugh2");
for (final JobEntry job : IJobRegistry.getInstance().getValues()) {
if (job.getRegistryName().getNamespace().equals(Constants.MOD_ID) && !job.getRegistryName().getPath().equals("placeholder")) {
for (final EventType soundEvents : EventType.values()) {
sounds.add("mob." + job.getRegistryName().getPath() + ".male." + soundEvents.name().toLowerCase(Locale.US), createSoundJson("neutral", getDefaultProperties(), defaultMaleSounds));
sounds.add("mob." + job.getRegistryName().getPath() + ".female." + soundEvents.name().toLowerCase(Locale.US), createSoundJson("neutral", getDefaultProperties(), defaultFemaleSounds));
}
}
}
for (final EventType soundEvents : EventType.values()) {
sounds.add("mob.citizen.male." + soundEvents.name().toLowerCase(Locale.US), createSoundJson("neutral", getDefaultProperties(), defaultMaleSounds));
sounds.add("mob.citizen.female." + soundEvents.name().toLowerCase(Locale.US), createSoundJson("neutral", getDefaultProperties(), defaultFemaleSounds));
}
for (final EventType soundEvents : EventType.values()) {
sounds.add("mob.child.male." + soundEvents.name().toLowerCase(Locale.US), createSoundJson("neutral", getDefaultProperties(), childSounds));
sounds.add("mob.child.female." + soundEvents.name().toLowerCase(Locale.US), createSoundJson("neutral", getDefaultProperties(), childSounds));
}
for (final RaiderType type : RaiderType.values()) {
sounds.add("mob." + type.name().toLowerCase(Locale.US) + ".death", createSoundJson("hostile", getDefaultProperties(), ImmutableList.of("minecolonies:mob/barbarian/death")));
sounds.add("mob." + type.name().toLowerCase(Locale.US) + ".say", createSoundJson("hostile", getDefaultProperties(), ImmutableList.of("minecolonies:mob/barbarian/say")));
sounds.add("mob." + type.name().toLowerCase(Locale.US) + ".hurt", createSoundJson("hostile", getDefaultProperties(), ImmutableList.of("minecolonies:mob/barbarian/hurt1", "minecolonies:mob/barbarian/hurt2", "minecolonies:mob/barbarian/hurt3", "minecolonies:mob/barbarian/hurt4")));
}
sounds.add("mob.citizen.snore", createSoundJson("neutral", getDefaultProperties(), ImmutableList.of("minecolonies:mob/citizen/snore")));
JsonObject tavernProperties = getDefaultProperties();
tavernProperties.addProperty("attenuation_distance", 23);
tavernProperties.addProperty("stream", true);
tavernProperties.addProperty("comment", "Credits to Darren Curtis - Fireside Tales");
sounds.add("tile.tavern.tavern_theme", createSoundJson("music", tavernProperties, ImmutableList.of("minecolonies:tile/tavern/tavern_theme")));
sounds.add("mob.mercenary.attack", createSoundJson("neutral", getDefaultProperties(), ImmutableList.of("minecolonies:mob/mercenary/attack/attack1", "minecolonies:mob/mercenary/attack/attack2", "minecolonies:mob/mercenary/attack/attack3", "minecolonies:mob/mercenary/attack/attack4")));
sounds.add("mob.mercenary.celebrate", createSoundJson("neutral", getDefaultProperties(), ImmutableList.of("minecolonies:mob/mercenary/celebrate/celebrate1")));
sounds.add("mob.mercenary.die", createSoundJson("neutral", getDefaultProperties(), ImmutableList.of("minecolonies:mob/mercenary/die/death1", "minecolonies:mob/mercenary/die/death2")));
sounds.add("mob.mercenary.hurt", createSoundJson("neutral", getDefaultProperties(), ImmutableList.of("minecolonies:mob/mercenary/hurt/hurt1", "minecolonies:mob/mercenary/hurt/hurt2", "minecolonies:mob/mercenary/hurt/hurt3")));
sounds.add("mob.mercenary.say", createSoundJson("neutral", getDefaultProperties(), ImmutableList.of("minecolonies:mob/mercenary/say/say1", "minecolonies:mob/mercenary/say/say2", "minecolonies:mob/mercenary/say/say3")));
sounds.add("mob.mercenary.step", createSoundJson("neutral", getDefaultProperties(), ImmutableList.of("minecolonies:mob/mercenary/step/step1", "minecolonies:mob/mercenary/step/step2", "minecolonies:mob/mercenary/step/step3", "minecolonies:mob/mercenary/step/step4")));
add("record", false, "raid.raid_alert", "raid.raid_alert_early", "raid.raid_won", "raid.raid_won_early");
add("music", true, "raid.desert.desert_raid", "raid.desert.desert_raid_warning", "raid.desert.desert_raid_victory", "raid.amazon.amazon_raid");
final Path savePath = generator.getOutputFolder().resolve(DataGeneratorConstants.ASSETS_DIR).resolve("sounds.json");
IDataProvider.save(DataGeneratorConstants.GSON, cache, sounds, savePath);
}
Aggregations