Class ActiveClientConnection


public class ActiveClientConnection extends ActiveMinecraftConnection
  • Field Details

    • netHandler

      public final net.minecraft.client.network.ClientPlayNetworkHandler netHandler
  • Constructor Details

    • ActiveClientConnection

      public ActiveClientConnection(net.minecraft.client.network.ClientPlayNetworkHandler netHandler)
  • Method Details

    • toNormalPacket

      protected net.minecraft.network.Packet<?> toNormalPacket(NetByteBuf data)
      Specified by:
      toNormalPacket in class ActiveMinecraftConnection
    • toCompactPacket

      protected net.minecraft.network.Packet<?> toCompactPacket(int receiverId, NetByteBuf data)
      Specified by:
      toCompactPacket in class ActiveMinecraftConnection
    • sendPacket

      protected void sendPacket(net.minecraft.network.Packet<?> packet)
      Specified by:
      sendPacket in class ActiveMinecraftConnection
    • getNetSide

      public EnumNetSide getNetSide()
      Specified by:
      getNetSide in class ActiveMinecraftConnection
      Returns:
      The "side" of this connection. This will be EnumNetSide.CLIENT both when writing client to server packets, and when reading packets sent from the server. (And EnumNetSide.SERVER both when writing server to client packets, and when reading client to server packets).
    • getPlayer

      public net.minecraft.entity.player.PlayerEntity getPlayer()
      Specified by:
      getPlayer in class ActiveMinecraftConnection
      Returns:
      The Minecraft PlayerEntity for this connection. Throws an error if this is not a ActiveMinecraftConnection.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • onIncrementMinecraftTickCounter

      public void onIncrementMinecraftTickCounter(long milliseconds)
      Called by MinecraftClientMixin (ONLY) when minecraft increases it's MinecraftClient.getTickDelta() value. Used internally to update the values returned by getSmoothedServerTickValue() and getSmoothedServerTickDelta().
      Parameters:
      milliseconds - The value of Util.getMeasuringTimeMs() that was passed into RenderTickCounter.beginRenderTick(long).
    • getAbsoluteServerTick

      public long getAbsoluteServerTick()
      Gets the last received tick that the server has sent. It is never normally a good idea to use this method directly because this will not return useful values if the network connection isn't perfect. Instead use getSmoothedServerTickValue() and getSmoothedServerTickDelta().
      Returns:
      The last received tick from the server, or Long.MIN_VALUE if the server hasn't sent tick data yet.
    • getSmoothedServerTickValue

      public long getSmoothedServerTickValue()
      Returns:
      The smoothed tick value for the server. This will always lag behind getAbsoluteServerTick(), but a best-effort is made to try and keep the rate that this changes roughly equal to the server tick speed, rather than being solely based on the network connection.
    • getSmoothedServerTickDelta

      public double getSmoothedServerTickDelta()
      Returns:
      A value between 0 and 1 (to be used along side getSmoothedServerTickValue()) which is analogous to MinecraftClient.getTickDelta().