Skip to content

Commit

Permalink
Some more small fixes with fake parent mods
Browse files Browse the repository at this point in the history
  • Loading branch information
Prospector committed Feb 1, 2021
1 parent 0eaa181 commit b9a15ed
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/terraformersmc/modmenu/gui/ModsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
trimmedName = StringVisitable.concat(textRenderer.trimToWidth(name, maxNameWidth - textRenderer.getWidth(ellipsis)), ellipsis);
}
textRenderer.draw(matrices, Language.getInstance().reorder(trimmedName), x + imageOffset, paneY + 1, 0xFFFFFF);
if (mouseX > x + imageOffset && mouseY > paneY + 1 && mouseY < paneY + 1 + textRenderer.fontHeight && mouseX < x + imageOffset + textRenderer.getWidth(trimmedName)) {
if (mod.isReal() && mouseX > x + imageOffset && mouseY > paneY + 1 && mouseY < paneY + 1 + textRenderer.fontHeight && mouseX < x + imageOffset + textRenderer.getWidth(trimmedName)) {
setTooltip(new TranslatableText("modmenu.modIdToolTip", mod.getId()));
}
if (init || modBadgeRenderer == null || modBadgeRenderer.getMod() != mod) {
Expand All @@ -321,7 +321,9 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
if (!ModMenuConfig.HIDE_BADGES.getValue()) {
modBadgeRenderer.draw(matrices, mouseX, mouseY);
}
textRenderer.draw(matrices, "v" + mod.getVersion(), x + imageOffset, paneY + 2 + lineSpacing, 0x808080);
if (mod.isReal()) {
textRenderer.draw(matrices, "v" + mod.getVersion(), x + imageOffset, paneY + 2 + lineSpacing, 0x808080);
}
String authors;
List<String> names = mod.getAuthors();

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ public interface Mod {
@Nullable
String getParent();

@NotNull
Set<String> getLicense();

@NotNull
Map<String, String> getLinks();

boolean isReal();

enum Badge {
LIBRARY("modmenu.library", 0xff107454, 0xff093929, "library"),
CLIENT("modmenu.clientsideOnly", 0xff2b4b7c, 0xff0e2a55, "client"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,17 @@ public FabricDummyParentMod(FabricMod host, String id) {
}

@Override
public @Nullable Set<String> getLicense() {
public @NotNull Set<String> getLicense() {
return new HashSet<>();
}

@Override
public Map<String, String> getLinks() {
public @NotNull Map<String, String> getLinks() {
return new HashMap<>();
}

@Override
public boolean isReal() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public FabricMod(ModContainer modContainer) {
CustomValueUtil.getString("name", parentObj),
CustomValueUtil.getString("description", parentObj),
CustomValueUtil.getString("icon", parentObj),
CustomValueUtil.getStringSet("modmenu:badges", parentObj).orElse(new HashSet<>())
CustomValueUtil.getStringSet("badges", parentObj).orElse(new HashSet<>())
);
} catch (Throwable t) {
LOGGER.error("Error loading parent data from mod: " + metadata.getId(), t);
Expand Down Expand Up @@ -243,18 +243,23 @@ public FabricMod(ModContainer modContainer) {
}

@Override
public @Nullable Set<String> getLicense() {
public @NotNull Set<String> getLicense() {
if ("minecraft".equals(getId())) {
return Sets.newHashSet("All Rights Reserved");
}
return Sets.newHashSet(metadata.getLicense());
}

@Override
public @Nullable Map<String, String> getLinks() {
public @NotNull Map<String, String> getLinks() {
return links;
}

@Override
public boolean isReal() {
return true;
}

public ModMenuData getModMenuData() {
return modMenuData;
}
Expand Down

0 comments on commit b9a15ed

Please sign in to comment.