From 093328db11201892b76f4930c9eab61708295a94 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 5 May 2024 16:53:36 +0200 Subject: [PATCH] Handle missing mappings --- .../viabackwards/api/data/BackwardsMappings.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java b/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java index f73bb5f1..9f83491e 100644 --- a/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java +++ b/common/src/main/java/com/viaversion/viabackwards/api/data/BackwardsMappings.java @@ -22,6 +22,7 @@ import com.viaversion.viabackwards.ViaBackwards; import com.viaversion.viabackwards.api.BackwardsProtocol; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.data.BiMappings; +import com.viaversion.viaversion.api.data.IdentityMappings; import com.viaversion.viaversion.api.data.MappingData; import com.viaversion.viaversion.api.data.MappingDataBase; import com.viaversion.viaversion.api.data.Mappings; @@ -116,10 +117,14 @@ public class BackwardsMappings extends MappingDataBase { @Override protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) { if (key.equals("items") && vvProtocolClass != null) { - final Mappings mappings = super.loadMappings(data, key); + Mappings mappings = super.loadMappings(data, key); final MappingData mappingData = Via.getManager().getProtocolManager().getProtocol(vvProtocolClass).getMappingData(); if (mappingData != null && mappingData.getItemMappings() != null) { - return ItemMappings.of(mappings, mappingData.getItemMappings()); + final BiMappings vvItemMappings = mappingData.getItemMappings(); + if (mappings == null) { + mappings = new IdentityMappings(vvItemMappings.mappedSize(), vvItemMappings.size()); + } + return ItemMappings.of(mappings, vvItemMappings); } } return super.loadBiMappings(data, key);