mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Fix NPE for unknown enchantments/enchantments not in bedrock
This commit is contained in:
parent
6f7ad4b569
commit
59b2805a4a
1 changed files with 6 additions and 4 deletions
|
@ -58,9 +58,11 @@ public class EnchantmentTranslator extends NbtItemStackTranslator {
|
||||||
if (!(tag instanceof CompoundTag)) continue;
|
if (!(tag instanceof CompoundTag)) continue;
|
||||||
|
|
||||||
CompoundTag bedrockTag = remapEnchantment((CompoundTag) tag);
|
CompoundTag bedrockTag = remapEnchantment((CompoundTag) tag);
|
||||||
|
if (bedrockTag != null) {
|
||||||
bedrockTag.put(new ShortTag("GeyserStoredEnchantment", (short) 0));
|
bedrockTag.put(new ShortTag("GeyserStoredEnchantment", (short) 0));
|
||||||
newTags.add(bedrockTag);
|
newTags.add(bedrockTag);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
itemTag.remove("StoredEnchantments");
|
itemTag.remove("StoredEnchantments");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,11 +119,11 @@ public class EnchantmentTranslator extends NbtItemStackTranslator {
|
||||||
|
|
||||||
|
|
||||||
private CompoundTag remapEnchantment(CompoundTag tag) {
|
private CompoundTag remapEnchantment(CompoundTag tag) {
|
||||||
Tag javaEnchLvl = ((CompoundTag) tag).get("lvl");
|
Tag javaEnchLvl = tag.get("lvl");
|
||||||
if (!(javaEnchLvl instanceof ShortTag))
|
if (!(javaEnchLvl instanceof ShortTag))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Tag javaEnchId = ((CompoundTag) tag).get("id");
|
Tag javaEnchId = tag.get("id");
|
||||||
if (!(javaEnchId instanceof StringTag))
|
if (!(javaEnchId instanceof StringTag))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue