mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-26 16:57:14 +01:00
Map new Mace enchantments for Bedrock clients (#4653)
* Map new Mace enchantments for Bedrock clients * Move to using a map for Java-only enchantments. * Change to using null check for translationKey
This commit is contained in:
parent
e697eb3ae3
commit
7801e357fb
1 changed files with 16 additions and 5 deletions
|
@ -53,6 +53,16 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class Item {
|
public class Item {
|
||||||
|
/**
|
||||||
|
* This is a map from Java-only enchantments to their translation keys so that we can
|
||||||
|
* map these enchantments to Bedrock clients, since they don't actually exist there.
|
||||||
|
*/
|
||||||
|
private static final Map<Enchantment.JavaEnchantment, String> ENCHANTMENT_TRANSLATION_KEYS = Map.of(
|
||||||
|
Enchantment.JavaEnchantment.SWEEPING_EDGE, "enchantment.minecraft.sweeping",
|
||||||
|
Enchantment.JavaEnchantment.DENSITY, "enchantment.minecraft.density",
|
||||||
|
Enchantment.JavaEnchantment.BREACH, "enchantment.minecraft.breach",
|
||||||
|
Enchantment.JavaEnchantment.WIND_BURST, "enchantment.minecraft.wind_burst");
|
||||||
|
|
||||||
private final String javaIdentifier;
|
private final String javaIdentifier;
|
||||||
private int javaId = -1;
|
private int javaId = -1;
|
||||||
private final int stackSize;
|
private final int stackSize;
|
||||||
|
@ -227,8 +237,10 @@ public class Item {
|
||||||
// TODO verify
|
// TODO verify
|
||||||
// TODO streamline Enchantment process
|
// TODO streamline Enchantment process
|
||||||
Enchantment.JavaEnchantment enchantment = Enchantment.JavaEnchantment.of(enchantId);
|
Enchantment.JavaEnchantment enchantment = Enchantment.JavaEnchantment.of(enchantId);
|
||||||
if (enchantment == Enchantment.JavaEnchantment.SWEEPING_EDGE) {
|
String translationKey = ENCHANTMENT_TRANSLATION_KEYS.get(enchantment);
|
||||||
addSweeping(session, builder, level);
|
if (translationKey != null) {
|
||||||
|
String enchantmentTranslation = MinecraftLocale.getLocaleString(translationKey, session.locale());
|
||||||
|
addJavaOnlyEnchantment(session, builder, enchantmentTranslation, level);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (enchantment == null) {
|
if (enchantment == null) {
|
||||||
|
@ -242,11 +254,10 @@ public class Item {
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSweeping(GeyserSession session, BedrockItemBuilder builder, int level) {
|
private void addJavaOnlyEnchantment(GeyserSession session, BedrockItemBuilder builder, String enchantmentName, int level) {
|
||||||
String sweepingTranslation = MinecraftLocale.getLocaleString("enchantment.minecraft.sweeping", session.locale());
|
|
||||||
String lvlTranslation = MinecraftLocale.getLocaleString("enchantment.level." + level, session.locale());
|
String lvlTranslation = MinecraftLocale.getLocaleString("enchantment.level." + level, session.locale());
|
||||||
|
|
||||||
builder.getOrCreateLore().add(ChatColor.RESET + ChatColor.GRAY + sweepingTranslation + " " + lvlTranslation);
|
builder.getOrCreateLore().add(ChatColor.RESET + ChatColor.GRAY + enchantmentName + " " + lvlTranslation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Translation methods end */
|
/* Translation methods end */
|
||||||
|
|
Loading…
Reference in a new issue