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 cf604dd2..c64e3f04 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
@@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.data.BiMappings;
import com.viaversion.viaversion.api.data.MappingData;
import com.viaversion.viaversion.api.data.MappingDataBase;
+import com.viaversion.viaversion.api.data.Mappings;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
@@ -87,9 +88,10 @@ 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);
final MappingData mappingData = Via.getManager().getProtocolManager().getProtocol(vvProtocolClass).getMappingData();
if (mappingData != null && mappingData.getItemMappings() != null) {
- return mappingData.getItemMappings().inverse();
+ return ItemMappings.of(mappings, mappingData.getItemMappings());
}
}
return super.loadBiMappings(data, key);
diff --git a/common/src/main/java/com/viaversion/viabackwards/api/data/ItemMappings.java b/common/src/main/java/com/viaversion/viabackwards/api/data/ItemMappings.java
new file mode 100644
index 00000000..83a89d71
--- /dev/null
+++ b/common/src/main/java/com/viaversion/viabackwards/api/data/ItemMappings.java
@@ -0,0 +1,72 @@
+/*
+ * This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
+ * Copyright (C) 2023 ViaVersion and contributors
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package com.viaversion.viabackwards.api.data;
+
+import com.viaversion.viaversion.api.data.BiMappings;
+import com.viaversion.viaversion.api.data.Mappings;
+
+public final class ItemMappings implements BiMappings {
+
+ private final Mappings mappings;
+ private final ItemMappings inverse;
+
+ private ItemMappings(final Mappings mappings, final Mappings inverse) {
+ this.mappings = mappings;
+ this.inverse = new ItemMappings(inverse, this);
+ }
+
+ private ItemMappings(final Mappings mappings, final ItemMappings inverse) {
+ this.mappings = mappings;
+ this.inverse = inverse;
+ }
+
+ public static ItemMappings of(final Mappings mappings, final Mappings inverse) {
+ return new ItemMappings(mappings, inverse);
+ }
+
+ @Override
+ public BiMappings inverse() {
+ return inverse;
+ }
+
+ @Override
+ public int getNewId(final int id) {
+ return mappings.getNewId(id);
+ }
+
+ @Override
+ public void setNewId(final int id, final int mappedId) {
+ // Only set one-way
+ mappings.setNewId(id, mappedId);
+ }
+
+ @Override
+ public int size() {
+ return mappings.size();
+ }
+
+ @Override
+ public int mappedSize() {
+ return mappings.mappedSize();
+ }
+
+ //TODO remove
+ public Mappings createInverse() {
+ return null;
+ }
+}
diff --git a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java
index d198086a..6305e6e0 100644
--- a/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java
+++ b/common/src/main/java/com/viaversion/viabackwards/protocol/protocol1_12_2to1_13/data/BackwardsMappings.java
@@ -18,8 +18,6 @@
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
-import com.viaversion.viaversion.api.data.BiMappings;
-import com.viaversion.viaversion.api.data.Mappings;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap;
import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectOpenHashMap;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
@@ -27,7 +25,6 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.StatisticMappings;
import java.util.HashMap;
import java.util.Map;
-import org.checkerframework.checker.nullness.qual.Nullable;
public class BackwardsMappings extends com.viaversion.viabackwards.api.data.BackwardsMappings {
private final Int2ObjectMap statisticMappings = new Int2ObjectOpenHashMap<>();
@@ -39,40 +36,6 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
@Override
public void loadExtras(final CompoundTag data) {
- final Mappings itemsToMapped = loadMappings(data, "items");
- final BiMappings itemsToUnmapped = Protocol1_13To1_12_2.MAPPINGS.getItemMappings();
- this.itemMappings = new BiMappings() {
- @Override
- public BiMappings inverse() {
- return itemsToUnmapped;
- }
-
- @Override
- public int getNewId(int id) {
- return itemsToMapped.getNewId(id);
- }
-
- @Override
- public void setNewId(int id, int mappedId) {
- itemsToMapped.setNewId(id, mappedId);
- }
-
- @Override
- public int size() {
- return itemsToMapped.size();
- }
-
- @Override
- public int mappedSize() {
- return itemsToMapped.mappedSize();
- }
-
- @Override
- public Mappings createInverse() {
- return itemsToMapped.createInverse();
- }
- };
-
super.loadExtras(data);
for (Map.Entry entry : StatisticMappings.CUSTOM_STATS.entrySet()) {
@@ -83,31 +46,6 @@ public class BackwardsMappings extends com.viaversion.viabackwards.api.data.Back
}
}
- @Override
- protected @Nullable BiMappings loadBiMappings(final CompoundTag data, final String key) {
- // Special cursed case
- if (key.equals("items")) {
- return null;
- } else {
- return super.loadBiMappings(data, key);
- }
- }
-
- @Override
- public BiMappings getItemMappings() {
- return itemMappings;
- }
-
- @Override
- public int getNewItemId(final int id) {
- return itemMappings.getNewId(id);
- }
-
- @Override
- public int getOldItemId(final int id) {
- return itemMappings.inverse().getNewId(id);
- }
-
@Override
public int getNewBlockStateId(int id) {
// Comparator funkyness: https://github.com/ViaVersion/ViaBackwards/issues/524
diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.10to1.9.4.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.10to1.9.4.nbt
index 14a89fbd..124df3d8 100644
Binary files a/common/src/main/resources/assets/viabackwards/data/mappings-1.10to1.9.4.nbt and b/common/src/main/resources/assets/viabackwards/data/mappings-1.10to1.9.4.nbt differ
diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.11to1.10.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.11to1.10.nbt
index 66a22181..6622945f 100644
Binary files a/common/src/main/resources/assets/viabackwards/data/mappings-1.11to1.10.nbt and b/common/src/main/resources/assets/viabackwards/data/mappings-1.11to1.10.nbt differ
diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.12to1.11.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.12to1.11.nbt
index 3a0ac746..d0dbac93 100644
Binary files a/common/src/main/resources/assets/viabackwards/data/mappings-1.12to1.11.nbt and b/common/src/main/resources/assets/viabackwards/data/mappings-1.12to1.11.nbt differ
diff --git a/common/src/main/resources/assets/viabackwards/data/mappings-1.13.2to1.13.nbt b/common/src/main/resources/assets/viabackwards/data/mappings-1.13.2to1.13.nbt
index 10fd51c3..b04c3cde 100644
Binary files a/common/src/main/resources/assets/viabackwards/data/mappings-1.13.2to1.13.nbt and b/common/src/main/resources/assets/viabackwards/data/mappings-1.13.2to1.13.nbt differ