Fix Custom Model Data not working on Potions. (#3616)

This commit is contained in:
Tydium 2023-03-28 14:35:22 -04:00 committed by GitHub
parent 2a8d8b6cdf
commit 45e043c6e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,6 +48,8 @@ public class PotionTranslator extends ItemTranslator {
if (itemStack.getNbt() == null) return super.translateToBedrock(itemStack, mapping, mappings); if (itemStack.getNbt() == null) return super.translateToBedrock(itemStack, mapping, mappings);
Tag potionTag = itemStack.getNbt().get("Potion"); Tag potionTag = itemStack.getNbt().get("Potion");
if (potionTag instanceof StringTag) { if (potionTag instanceof StringTag) {
int customItemId = CustomItemTranslator.getCustomItem(itemStack.getNbt(), mapping);
if (customItemId == -1) {
Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue()); Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
if (potion != null) { if (potion != null) {
return ItemData.builder() return ItemData.builder()
@ -57,6 +59,12 @@ public class PotionTranslator extends ItemTranslator {
.tag(translateNbtToBedrock(itemStack.getNbt())); .tag(translateNbtToBedrock(itemStack.getNbt()));
} }
GeyserImpl.getInstance().getLogger().debug("Unknown Java potion: " + potionTag.getValue()); GeyserImpl.getInstance().getLogger().debug("Unknown Java potion: " + potionTag.getValue());
} else {
return ItemData.builder()
.id(customItemId)
.count(itemStack.getAmount())
.tag(translateNbtToBedrock(itemStack.getNbt()));
}
} }
return super.translateToBedrock(itemStack, mapping, mappings); return super.translateToBedrock(itemStack, mapping, mappings);
} }