Skip to content

Commit

Permalink
Get ModName from items more efficiently
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Sep 16, 2016
1 parent 0fbd364 commit 4c448fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/main/java/mezz/jei/ItemRegistry.java
Expand Up @@ -66,6 +66,11 @@ public String getModNameForItem(@Nullable Item item) {
return modList.getModNameForItem(item);
}

@Nonnull
public String getModNameForModId(@Nonnull String modId) {
return modList.getModNameForModId(modId);
}

@Nonnull
@Override
public ImmutableList<ItemStack> getItemListForModId(@Nullable String modId) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/mezz/jei/util/ItemStackElement.java
Expand Up @@ -8,6 +8,7 @@

import com.google.common.base.Joiner;
import mezz.jei.Internal;
import mezz.jei.ItemRegistry;
import mezz.jei.config.Config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
Expand Down Expand Up @@ -65,7 +66,8 @@ private ItemStackElement(@Nonnull ItemStack itemStack) {
}

String modId = itemResourceLocation.getResourceDomain().toLowerCase(Locale.ENGLISH);
String modName = Internal.getItemRegistry().getModNameForItem(item).toLowerCase(Locale.ENGLISH);
ItemRegistry itemRegistry = Internal.getItemRegistry();
String modName = itemRegistry.getModNameForModId(modId).toLowerCase(Locale.ENGLISH);

String displayName = itemStack.getDisplayName();
if (displayName == null) {
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/mezz/jei/util/ModList.java
Expand Up @@ -33,6 +33,11 @@ public String getModNameForItem(@Nonnull Item item) {
throw new NullPointerException("item.getRegistryName() returned null for: " + stackInfo);
}
String modId = itemResourceLocation.getResourceDomain();
return getModNameForModId(modId);
}

@Nonnull
public String getModNameForModId(@Nonnull String modId) {
String lowercaseModId = modId.toLowerCase(Locale.ENGLISH);
String modName = modNamesForIds.get(lowercaseModId);
if (modName == null) {
Expand Down

0 comments on commit 4c448fe

Please sign in to comment.