From 71361be66c643e44c00d8d21d6a4c482893ac2db Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 6 Mar 2023 10:53:41 +0100 Subject: [PATCH] Update mapping files --- .../api/data/BackwardsMappings.java | 4 +- .../viabackwards/api/data/ItemMappings.java | 72 ++++++++++++++++++ .../data/BackwardsMappings.java | 62 --------------- .../data/mappings-1.10to1.9.4.nbt | Bin 232 -> 1165 bytes .../viabackwards/data/mappings-1.11to1.10.nbt | Bin 360 -> 2050 bytes .../viabackwards/data/mappings-1.12to1.11.nbt | Bin 1680 -> 4441 bytes .../data/mappings-1.13.2to1.13.nbt | Bin 618 -> 814 bytes 7 files changed, 75 insertions(+), 63 deletions(-) create mode 100644 common/src/main/java/com/viaversion/viabackwards/api/data/ItemMappings.java 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 14a89fbd0fc6a65c6b8afeb3a89a4379e599e552..124df3d8c04968dd7baea437ed1bbf996a228a43 100644 GIT binary patch literal 1165 zcmaixOHSNC5Qb|Q1eRw53<;n?h$S1G2V##R4iG5^7`4X@wrqEs?lz-A$|3@VOXUu^ zN|qrag5Qre^T30pPwp=NRj$9vCF;`pHCH;4f`~dUt!bHyKzGSaS(fqOTXe(m;a7)N zqM*~IRb2&s_h^L~bf_oG-63P81 zJb0sU=R5cT?r{HG-)-y^u|J4igClST&VfI5Hsn%|3lo`%U@6xQxtUCu8v2|ma=#Ym z!!PBT+|qq58~BMF#U2-D`F1q)wwT@ZA-149xSH#%%2S3a=5dY zx6J4JMS1DgPF06_5_5&=7It4zm!_MsN~O8i>UqqRh{R>Hg|SR7yh|m=i9_3UBibl7 zX{KY{=$I$mNMS!X&73QJWzlZEQP<0~?N!>+U-LU#xH34aEWIr#D|>c7e8D(j77GIqOq}P*$N&H-)C4C0 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 66a2218101f8fd2d650c77acb3a915bf9c7bebf8..6622945f2b429f6607253f322adbe066ff2c2d87 100644 GIT binary patch literal 2050 zcma)-&2AJq5XWmW30Q-6VM#)E3132`Xo>2CMh?n#CR;Om6o z4bTb@NC=KxL9pN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