3
0
Mirror von https://github.com/ViaVersion/ViaBackwards.git synchronisiert 2024-12-24 15:20:19 +01:00

Fix identifier handling in old protocols (#624)

Dieser Commit ist enthalten in:
RK_01 2023-10-23 23:55:13 +00:00 committet von GitHub
Ursprung 48907be813
Commit 232180ee61
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
6 geänderte Dateien mit 20 neuen und 37 gelöschten Zeilen

Datei anzeigen

@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
import com.viaversion.viaversion.util.Key;
public class ShoulderTracker extends StoredObject {
private int entityId;
@ -74,9 +75,7 @@ public class ShoulderTracker extends StoredObject {
}
private String getName(String current) {
if (current.startsWith("minecraft:")) {
current = current.substring(10);
}
current = Key.stripMinecraftNamespace(current);
String[] array = current.split("_");
StringBuilder builder = new StringBuilder();

Datei anzeigen

@ -18,6 +18,8 @@
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
import com.viaversion.viaversion.util.Key;
import java.util.HashMap;
import java.util.Map;
@ -42,15 +44,11 @@ public class EntityNameRewrites {
private static void reg(String past, String future) {
ENTITY_NAMES.put("minecraft:" + future, "minecraft:" + past);
ENTITY_NAMES.put(Key.namespaced(future), Key.namespaced(past));
}
public static String rewrite(String entName) {
String entityName = ENTITY_NAMES.get(entName);
if (entityName != null) {
return entityName;
}
entityName = ENTITY_NAMES.get("minecraft:" + entName);
String entityName = ENTITY_NAMES.get(Key.namespaced(entName));
if (entityName != null) {
return entityName;
} else

Datei anzeigen

@ -18,6 +18,8 @@
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
import com.viaversion.viaversion.util.Key;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
@ -37,9 +39,6 @@ public class NamedSoundMapping {
}
public static String getOldId(String sound1_13) {
if (sound1_13.startsWith("minecraft:")) {
sound1_13 = sound1_13.substring(10);
}
return SOUNDS.get(sound1_13);
return SOUNDS.get(Key.stripMinecraftNamespace(sound1_13));
}
}

Datei anzeigen

@ -41,14 +41,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_13;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
import com.viaversion.viaversion.libs.opennbt.conversion.ConverterRegistry;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.NumberTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ShortTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_12_1to1_12.ServerboundPackets1_12_1;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
@ -57,12 +50,8 @@ import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.BlockIdData;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
import com.viaversion.viaversion.util.Key;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.*;
public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter<ClientboundPackets1_13, ServerboundPackets1_12_1, Protocol1_12_2To1_13> {
@ -592,7 +581,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
for (Tag oldTag : blockTag) {
Object value = oldTag.getValue();
String[] newValues = value instanceof String ?
BlockIdData.fallbackReverseMapping.get(((String) value).replace("minecraft:", "")) : null;
BlockIdData.fallbackReverseMapping.get(Key.stripMinecraftNamespace((String) value)) : null;
if (newValues != null) {
for (String newValue : newValues) {
newCanPlaceOn.add(new StringTag(newValue));
@ -843,7 +832,7 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
ListTag newCanPlaceOn = new ListTag(StringTag.class);
for (Tag oldTag : blockTag) {
Object value = oldTag.getValue();
String oldId = value.toString().replace("minecraft:", "");
String oldId = Key.stripMinecraftNamespace(value.toString());
int key = Ints.tryParse(oldId);
String numberConverted = BlockIdData.numberIdToString.get(key);
if (numberConverted != null) {

Datei anzeigen

@ -25,12 +25,7 @@ import com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage.ChunkLi
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Environment;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLight;
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSectionLightImpl;
import com.viaversion.viaversion.api.minecraft.chunks.DataPalette;
import com.viaversion.viaversion.api.minecraft.chunks.PaletteType;
import com.viaversion.viaversion.api.minecraft.chunks.*;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
import com.viaversion.viaversion.api.minecraft.item.Item;
@ -54,6 +49,8 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPacke
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
import com.viaversion.viaversion.util.Key;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@ -261,7 +258,7 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
for (int i = 0; i < size; i++) {
String type = wrapper.read(Type.STRING);
String id = wrapper.read(Type.STRING); // Recipe Identifier
type = type.replace("minecraft:", "");
type = Key.stripMinecraftNamespace(type);
if (removedTypes.contains(type)) {
switch (type) {
case "blasting":

Datei anzeigen

@ -22,6 +22,7 @@ import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
import com.viaversion.viaversion.rewriter.RecipeRewriter;
import com.viaversion.viaversion.util.Key;
public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets1_14, ClientboundPackets1_14, ServerboundPackets1_14, ServerboundPackets1_14> {
@ -60,7 +61,7 @@ public class Protocol1_14_2To1_14_3 extends BackwardsProtocol<ClientboundPackets
int deleted = 0;
for (int i = 0; i < size; i++) {
String fullType = wrapper.read(Type.STRING);
String type = fullType.replace("minecraft:", "");
String type = Key.stripMinecraftNamespace(fullType);
String id = wrapper.read(Type.STRING); // id
if (type.equals("crafting_special_repairitem")) {