From 87aed8f3f20567fc801c86da307fd6cc22d5e6d2 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Fri, 3 Dec 2021 08:59:28 +0100 Subject: [PATCH] Fix NPE Fixes ViaVersion/ViaVersion#2751 --- .../providers/BackwardsBlockEntityProvider.java | 8 +++++++- .../protocol1_13_2to1_14/packets/EntityPackets1_14.java | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java index 456183af..a7796ac2 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/providers/BackwardsBlockEntityProvider.java @@ -33,6 +33,7 @@ import com.viaversion.viaversion.api.platform.providers.Provider; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; +import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag; import java.util.HashMap; import java.util.Map; @@ -67,7 +68,12 @@ public class BackwardsBlockEntityProvider implements Provider { * @param tag The block entity tag */ public CompoundTag transform(UserConnection user, Position position, CompoundTag tag) throws Exception { - String id = (String) tag.get("id").getValue(); + final Tag idTag = tag.get("id"); + if (!(idTag instanceof StringTag)) { + return tag; + } + + String id = (String) idTag.getValue(); BackwardsBlockEntityHandler handler = handlers.get(id); if (handler == null) { if (Via.getManager().isDebug()) { diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java index 8a88a27e..15ea06e9 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_13_2to1_14/packets/EntityPackets1_14.java @@ -372,7 +372,7 @@ public class EntityPackets1_14 extends LegacyEntityRewriter