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
Modifier and TypeFieldDescriptionfinal net.minecraft.client.network.ClientPlayNetworkHandler
Fields inherited from class alexiil.mc.lib.net.impl.ActiveMinecraftConnection
ctx, PACKET_ID
Fields inherited from class alexiil.mc.lib.net.BufferedConnection
ENABLE_QUEUE
-
Constructor Summary
ConstructorDescriptionActiveClientConnection
(net.minecraft.client.network.ClientPlayNetworkHandler netHandler) -
Method Summary
Modifier and TypeMethodDescriptionlong
Gets the last received tick that the server has sent.net.minecraft.entity.player.PlayerEntity
double
long
void
onIncrementMinecraftTickCounter
(long milliseconds) Called byMinecraftClientMixin
(ONLY) when minecraft increases it'sMinecraftClient.getTickDelta()
value.protected void
sendPacket
(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
getMinecraftContext, sendRawData0, tick
Methods inherited from class alexiil.mc.lib.net.BufferedConnection
hasPackets, maximumPacketSize, onReceiveRawData, sendPacket, sendTickPacket, setMaxBandwidth
Methods inherited from class alexiil.mc.lib.net.ActiveConnection
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:
toNormalPacket
in classActiveMinecraftConnection
-
toCompactPacket
- Specified by:
toCompactPacket
in classActiveMinecraftConnection
-
sendPacket
protected void sendPacket(net.minecraft.network.Packet<?> packet) - Specified by:
sendPacket
in classActiveMinecraftConnection
-
getNetSide
- Specified by:
getNetSide
in classActiveMinecraftConnection
- 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. (AndEnumNetSide.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 classActiveMinecraftConnection
- Returns:
- The Minecraft
PlayerEntity
for 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_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 toMinecraftClient.getTickDelta()
.
-