Skip to content

Commit

Permalink
Add json name parsing to loot recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzyhmstrs committed Sep 26, 2024
1 parent 65d4cd9 commit db1e4e5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,21 @@ public ArchaeologyLootRecipe(ClientArchaeologyLootTable loot) {
MutableText text = LText.translatable(key);
MutableText rawTitle;
if(!I18n.hasTranslation(key)) {
StringBuilder archName = new StringBuilder();
String[] chestPathTokens = loot.id.getPath().split("[/_]");
for (String str : chestPathTokens) {
if (str.length() <= 1) {
archName.append(" ").append(str);
} else {
archName.append(" ").append(str.substring(0, 1).toUpperCase()).append(str.substring(1));
}
}
if(EMILootAgnos.isModLoaded(loot.id.getNamespace())) {
String modName = EMILootAgnos.getModName(loot.id.getNamespace());
rawTitle = LText.translatable("emi_loot.archaeology.unknown_archaeology", modName);
rawTitle = LText.translatable("emi_loot.archaeology.unknown_archaeology", archName.toString() + modName);
} else {
Text unknown = LText.translatable("emi_loot.archaeology.unknown");
rawTitle = LText.translatable("emi_loot.archaeology.unknown_archaeology", unknown.getString());
rawTitle = LText.translatable("emi_loot.archaeology.unknown_archaeology", archName.toString() + unknown.getString());
}
if (EMILoot.config.isLogI18n(EMILoot.Type.ARCHAEOLOGY)) {
EMILoot.LOGGER.warn("Untranslated archaeology loot table \"" + loot.id + "\" (key: \"" + key + "\")");
Expand Down
13 changes: 11 additions & 2 deletions xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ChestLootRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,21 @@ public ChestLootRecipe(ClientChestLootTable loot) {
MutableText text = LText.translatable(key);
MutableText rawTitle;
if (!I18n.hasTranslation(key)) {
StringBuilder chestName = new StringBuilder();
String[] chestPathTokens = loot.id.getPath().split("[/_]");
for (String str : chestPathTokens) {
if (str.length() <= 1) {
chestName.append(" ").append(str);
} else {
chestName.append(" ").append(str.substring(0, 1).toUpperCase()).append(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.toString() + 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.toString() + unknown.getString());
}
if (EMILoot.config.isLogI18n(EMILoot.Type.CHEST)) {
EMILoot.LOGGER.warn("Untranslated chest loot table \"" + loot.id + "\" (key: \"" + key + "\")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,21 @@ public GameplayLootRecipe(ClientGameplayLootTable loot) {
Text text = LText.translatable(key);
Text rawTitle;
if (!I18n.hasTranslation(key)) {
StringBuilder gameplayName = new StringBuilder();
String[] chestPathTokens = loot.id.getPath().split("[/_]");
for (String str : chestPathTokens) {
if (str.length() <= 1) {
gameplayName.append(" ").append(str);
} else {
gameplayName.append(" ").append(str.substring(0, 1).toUpperCase()).append(str.substring(1));
}
}
if(EMILootAgnos.isModLoaded(loot.id.getNamespace())) {
String modName = EMILootAgnos.getModName(loot.id.getNamespace());
rawTitle = LText.translatable("emi_loot.gameplay.unknown_gameplay", modName);
rawTitle = LText.translatable("emi_loot.gameplay.unknown_gameplay", gameplayName.toString() + modName);
} else {
Text unknown = LText.translatable("emi_loot.gameplay.unknown");
rawTitle = LText.translatable("emi_loot.gameplay.unknown_gameplay", unknown.getString());
rawTitle = LText.translatable("emi_loot.gameplay.unknown_gameplay", gameplayName.toString() + unknown.getString());
}
if (EMILoot.config.isLogI18n(EMILoot.Type.GAMEPLAY)) {
EMILoot.LOGGER.warn("Untranslated gameplay loot table \"" + loot.id + "\" (key: \"" + key + "\")");
Expand Down

0 comments on commit db1e4e5

Please sign in to comment.