Skip to content

Commit

Permalink
Fix content attribution for pages
Browse files Browse the repository at this point in the history
  • Loading branch information
shartte committed Feb 9, 2025
1 parent ab034b2 commit 6bec709
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions src/main/java/guideme/internal/screen/GuideScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,32 +256,20 @@ protected boolean hasFooter() {
*/
@Nullable
private String getExternalSourceName() {
var sourcePackId = currentPage.sourcePack();
// If the pages came directly from a mod resource pack, we have to use the mod-list to resolve its name
if (sourcePackId.startsWith("mod:") || sourcePackId.startsWith("mod/")) {
var modId = sourcePackId.substring("mod:".length());

// Only show the source marker for pages that are not native to the guides mod
if (guide.getDefaultNamespace().equals(modId)) {
return null;
}
var pack = Minecraft.getInstance().getResourcePackRepository().getPack(currentPage.sourcePack());
if (pack != null && !pack.getId().equals("mod_resources")) {
return pack.getDescription().getString();
}

return ModList.get().getModContainerById(modId)
var pageNamespace = currentPage.id().getNamespace();
// If the page had an ID under another mod's namespace, we have to use the mod-list to resolve its name
if (!guide.getDefaultNamespace().equals(pageNamespace)) {
return ModList.get().getModContainerById(pageNamespace)
.map(ModContainer::getModInfo)
.map(IModInfo::getDisplayName)
.orElse(null);
}

// Only show the source marker for pages that are not native to the guides mod
if (guide.getDefaultNamespace().equals(sourcePackId)) {
return null;
}

var pack = Minecraft.getInstance().getResourcePackRepository().getPack(sourcePackId);
if (pack != null) {
return pack.getDescription().getString();
}

return null;
}

Expand Down

0 comments on commit 6bec709

Please sign in to comment.