Fix NPE in TippedArrow when it has no components (#4694)

This commit is contained in:
Valaphee The Meerkat 2024-05-27 14:08:04 +02:00 committed by GitHub
parent 5f7a31a1d8
commit cb0488a271
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,6 +41,7 @@ public class TippedArrowItem extends ArrowItem {
@Override @Override
public ItemData.Builder translateToBedrock(int count, DataComponents components, ItemMapping mapping, ItemMappings mappings) { public ItemData.Builder translateToBedrock(int count, DataComponents components, ItemMapping mapping, ItemMappings mappings) {
if (components != null) {
PotionContents potionContents = components.get(DataComponentType.POTION_CONTENTS); PotionContents potionContents = components.get(DataComponentType.POTION_CONTENTS);
if (potionContents != null) { if (potionContents != null) {
TippedArrowPotion tippedArrowPotion = TippedArrowPotion.of(potionContents.getPotionId()); TippedArrowPotion tippedArrowPotion = TippedArrowPotion.of(potionContents.getPotionId());
@ -52,6 +53,7 @@ public class TippedArrowItem extends ArrowItem {
} }
GeyserImpl.getInstance().getLogger().debug("Unknown Java potion (tipped arrow): " + potionContents.getPotionId()); GeyserImpl.getInstance().getLogger().debug("Unknown Java potion (tipped arrow): " + potionContents.getPotionId());
} }
}
return super.translateToBedrock(count, components, mapping, mappings); return super.translateToBedrock(count, components, mapping, mappings);
} }
} }