-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to send older version packets to servers
- Loading branch information
Showing
6 changed files
with
102 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...ain/java/com/noxcrew/noxesium/network/clientbound/ClientboundServerInformationPacket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.noxcrew.noxesium.network.clientbound; | ||
|
||
import com.noxcrew.noxesium.NoxesiumMod; | ||
import com.noxcrew.noxesium.network.NoxesiumPackets; | ||
import com.noxcrew.noxesium.network.serverbound.ServerboundNoxesiumPacket; | ||
import net.fabricmc.fabric.api.networking.v1.PacketSender; | ||
import net.fabricmc.fabric.api.networking.v1.PacketType; | ||
import net.minecraft.client.player.LocalPlayer; | ||
import net.minecraft.network.FriendlyByteBuf; | ||
|
||
/** | ||
* Sent to the client when the server is first informed of it existing, this contains information | ||
* about what protocol version the server supports. | ||
*/ | ||
public class ClientboundServerInformationPacket extends ClientboundNoxesiumPacket { | ||
|
||
private final int maxProtocolVersion; | ||
|
||
public ClientboundServerInformationPacket(FriendlyByteBuf buf) { | ||
super(buf.readVarInt()); | ||
this.maxProtocolVersion = buf.readVarInt(); | ||
} | ||
|
||
@Override | ||
public void receive(LocalPlayer player, PacketSender responseSender) { | ||
// Whenever the server sends information about the supported protocol version we store | ||
// that and can use it to downgrade server-side packets based on the newest version | ||
// that can be sent. | ||
NoxesiumMod.setServerVersion(maxProtocolVersion); | ||
} | ||
|
||
@Override | ||
public PacketType<?> getType() { | ||
return NoxesiumPackets.CLIENT_SERVER_INFO; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters