Skip to content

Commit

Permalink
don't sent minecraft:register on quilt
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Feb 13, 2024
1 parent 48f2848 commit 459c9cc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
public class FabricProxy extends PlatformProxy {

private static final boolean HAS_FABRIC_API = FabricLoader.getInstance().isModLoaded("fabric-networking-api-v1");
private static final boolean HAS_QUILT_STD = FabricLoader.getInstance().isModLoaded("quilt_networking");

@Override
public boolean canSendVanillaRegisterPackets() {
return !HAS_QUILT_STD;
}

@Override
public Packet<?> createVanillaRegisterConfigS2CPacket(FriendlyByteBuf buf) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import lol.bai.badpackets.api.PacketSender;
import lol.bai.badpackets.impl.Constants;
import lol.bai.badpackets.impl.payload.UntypedPayload;
import lol.bai.badpackets.impl.platform.PlatformProxy;
import lol.bai.badpackets.impl.registry.ChannelRegistry;
import net.minecraft.network.Connection;
import net.minecraft.network.FriendlyByteBuf;
Expand Down Expand Up @@ -143,7 +144,7 @@ public void remove() {
}

private void sendVanillaChannelRegisterPacket(Set<ResourceLocation> channels) {
if (!channels.isEmpty()) {
if (PlatformProxy.INSTANCE.canSendVanillaRegisterPackets() && !channels.isEmpty()) {
FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
boolean first = true;
for (ResourceLocation channel : channels) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class PlatformProxy {

public static final PlatformProxy INSTANCE = ServiceLoader.load(PlatformProxy.class).findFirst().orElseGet(PlatformProxy::new);

public boolean canSendVanillaRegisterPackets() {
return true;
}

public Packet<?> createVanillaRegisterConfigC2SPacket(FriendlyByteBuf buf) {
return new ServerboundCustomPayloadPacket(new UntypedPayload(Constants.MC_REGISTER_CHANNEL, buf));
}
Expand Down

0 comments on commit 459c9cc

Please sign in to comment.