Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/stats' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Caedis committed Jul 30, 2024
2 parents aaf8d39 + addddec commit b4a9d83
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import com.mitchej123.hodgepodge.Common;

import cpw.mods.fml.common.registry.GameRegistry;

Expand Down Expand Up @@ -58,9 +59,20 @@ public class MixinGameRegistry {

@Unique
private static StatCrafting hodgepodge$createAndRegisterStat(String key, Item item) {
String unlocalizedName;
try {
unlocalizedName = item.getUnlocalizedName();
} catch (Exception e) {
String registryName = item.delegate.name();
unlocalizedName = "item." + registryName + ".name";
Common.log.warn(
"An Exception occured while invoking Item.getUnlocalizedName() after registering the item {} ({})! Using fallback unlocalized name.",
registryName,
item.getClass().getName());
}
StatCrafting stat = new StatCrafting(
key + '.' + item.delegate.name(),
new ChatComponentTranslation(key, new ChatComponentTranslation(item.getUnlocalizedName())),
key + ".autogen." + item.delegate.name(),
new ChatComponentTranslation(key, new ChatComponentTranslation(unlocalizedName)),
item);
stat.registerStat();
return stat;
Expand Down

0 comments on commit b4a9d83

Please sign in to comment.