From 5f90bcbbafb31078c17bbbb82908eeff6edfe84e Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 28 Apr 2024 15:15:17 +0200 Subject: [PATCH] Fix item cost type reading --- .../api/minecraft/data/StructuredDataContainer.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataContainer.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataContainer.java index 27a219651..53a522475 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataContainer.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/data/StructuredDataContainer.java @@ -22,6 +22,7 @@ */ package com.viaversion.viaversion.api.minecraft.data; +import com.google.common.base.Preconditions; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.data.FullMappings; import com.viaversion.viaversion.api.protocol.Protocol; @@ -44,7 +45,7 @@ public final class StructuredDataContainer { public StructuredDataContainer(final StructuredData[] dataArray) { this(new Reference2ObjectOpenHashMap<>(dataArray.length)); for (final StructuredData data : dataArray) { - add(data); + this.data.put(data.key(), data); } } @@ -138,6 +139,7 @@ public final class StructuredDataContainer { */ public void setIdLookup(final Protocol protocol, final boolean mappedNames) { this.lookup = protocol.getMappingData().getDataComponentSerializerMappings(); + Preconditions.checkNotNull(this.lookup, "Data component serializer mappings are null"); this.mappedNames = mappedNames; } @@ -159,10 +161,6 @@ public final class StructuredDataContainer { return data; } - private void add(final StructuredData data) { - set(data.key(), data.value()); - } - @Override public String toString() { return "StructuredDataContainer{" +