Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-20 06:50:10 +01:00
Update mapping files
Dieser Commit ist enthalten in:
Ursprung
3cddb712c8
Commit
71361be66c
@ -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);
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@ -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<String> 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<String, Integer> 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
|
||||
|
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren