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

Fix ancient client error caused by empty meta for < 1.11

Since modern versions don't immediately send metadata in spawn packets and 1.10 clients and lower have a slight oversight in the meta getting, every mob/player spawn spammed the client console with an error. Even though it is a harmless error, I figured people would like their client console not to get spammed anymore.
Dieser Commit ist enthalten in:
KennyTV 2021-05-29 14:56:22 +02:00
Ursprung 27b4933262
Commit f341fc132c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -134,9 +134,7 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
handler(getTrackerHandler(Type.UNSIGNED_BYTE, 0)); handler(getTrackerHandler(Type.UNSIGNED_BYTE, 0));
// Rewrite entity type / metadata // Rewrite entity type / metadata
handler(new PacketHandler() { handler(wrapper -> {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = wrapper.get(Type.VAR_INT, 0); int entityId = wrapper.get(Type.VAR_INT, 0);
EntityType type = tracker(wrapper.user()).entityType(entityId); EntityType type = tracker(wrapper.user()).entityType(entityId);
@ -150,6 +148,10 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
entityData.defaultMeta().createMeta(new WrappedMetadata(list)); entityData.defaultMeta().createMeta(new WrappedMetadata(list));
} }
} }
// Sub 1.11 clients will error if the list is empty
if (list.isEmpty()) {
list.add(new Metadata(0, MetaType1_9.Byte, (byte) 0));
} }
}); });
} }
@ -172,6 +174,13 @@ public class EntityPackets1_11 extends LegacyEntityRewriter<Protocol1_10To1_11>
map(Types1_9.METADATA_LIST); // 7 - Metadata list map(Types1_9.METADATA_LIST); // 7 - Metadata list
handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER)); handler(getTrackerAndMetaHandler(Types1_9.METADATA_LIST, Entity1_11Types.EntityType.PLAYER));
handler(wrapper -> {
// Sub 1.11 clients will cry if the list is empty
List<Metadata> metadata = wrapper.get(Types1_9.METADATA_LIST, 0);
if (metadata.isEmpty()) {
metadata.add(new Metadata(0, MetaType1_9.Byte, (byte) 0));
}
});
} }
}); });