3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 00:22:51 +01:00

Fix 1.14->1.15 meta ordering issue

Closes #2467
Dieser Commit ist enthalten in:
KennyTV 2021-05-10 13:27:12 +02:00
Ursprung efeaef3e4e
Commit 2df57bc37c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
2 geänderte Dateien mit 23 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -228,7 +228,7 @@ public interface PacketWrapper {
/**
* Create a new packet for the target of this packet.
*
* @param packetType packet type of the new packedt
* @param packetType packet type of the new packet
* @return The newly created packet wrapper
*/
PacketWrapper create(PacketType packetType);

Datei anzeigen

@ -24,9 +24,11 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.ClientboundPackets1_15;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.Protocol1_15To1_14_4;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.metadata.MetadataRewriter1_15To1_14_4;
import com.viaversion.viaversion.protocols.protocol1_15to1_14_4.storage.EntityTracker1_15;
import com.viaversion.viaversion.rewriter.MetadataRewriter;
import java.util.List;
@ -54,15 +56,7 @@ public class EntityPackets {
map(Type.SHORT); // 11 - Velocity Z
handler(metadataRewriter.getTracker());
handler(wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0);
List<Metadata> metadata = wrapper.read(Types1_14.METADATA_LIST);
metadataRewriter.handleMetadata(entityId, metadata, wrapper.user());
PacketWrapper metadataUpdate = wrapper.create(0x44);
metadataUpdate.write(Type.VAR_INT, entityId);
metadataUpdate.write(Types1_14.METADATA_LIST, metadata);
metadataUpdate.send(Protocol1_15To1_14_4.class);
});
handler(wrapper -> sendMetadataPacket(wrapper, wrapper.get(Type.VAR_INT, 0), metadataRewriter));
}
});
@ -79,15 +73,9 @@ public class EntityPackets {
handler(wrapper -> {
int entityId = wrapper.get(Type.VAR_INT, 0);
Entity1_15Types entityType = Entity1_15Types.PLAYER;
wrapper.user().get(EntityTracker1_15.class).addEntity(entityId, entityType);
wrapper.user().get(EntityTracker1_15.class).addEntity(entityId, Entity1_15Types.PLAYER);
List<Metadata> metadata = wrapper.read(Types1_14.METADATA_LIST);
metadataRewriter.handleMetadata(entityId, metadata, wrapper.user());
PacketWrapper metadataUpdate = wrapper.create(0x44);
metadataUpdate.write(Type.VAR_INT, entityId);
metadataUpdate.write(Types1_14.METADATA_LIST, metadata);
metadataUpdate.send(Protocol1_15To1_14_4.class);
sendMetadataPacket(wrapper, entityId, metadataRewriter);
});
}
});
@ -96,6 +84,23 @@ public class EntityPackets {
metadataRewriter.registerEntityDestroy(ClientboundPackets1_14.DESTROY_ENTITIES);
}
private static void sendMetadataPacket(PacketWrapper wrapper, int entityId, MetadataRewriter rewriter) throws Exception {
// Meta is no longer included in the spawn packets, but sent separately
List<Metadata> metadata = wrapper.read(Types1_14.METADATA_LIST);
// Send the spawn packet manually
wrapper.send(Protocol1_15To1_14_4.class, true, true);
wrapper.cancel();
// Handle meta
rewriter.handleMetadata(entityId, metadata, wrapper.user());
PacketWrapper metadataPacket = PacketWrapper.create(ClientboundPackets1_15.ENTITY_METADATA, wrapper.user());
metadataPacket.write(Type.VAR_INT, entityId);
metadataPacket.write(Types1_14.METADATA_LIST, metadata);
metadataPacket.send(Protocol1_15To1_14_4.class, true, true);
}
public static int getNewEntityId(int oldId) {
return oldId >= 4 ? oldId + 1 : oldId; // 4 = bee
}