Package alexiil.mc.lib.net.impl
Class ActiveClientConnection
java.lang.Object
alexiil.mc.lib.net.ActiveConnection
alexiil.mc.lib.net.BufferedConnection
alexiil.mc.lib.net.impl.ActiveMinecraftConnection
alexiil.mc.lib.net.impl.ActiveClientConnection
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal net.minecraft.client.network.ClientPlayNetworkHandlerFields inherited from class alexiil.mc.lib.net.impl.ActiveMinecraftConnection
PACKET_IDFields inherited from class alexiil.mc.lib.net.BufferedConnection
ENABLE_QUEUE -
Constructor Summary
ConstructorsConstructorDescriptionActiveClientConnection(net.minecraft.client.network.ClientPlayNetworkHandler netHandler) -
Method Summary
Modifier and TypeMethodDescriptionlongGets the last received tick that the server has sent.net.minecraft.entity.player.PlayerEntitydoublelongvoidonIncrementMinecraftTickCounter(long milliseconds) Called byMinecraftClientMixin(ONLY) when minecraft increases it'sMinecraftClient.getTickDelta()value.protected voidsendPacket(net.minecraft.network.Packet<?> packet) protected net.minecraft.network.Packet<?>toCompactPacket(int receiverId, NetByteBuf data) protected net.minecraft.network.Packet<?>toNormalPacket(NetByteBuf data) toString()Methods inherited from class alexiil.mc.lib.net.impl.ActiveMinecraftConnection
sendRawData0, tickMethods inherited from class alexiil.mc.lib.net.BufferedConnection
hasPackets, maximumPacketSize, onReceiveRawData, sendPacket, sendTickPacket, setMaxBandwidthMethods inherited from class alexiil.mc.lib.net.ActiveConnection
allocBuffer, allocBuffer, isDebuggingConnection, postConstruct
-
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
- Specified by:
toNormalPacketin classActiveMinecraftConnection
-
toCompactPacket
- Specified by:
toCompactPacketin classActiveMinecraftConnection
-
sendPacket
protected void sendPacket(net.minecraft.network.Packet<?> packet) - Specified by:
sendPacketin classActiveMinecraftConnection
-
getNetSide
- Specified by:
getNetSidein classActiveMinecraftConnection- Returns:
- The "side" of this connection. This will be
EnumNetSide.CLIENTboth when writing client to server packets, and when reading packets sent from the server. (AndEnumNetSide.SERVERboth when writing server to client packets, and when reading client to server packets).
-
getPlayer
public net.minecraft.entity.player.PlayerEntity getPlayer()- Specified by:
getPlayerin classActiveMinecraftConnection- Returns:
- The Minecraft
PlayerEntityfor this connection. Throws an error if this is not aActiveMinecraftConnection.
-
toString
-
onIncrementMinecraftTickCounter
public void onIncrementMinecraftTickCounter(long milliseconds) Called byMinecraftClientMixin(ONLY) when minecraft increases it'sMinecraftClient.getTickDelta()value. Used internally to update the values returned bygetSmoothedServerTickValue()andgetSmoothedServerTickDelta().- Parameters:
milliseconds- The value ofUtil.getMeasuringTimeMs()that was passed intoRenderTickCounter.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 usegetSmoothedServerTickValue()andgetSmoothedServerTickDelta().- Returns:
- The last received tick from the server, or
Long.MIN_VALUEif 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 toMinecraftClient.getTickDelta().
-