From 0fb45b0ea7820ebb7f83e71917cf2be14d09d55d Mon Sep 17 00:00:00 2001 From: roggy666 <59109355+roggy666@users.noreply.github.com> Date: Tue, 7 Apr 2026 22:20:35 +0400 Subject: [PATCH] Fix NPE in dimension_type registry handler for MC 26.1.1 When a player using an older client (via ViaBackwards) connects to a 26.1.1 server, the REGISTRY_DATA packet is remapped by Protocol26_1To1_21_11. The dimension_type handler assumes every dimension entry contains an "attributes" CompoundTag and calls removeNamespaced() on it to strip new visual fields (block_light_tint, night_vision_color, ambient_light_color). In 26.1.1 some dimension_type entries may not include the "attributes" tag at all, causing getCompoundTag("attributes") to return null. This results in a NullPointerException inside TagUtil.removeNamespaced, which crashes the encoder pipeline and disconnects the player with "Internal Exception: EncoderException". Added a null check before calling removeNamespaced so that dimensions without the attributes tag are silently skipped. --- .../protocol/v26_1to1_21_11/Protocol26_1To1_21_11.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/v26_1to1_21_11/Protocol26_1To1_21_11.java b/common/src/main/java/com/viaversion/viabackwards/protocol/v26_1to1_21_11/Protocol26_1To1_21_11.java index 27f985dd..9a500cb5 100644 --- a/common/src/main/java/com/viaversion/viabackwards/protocol/v26_1to1_21_11/Protocol26_1To1_21_11.java +++ b/common/src/main/java/com/viaversion/viabackwards/protocol/v26_1to1_21_11/Protocol26_1To1_21_11.java @@ -89,9 +89,11 @@ protected void registerPackets() { // Remove new environment attributes registryDataRewriter.addHandler("dimension_type", (key, tag) -> { final CompoundTag attributes = tag.getCompoundTag("attributes"); - removeNamespaced(attributes, "visual/block_light_tint"); - removeNamespaced(attributes, "visual/night_vision_color"); - removeNamespaced(attributes, "visual/ambient_light_color"); + if (attributes != null) { + removeNamespaced(attributes, "visual/block_light_tint"); + removeNamespaced(attributes, "visual/night_vision_color"); + removeNamespaced(attributes, "visual/ambient_light_color"); + } }); // Move around entity variant names and sounds