Skip to content

Commit

Permalink
Another attempt at fixing the config sync crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Oct 7, 2023
1 parent 2bb7e38 commit e1d9415
Showing 1 changed file with 25 additions and 6 deletions.
31 changes: 25 additions & 6 deletions src/main/java/vazkii/quark/base/network/QuarkNetwork.java
Original file line number Diff line number Diff line change
@@ -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 {

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit e1d9415

Please sign in to comment.