Skip to content

Commit

Permalink
Log the correct error and don't log an error at all if a default icon…
Browse files Browse the repository at this point in the history
… doesn't exist (Closes #208)

- Fixed incorrect error being logged when a mod defines an invalid icon
- Fixed an error being logged when no icon is at the default path
  • Loading branch information
Prospector committed Feb 2, 2021
1 parent c8d893c commit 5517a75
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.terraformersmc.modmenu.util.mod;

import com.terraformersmc.modmenu.ModMenu;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.client.texture.NativeImage;
import net.minecraft.client.texture.NativeImageBackedTexture;
Expand All @@ -24,10 +22,6 @@ public class ModIconHandler {
public NativeImageBackedTexture createIcon(ModContainer iconSource, String iconPath) {
try {
Path path = iconSource.getPath(iconPath);
if (!Files.exists(path)) {
iconSource = FabricLoader.getInstance().getModContainer(ModMenu.MOD_ID).orElseThrow(() -> new RuntimeException("Cannot get ModContainer for Mod Menu!"));
iconPath = "assets/" + ModMenu.MOD_ID + "/unknown_icon.png";
}
NativeImageBackedTexture cachedIcon = getCachedModIcon(path);
if (cachedIcon != null) {
return cachedIcon;
Expand All @@ -45,7 +39,9 @@ public NativeImageBackedTexture createIcon(ModContainer iconSource, String iconP
}

} catch (Throwable t) {
LOGGER.error("Invalid mod icon for icon source {}: {}", iconSource.getMetadata().getId(), iconPath, t);
if (!iconPath.equals("assets/" + iconSource.getMetadata().getId() + "/icon.png")) {
LOGGER.error("Invalid mod icon for icon source {}: {}", iconSource.getMetadata().getId(), iconPath, t);
}
return null;
}
}
Expand Down

0 comments on commit 5517a75

Please sign in to comment.