diff --git a/src/main/java/vazkii/quark/base/network/QuarkNetwork.java b/src/main/java/vazkii/quark/base/network/QuarkNetwork.java index ed76e0d2fa..61a7fa76cd 100644 --- a/src/main/java/vazkii/quark/base/network/QuarkNetwork.java +++ b/src/main/java/vazkii/quark/base/network/QuarkNetwork.java @@ -1,25 +1,43 @@ package vazkii.quark.base.network; +import java.time.Instant; +import java.util.BitSet; + +import net.minecraft.client.Minecraft; import net.minecraft.network.chat.LastSeenMessages; import net.minecraft.network.chat.MessageSignature; import net.minecraft.network.protocol.Packet; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.network.NetworkDirection; import net.minecraftforge.network.simple.SimpleChannel; import vazkii.arl.network.IMessage; import vazkii.arl.network.MessageSerializer; import vazkii.arl.network.NetworkHandler; import vazkii.quark.base.Quark; -import vazkii.quark.base.network.message.*; +import vazkii.quark.base.network.message.ChangeHotbarMessage; +import vazkii.quark.base.network.message.DoEmoteMessage; +import vazkii.quark.base.network.message.DoubleDoorMessage; +import vazkii.quark.base.network.message.EditSignMessage; +import vazkii.quark.base.network.message.HarvestMessage; +import vazkii.quark.base.network.message.InventoryTransferMessage; +import vazkii.quark.base.network.message.RequestEmoteMessage; +import vazkii.quark.base.network.message.ScrollOnBundleMessage; +import vazkii.quark.base.network.message.SetLockProfileMessage; +import vazkii.quark.base.network.message.ShareItemMessage; +import vazkii.quark.base.network.message.SortInventoryMessage; +import vazkii.quark.base.network.message.UpdateTridentMessage; import vazkii.quark.base.network.message.experimental.PlaceVariantUpdateMessage; import vazkii.quark.base.network.message.oddities.HandleBackpackMessage; import vazkii.quark.base.network.message.oddities.MatrixEnchanterOperationMessage; import vazkii.quark.base.network.message.oddities.ScrollCrateMessage; -import vazkii.quark.base.network.message.structural.*; - -import java.time.Instant; -import java.util.BitSet; +import vazkii.quark.base.network.message.structural.C2SLoginFlag; +import vazkii.quark.base.network.message.structural.C2SUpdateFlag; +import vazkii.quark.base.network.message.structural.HandshakeMessage; +import vazkii.quark.base.network.message.structural.S2CLoginFlag; +import vazkii.quark.base.network.message.structural.S2CUpdateFlag; public final class QuarkNetwork { @@ -88,8 +106,9 @@ public static void sendToPlayer(IMessage msg, ServerPlayer player) { network.sendToPlayer(msg, player); } + @OnlyIn(Dist.CLIENT) public static void sendToServer(IMessage msg) { - if(network == null) + if(network == null || Minecraft.getInstance().getConnection() == null) return; network.sendToServer(msg);