mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-22 16:57:40 +01:00
Fix identifier handling in old protocols (#624)
This commit is contained in:
parent
48907be813
commit
232180ee61
@ -26,6 +26,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
|||||||
import com.viaversion.viaversion.api.type.Type;
|
import com.viaversion.viaversion.api.type.Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.ClientboundPackets1_12;
|
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.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||||
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
public class ShoulderTracker extends StoredObject {
|
public class ShoulderTracker extends StoredObject {
|
||||||
private int entityId;
|
private int entityId;
|
||||||
@ -74,9 +75,7 @@ public class ShoulderTracker extends StoredObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String getName(String current) {
|
private String getName(String current) {
|
||||||
if (current.startsWith("minecraft:")) {
|
current = Key.stripMinecraftNamespace(current);
|
||||||
current = current.substring(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] array = current.split("_");
|
String[] array = current.split("_");
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -42,15 +44,11 @@ public class EntityNameRewrites {
|
|||||||
|
|
||||||
|
|
||||||
private static void reg(String past, String future) {
|
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) {
|
public static String rewrite(String entName) {
|
||||||
String entityName = ENTITY_NAMES.get(entName);
|
String entityName = ENTITY_NAMES.get(Key.namespaced(entName));
|
||||||
if (entityName != null) {
|
|
||||||
return entityName;
|
|
||||||
}
|
|
||||||
entityName = ENTITY_NAMES.get("minecraft:" + entName);
|
|
||||||
if (entityName != null) {
|
if (entityName != null) {
|
||||||
return entityName;
|
return entityName;
|
||||||
} else
|
} else
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
package com.viaversion.viabackwards.protocol.protocol1_12_2to1_13.data;
|
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.protocols.protocol1_13to1_12_2.data.NamedSoundRewriter;
|
||||||
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -37,9 +39,6 @@ public class NamedSoundMapping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getOldId(String sound1_13) {
|
public static String getOldId(String sound1_13) {
|
||||||
if (sound1_13.startsWith("minecraft:")) {
|
return SOUNDS.get(Key.stripMinecraftNamespace(sound1_13));
|
||||||
sound1_13 = sound1_13.substring(10);
|
|
||||||
}
|
|
||||||
return SOUNDS.get(sound1_13);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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_13;
|
||||||
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_3;
|
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.conversion.ConverterRegistry;
|
||||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ByteTag;
|
import com.viaversion.viaversion.libs.opennbt.tag.builtin.*;
|
||||||
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.protocols.protocol1_12_1to1_12.ClientboundPackets1_12_1;
|
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_12_1to1_12.ServerboundPackets1_12_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter;
|
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.BlockIdData;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.data.SpawnEggRewriter;
|
||||||
import com.viaversion.viaversion.util.Key;
|
import com.viaversion.viaversion.util.Key;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewriters.ItemRewriter<ClientboundPackets1_13, ServerboundPackets1_12_1, Protocol1_12_2To1_13> {
|
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) {
|
for (Tag oldTag : blockTag) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
String[] newValues = value instanceof String ?
|
String[] newValues = value instanceof String ?
|
||||||
BlockIdData.fallbackReverseMapping.get(((String) value).replace("minecraft:", "")) : null;
|
BlockIdData.fallbackReverseMapping.get(Key.stripMinecraftNamespace((String) value)) : null;
|
||||||
if (newValues != null) {
|
if (newValues != null) {
|
||||||
for (String newValue : newValues) {
|
for (String newValue : newValues) {
|
||||||
newCanPlaceOn.add(new StringTag(newValue));
|
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);
|
ListTag newCanPlaceOn = new ListTag(StringTag.class);
|
||||||
for (Tag oldTag : blockTag) {
|
for (Tag oldTag : blockTag) {
|
||||||
Object value = oldTag.getValue();
|
Object value = oldTag.getValue();
|
||||||
String oldId = value.toString().replace("minecraft:", "");
|
String oldId = Key.stripMinecraftNamespace(value.toString());
|
||||||
int key = Ints.tryParse(oldId);
|
int key = Ints.tryParse(oldId);
|
||||||
String numberConverted = BlockIdData.numberIdToString.get(key);
|
String numberConverted = BlockIdData.numberIdToString.get(key);
|
||||||
if (numberConverted != null) {
|
if (numberConverted != null) {
|
||||||
|
@ -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.Via;
|
||||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||||
import com.viaversion.viaversion.api.minecraft.Environment;
|
import com.viaversion.viaversion.api.minecraft.Environment;
|
||||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
import com.viaversion.viaversion.api.minecraft.chunks.*;
|
||||||
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.entities.EntityType;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_14;
|
||||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
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.protocols.protocol1_14to1_13_2.Protocol1_14To1_13_2;
|
||||||
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
import com.viaversion.viaversion.rewriter.BlockRewriter;
|
||||||
import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
||||||
|
import com.viaversion.viaversion.util.Key;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
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++) {
|
for (int i = 0; i < size; i++) {
|
||||||
String type = wrapper.read(Type.STRING);
|
String type = wrapper.read(Type.STRING);
|
||||||
String id = wrapper.read(Type.STRING); // Recipe Identifier
|
String id = wrapper.read(Type.STRING); // Recipe Identifier
|
||||||
type = type.replace("minecraft:", "");
|
type = Key.stripMinecraftNamespace(type);
|
||||||
if (removedTypes.contains(type)) {
|
if (removedTypes.contains(type)) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "blasting":
|
case "blasting":
|
||||||
|
@ -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.ClientboundPackets1_14;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ServerboundPackets1_14;
|
||||||
import com.viaversion.viaversion.rewriter.RecipeRewriter;
|
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> {
|
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;
|
int deleted = 0;
|
||||||
for (int i = 0; i < size; i++) {
|
for (int i = 0; i < size; i++) {
|
||||||
String fullType = wrapper.read(Type.STRING);
|
String fullType = wrapper.read(Type.STRING);
|
||||||
String type = fullType.replace("minecraft:", "");
|
String type = Key.stripMinecraftNamespace(fullType);
|
||||||
String id = wrapper.read(Type.STRING); // id
|
String id = wrapper.read(Type.STRING); // id
|
||||||
|
|
||||||
if (type.equals("crafting_special_repairitem")) {
|
if (type.equals("crafting_special_repairitem")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user