mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Translate all rare items properly
This commit is contained in:
parent
8fe1b8f818
commit
c10cea4c76
2 changed files with 4 additions and 3 deletions
|
|
@ -58,6 +58,7 @@ import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData;
|
||||||
import org.geysermc.geyser.inventory.item.StoredItemMappings;
|
import org.geysermc.geyser.inventory.item.StoredItemMappings;
|
||||||
import org.geysermc.geyser.item.GeyserCustomMappingData;
|
import org.geysermc.geyser.item.GeyserCustomMappingData;
|
||||||
import org.geysermc.geyser.item.Items;
|
import org.geysermc.geyser.item.Items;
|
||||||
|
import org.geysermc.geyser.item.components.Rarity;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
import org.geysermc.geyser.item.type.Item;
|
||||||
import org.geysermc.geyser.registry.BlockRegistries;
|
import org.geysermc.geyser.registry.BlockRegistries;
|
||||||
import org.geysermc.geyser.registry.Registries;
|
import org.geysermc.geyser.registry.Registries;
|
||||||
|
|
@ -402,8 +403,9 @@ public class ItemRegistryPopulator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (javaOnlyItems.contains(javaItem)) {
|
if (javaOnlyItems.contains(javaItem) || javaItem.rarity() != Rarity.COMMON) {
|
||||||
// These items don't exist on Bedrock, so set up a variable that indicates they should have custom names
|
// These items don't exist on Bedrock, so set up a variable that indicates they should have custom names
|
||||||
|
// Or, ensure that we are translating these at all times to account for rarity colouring
|
||||||
mappingBuilder = mappingBuilder.translationString((bedrockBlock != null ? "block." : "item.") + entry.getKey().replace(":", "."));
|
mappingBuilder = mappingBuilder.translationString((bedrockBlock != null ? "block." : "item.") + entry.getKey().replace(":", "."));
|
||||||
GeyserImpl.getInstance().getLogger().debug("Adding " + entry.getKey() + " as an item that needs to be translated.");
|
GeyserImpl.getInstance().getLogger().debug("Adding " + entry.getKey() + " as an item that needs to be translated.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,6 @@ public final class ItemTranslator {
|
||||||
}
|
}
|
||||||
|
|
||||||
String customName = getCustomName(session, components, bedrockItem, rarity.getColor());
|
String customName = getCustomName(session, components, bedrockItem, rarity.getColor());
|
||||||
GeyserImpl.getInstance().getLogger().info("custom name: " + customName + " rarity: " + rarity.getName());
|
|
||||||
if (customName != null) {
|
if (customName != null) {
|
||||||
nbtBuilder.setCustomName(customName);
|
nbtBuilder.setCustomName(customName);
|
||||||
}
|
}
|
||||||
|
|
@ -446,7 +445,7 @@ public final class ItemTranslator {
|
||||||
// No custom name, but we need to localize the item's name
|
// No custom name, but we need to localize the item's name
|
||||||
String translationKey = mapping.getTranslationString();
|
String translationKey = mapping.getTranslationString();
|
||||||
// Reset formatting since Bedrock defaults to italics
|
// Reset formatting since Bedrock defaults to italics
|
||||||
return ChatColor.ESCAPE + translationColor + MinecraftLocale.getLocaleString(translationKey, session.locale());
|
return ChatColor.RESET + ChatColor.ESCAPE + translationColor + MinecraftLocale.getLocaleString(translationKey, session.locale());
|
||||||
}
|
}
|
||||||
// No custom name
|
// No custom name
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue