Skip to content

Commit

Permalink
Fix client networking canSend checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Su5eD committed Aug 9, 2024
1 parent c85e22a commit 28b204f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.Set;

import net.minecraft.network.ConnectionProtocol;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
Expand Down Expand Up @@ -157,7 +158,11 @@ public static Set<ResourceLocation> getSendable() throws IllegalStateException {
* False if the client is not in game.
*/
public static boolean canSend(ResourceLocation channelName) throws IllegalArgumentException {
return NeoClientConfigurationNetworking.canSend(channelName);
if (Minecraft.getInstance().getConnection() != null && Minecraft.getInstance().getConnection().protocol() == ConnectionProtocol.CONFIGURATION) {
return NeoClientConfigurationNetworking.canSend(channelName);
}

return false;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Objects;
import java.util.Set;

import net.minecraft.network.ConnectionProtocol;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
Expand Down Expand Up @@ -161,7 +162,7 @@ public static Set<ResourceLocation> getSendable() throws IllegalStateException {
*/
public static boolean canSend(ResourceLocation channelName) throws IllegalArgumentException {
// You cant send without a client player, so this is fine
if (Minecraft.getInstance().getConnection() != null) {
if (Minecraft.getInstance().getConnection() != null && Minecraft.getInstance().getConnection().protocol() == ConnectionProtocol.PLAY) {
return NeoClientPlayNetworking.canSend(channelName);
}

Expand Down
2 changes: 1 addition & 1 deletion ffapi.gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
loom.platform=neoforge
fabric.loom.dontRemap=true

implementationVersion=2.0.9
implementationVersion=2.0.10

versionMc=1.21
versionForge=21.0.160
Expand Down

0 comments on commit 28b204f

Please sign in to comment.