Search in sources :

Example 11 with EntityTracker

use of com.viaversion.viaversion.api.data.entity.EntityTracker in project ViaVersion by ViaVersion.

the class BungeeServerHandler method onServerSwitch.

@EventHandler(priority = -120)
public void onServerSwitch(ServerSwitchEvent e) {
    // Update entity id
    UserConnection userConnection = Via.getManager().getConnectionManager().getConnectedClient(e.getPlayer().getUniqueId());
    if (userConnection == null)
        return;
    int playerId;
    try {
        playerId = Via.getManager().getProviders().get(EntityIdProvider.class).getEntityId(userConnection);
    } catch (Exception ex) {
        // Ignored
        return;
    }
    for (EntityTracker tracker : userConnection.getEntityTrackers()) {
        tracker.setClientEntityId(playerId);
    }
    // For ViaRewind
    for (StorableObject object : userConnection.getStoredObjects().values()) {
        if (object instanceof ClientEntityIdChangeListener) {
            ((ClientEntityIdChangeListener) object).setClientEntityId(playerId);
        }
    }
}
Also used : EntityTracker(com.viaversion.viaversion.api.data.entity.EntityTracker) ClientEntityIdChangeListener(com.viaversion.viaversion.api.data.entity.ClientEntityIdChangeListener) StorableObject(com.viaversion.viaversion.api.connection.StorableObject) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) InvocationTargetException(java.lang.reflect.InvocationTargetException) EventHandler(net.md_5.bungee.event.EventHandler)

Aggregations

EntityTracker (com.viaversion.viaversion.api.data.entity.EntityTracker)11 PacketRemapper (com.viaversion.viaversion.api.protocol.remapper.PacketRemapper)8 Type (com.viaversion.viaversion.api.type.Type)7 PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 EntityType (com.viaversion.viaversion.api.minecraft.entities.EntityType)3 ClientboundPackets1_17_1 (com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1)3 Chunk1_17Type (com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type)3 MathUtil (com.viaversion.viaversion.util.MathUtil)3 BitSet (java.util.BitSet)3 ViaBackwards (com.viaversion.viabackwards.ViaBackwards)2 ItemRewriter (com.viaversion.viabackwards.api.rewriters.ItemRewriter)2 WindowTracker (com.viaversion.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker)2 Via (com.viaversion.viaversion.api.Via)2 StoredEntityData (com.viaversion.viaversion.api.data.entity.StoredEntityData)2 Position (com.viaversion.viaversion.api.minecraft.Position)2 BlockEntity (com.viaversion.viaversion.api.minecraft.blockentity.BlockEntity)2 Chunk (com.viaversion.viaversion.api.minecraft.chunks.Chunk)2 ChunkSection (com.viaversion.viaversion.api.minecraft.chunks.ChunkSection)2