Skip to content

Commit

Permalink
Added getIcon function to addon API.
Browse files Browse the repository at this point in the history
  • Loading branch information
coltonk9043 committed Aug 10, 2024
1 parent a701ff1 commit b0d7052
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/net/aoba/api/IAddon.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.minecraft.util.Identifier;

import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -110,4 +111,13 @@ default String getVersion() {
}
return "Unknown";
}

default Optional<String> getIcon() {
Optional<ModContainer> modContainer = FabricLoader.getInstance().getModContainer(getId());
if (modContainer.isPresent()) {
ModMetadata metadata = modContainer.get().getMetadata();
return metadata.getIconPath(64);
}
return Optional.ofNullable("Unknown");
}
}

0 comments on commit b0d7052

Please sign in to comment.