Skip to content

Commit

Permalink
Update ChestLootRecipe.java
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzyhmstrs authored Sep 25, 2024
1 parent 06c2d6c commit b2295c8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ChestLootRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,29 @@ public ChestLootRecipe(ClientChestLootTable loot) {

outputs = outputsList;
String key = "emi_loot.chest." + loot.id.toString();
MutableText text = LText.translatable(key);
MutableText rawTitle;
if (!I18n.hasTranslation(key)) {
String chestName = "";
String[] chestPathTokens = loot.id.getPath().split("[\/_]");
for (String str : chestPathTokens) {
if (str.length() <= 1) {
chestName = chestName + " " + str;
} else {
chestName = chestName + " " + str.substring(0, 1).toUpperCase() + str.substring(1);
}
}
if(EMILootAgnos.isModLoaded(loot.id.getNamespace())) {
String modName = EMILootAgnos.getModName(loot.id.getNamespace());
rawTitle = LText.translatable("emi_loot.chest.unknown_chest", modName);
rawTitle = LText.translatable("emi_loot.chest.unknown_chest", chestName + modName);
} else {
Text unknown = LText.translatable("emi_loot.chest.unknown");
rawTitle = LText.translatable("emi_loot.chest.unknown_chest", unknown.getString());
rawTitle = LText.translatable("emi_loot.chest.unknown_chest", chestName + unknown.getString());
}
if (EMILoot.config.isLogI18n(EMILoot.Type.CHEST)) {
EMILoot.LOGGER.warn("Untranslated chest loot table \"" + loot.id + "\" (key: \"" + key + "\")");
}
} else {
rawTitle = text;
rawTitle = LText.translatable(key);
}
this.title = TrimmedTitle.of(rawTitle, 138);
}
Expand Down Expand Up @@ -170,4 +178,4 @@ public boolean supportsRecipeTree() {
public boolean hideCraftable() {
return EmiRecipe.super.hideCraftable();
}
}
}

0 comments on commit b2295c8

Please sign in to comment.