Moved to new package for client to server packets. Renamed ClientInputPacket to InputPacket.

This commit is contained in:
2022-06-05 13:34:51 +01:00
parent 7f608a5374
commit c3f62f182e

View File

@ -1,26 +1,27 @@
package dev.micle.loginprotection.network; package dev.micle.loginprotection.network.client;
import dev.micle.loginprotection.data.ProtectedPlayer; import dev.micle.loginprotection.data.ProtectedPlayer;
import dev.micle.loginprotection.data.ProtectedPlayerManager; import dev.micle.loginprotection.data.ProtectedPlayerManager;
import dev.micle.loginprotection.network.NetworkManager;
import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraftforge.network.NetworkEvent; import net.minecraftforge.network.NetworkEvent;
import java.util.function.Supplier; import java.util.function.Supplier;
public class ClientInputPacket { public class InputPacket {
public ClientInputPacket() {} public InputPacket() {}
public static void encode(final ClientInputPacket packet, final FriendlyByteBuf buffer) { public static void encode(final InputPacket packet, final FriendlyByteBuf buffer) {
NetworkManager.writeVersionInfo(buffer, false); NetworkManager.writeVersionInfo(buffer, false);
} }
public static ClientInputPacket decode(final FriendlyByteBuf buffer) { public static InputPacket decode(final FriendlyByteBuf buffer) {
NetworkManager.checkVersion(buffer); NetworkManager.checkVersion(buffer);
return new ClientInputPacket(); return new InputPacket();
} }
public static void handle(final ClientInputPacket packet, final Supplier<NetworkEvent.Context> contextSupplier) { public static void handle(final InputPacket packet, final Supplier<NetworkEvent.Context> contextSupplier) {
final NetworkEvent.Context context = contextSupplier.get(); final NetworkEvent.Context context = contextSupplier.get();
context.enqueueWork(() -> { context.enqueueWork(() -> {
// Get sender // Get sender