3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 16:12:42 +01:00

Fix long metatype reading, some internal type reading changes

Dieser Commit ist enthalten in:
Nassim Jahnke 2022-10-22 10:19:27 +02:00
Ursprung 7400784e4f
Commit 555e1a7722
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
4 geänderte Dateien mit 14 neuen und 28 gelöschten Zeilen

Datei anzeigen

@ -30,7 +30,7 @@ public final class MetaTypes1_19_3 extends AbstractMetaTypes {
public final MetaType byteType = add(0, Type.BYTE);
public final MetaType varIntType = add(1, Type.VAR_INT);
public final MetaType longType = add(2, Type.LONG);
public final MetaType longType = add(2, Type.VAR_LONG);
public final MetaType floatType = add(3, Type.FLOAT);
public final MetaType stringType = add(4, Type.STRING);
public final MetaType componentType = add(5, Type.COMPONENT);

Datei anzeigen

@ -119,14 +119,12 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19_3To1_19_1>
for (int j = 0; j < properties; j++) {
wrapper.passthrough(Type.STRING); // Name
wrapper.passthrough(Type.STRING); // Value
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING); // Signature
}
wrapper.passthrough(Type.OPTIONAL_STRING); // Signature
}
final int gamemode = wrapper.read(Type.VAR_INT);
final int ping = wrapper.read(Type.VAR_INT);
final JsonElement displayName = wrapper.read(Type.BOOLEAN) ? wrapper.read(Type.COMPONENT) : null;
final JsonElement displayName = wrapper.read(Type.OPTIONAL_COMPONENT);
final ProfileKey profileKey = wrapper.read(Type.OPTIONAL_PROFILE_KEY);
// Salvage signed chat
@ -140,8 +138,7 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19_3To1_19_1>
} else if (action == 1 || action == 2) { // Update gamemode/update latency
wrapper.passthrough(Type.VAR_INT);
} else if (action == 3) { // Update display name
final JsonElement displayName = wrapper.passthrough(Type.BOOLEAN) ? wrapper.read(Type.COMPONENT) : null;
wrapper.write(Type.OPTIONAL_COMPONENT, displayName);
wrapper.passthrough(Type.OPTIONAL_COMPONENT);
}
}
});

Datei anzeigen

@ -280,25 +280,19 @@ public final class EntityPackets extends EntityRewriter<Protocol1_19To1_18_2> {
for (int j = 0; j < properties; j++) {
wrapper.passthrough(Type.STRING); // Name
wrapper.passthrough(Type.STRING); // Value
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.STRING); // Signature
}
wrapper.passthrough(Type.OPTIONAL_STRING); // Signature
}
wrapper.passthrough(Type.VAR_INT); // Gamemode
wrapper.passthrough(Type.VAR_INT); // Ping
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT); // Display name
}
wrapper.passthrough(Type.OPTIONAL_COMPONENT); // Display name
// No public profile signature
wrapper.write(Type.OPTIONAL_PROFILE_KEY, null);
} else if (action == 1 || action == 2) { // Update gamemode/update latency
wrapper.passthrough(Type.VAR_INT);
} else if (action == 3) { // Update display name
if (wrapper.passthrough(Type.BOOLEAN)) {
wrapper.passthrough(Type.COMPONENT);
}
wrapper.passthrough(Type.OPTIONAL_COMPONENT);
}
}
});

Datei anzeigen

@ -241,25 +241,20 @@ public class PlayerPackets {
for (int j = 0; j < properties; j++) {
wrapper.passthrough(Type.STRING); // name
wrapper.passthrough(Type.STRING); // value
boolean isSigned = wrapper.passthrough(Type.BOOLEAN);
if (isSigned) {
wrapper.passthrough(Type.STRING); // signature
}
wrapper.passthrough(Type.OPTIONAL_STRING); // signature
}
wrapper.passthrough(Type.VAR_INT); // gamemode
wrapper.passthrough(Type.VAR_INT); // ping
boolean hasDisplayName = wrapper.passthrough(Type.BOOLEAN);
if (hasDisplayName) {
Protocol1_9To1_8.FIX_JSON.write(wrapper, wrapper.read(Type.STRING)); // display name
}
String displayName = wrapper.read(Type.OPTIONAL_STRING);
wrapper.write(Type.OPTIONAL_COMPONENT, displayName != null ?
Protocol1_9To1_8.FIX_JSON.transform(wrapper, displayName) : null);
} else if ((action == 1) || (action == 2)) { // update gamemode || update latency
wrapper.passthrough(Type.VAR_INT);
} else if (action == 3) { // update display name
boolean hasDisplayName = wrapper.passthrough(Type.BOOLEAN);
if (hasDisplayName) {
Protocol1_9To1_8.FIX_JSON.write(wrapper, wrapper.read(Type.STRING)); // display name
}
String displayName = wrapper.read(Type.OPTIONAL_STRING);
wrapper.write(Type.OPTIONAL_COMPONENT, displayName != null ?
Protocol1_9To1_8.FIX_JSON.transform(wrapper, displayName) : null);
} else if (action == 4) { // remove player
// no fields
}