Search in sources :

Example 1 with PlayerMovementTracker

use of com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.PlayerMovementTracker in project DirtMultiversion by DirtPowered.

the class ViaPlugin method tick.

@Override
public void tick() {
    for (UserData userData : api.getAllConnections()) {
        ProtocolStorage s = userData.getProtocolStorage();
        if (!s.hasObject(PlayerMovementTracker.class))
            return;
        PlayerMovementTracker movementTracker = s.get(PlayerMovementTracker.class);
        if ((System.currentTimeMillis() - movementTracker.getLastLocationUpdate()) >= 50) {
            if (userData.getUniqueId() == null)
                return;
            UserConnection userConnection = connectionManager.getConnectedClient(userData.getUniqueId());
            if (userConnection == null)
                return;
            ProtocolInfo protocolInfo = userConnection.getProtocolInfo();
            if (protocolInfo == null)
                return;
            if (protocolInfo.getPipeline().contains(Protocol1_9To1_8.class) && protocolInfo.getState() == State.PLAY) {
                PacketWrapper wrapper = new PacketWrapperImpl(0x03, null, userConnection);
                wrapper.write(Type.BOOLEAN, true);
                try {
                    wrapper.sendToServer(Protocol1_9To1_8.class, true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : ProtocolStorage(com.github.dirtpowered.dirtmv.data.user.ProtocolStorage) PacketWrapper(com.viaversion.viaversion.api.protocol.packet.PacketWrapper) UserData(com.github.dirtpowered.dirtmv.data.user.UserData) PacketWrapperImpl(com.viaversion.viaversion.protocol.packet.PacketWrapperImpl) ProtocolInfo(com.viaversion.viaversion.api.connection.ProtocolInfo) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) PlayerMovementTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.PlayerMovementTracker) Protocol1_9To1_8(com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8)

Example 2 with PlayerMovementTracker

use of com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.PlayerMovementTracker in project DirtMultiversion by DirtPowered.

the class ProtocolRelease47To5 method onConnect.

@Override
public void onConnect(ServerSession session) {
    ProtocolStorage storage = session.getStorage();
    storage.set(OnGroundTracker.class, new OnGroundTracker());
    storage.set(WindowTypeTracker.class, new WindowTypeTracker());
    storage.set(QuickBarTracker.class, new QuickBarTracker());
    // additional block storage (for nether portal rotation fix)
    storage.set(PortalFrameCache.class, new PortalFrameCache());
    if (session.getMain().getConfiguration().enableViaVersion()) {
        // it's not needed for 1.8->1.7, but ViaVersion will need that to fix issues
        // with eating, entering portals, effects (potions)
        storage.set(PlayerMovementTracker.class, new PlayerMovementTracker());
    }
    // check if 1.6 entity tracker exists - if not, create one
    if (!storage.hasObject(EntityTracker.class)) {
        storage.set(V1_7EntityTracker.class, new V1_7EntityTracker());
    }
    // fixes block hardness inconsistencies
    if (session.getMain().getConfiguration().getServerVersion() == MinecraftVersion.B1_7_3) {
        storage.set(BlockMiningTimeFixer.class, new BlockMiningTimeFixer(session));
    }
}
Also used : WindowTypeTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.inventory.WindowTypeTracker) ProtocolStorage(com.github.dirtpowered.dirtmv.data.user.ProtocolStorage) PortalFrameCache(com.github.dirtpowered.dirtmv.network.versions.Release47To5.chunk.PortalFrameCache) V1_7EntityTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.V1_7EntityTracker) EntityTracker(com.github.dirtpowered.dirtmv.network.versions.Release73To61.entity.EntityTracker) OnGroundTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.OnGroundTracker) BlockMiningTimeFixer(com.github.dirtpowered.dirtmv.network.versions.Release47To5.other.BlockMiningTimeFixer) V1_7EntityTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.V1_7EntityTracker) QuickBarTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.inventory.QuickBarTracker) PlayerMovementTracker(com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.PlayerMovementTracker)

Aggregations

ProtocolStorage (com.github.dirtpowered.dirtmv.data.user.ProtocolStorage)2 PlayerMovementTracker (com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.PlayerMovementTracker)2 UserData (com.github.dirtpowered.dirtmv.data.user.UserData)1 PortalFrameCache (com.github.dirtpowered.dirtmv.network.versions.Release47To5.chunk.PortalFrameCache)1 OnGroundTracker (com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.OnGroundTracker)1 V1_7EntityTracker (com.github.dirtpowered.dirtmv.network.versions.Release47To5.entity.V1_7EntityTracker)1 QuickBarTracker (com.github.dirtpowered.dirtmv.network.versions.Release47To5.inventory.QuickBarTracker)1 WindowTypeTracker (com.github.dirtpowered.dirtmv.network.versions.Release47To5.inventory.WindowTypeTracker)1 BlockMiningTimeFixer (com.github.dirtpowered.dirtmv.network.versions.Release47To5.other.BlockMiningTimeFixer)1 EntityTracker (com.github.dirtpowered.dirtmv.network.versions.Release73To61.entity.EntityTracker)1 ProtocolInfo (com.viaversion.viaversion.api.connection.ProtocolInfo)1 UserConnection (com.viaversion.viaversion.api.connection.UserConnection)1 PacketWrapper (com.viaversion.viaversion.api.protocol.packet.PacketWrapper)1 PacketWrapperImpl (com.viaversion.viaversion.protocol.packet.PacketWrapperImpl)1 Protocol1_9To1_8 (com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8)1