Skip to content

Commit

Permalink
Always register the configuration channel.
Browse files Browse the repository at this point in the history
  • Loading branch information
covers1624 committed Sep 22, 2024
1 parent 797eae9 commit 2df47fe
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions src/main/java/codechicken/lib/packet/PacketCustomChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,41 +85,39 @@ private void onRegisterPayloadHandlerEvent(RegisterPayloadHandlerEvent event) {
if (optional) registrar = registrar.optional();
if (version != null) registrar = registrar.versioned(version);

if (client != null || server != null) {
registrar.play(
channel,
this::read,
handlers -> {
handlers.client((payload, context) -> {
if (client != null) {
enqueue(context.workHandler(), payload, () -> {
client.handlePacket(new PacketCustom(payload), Minecraft.getInstance());
});
}
});
handlers.server((payload, context) -> {
if (server != null) {
enqueue(context.workHandler(), payload, () -> {
server.handlePacket(new PacketCustom(payload), (ServerPlayer) context.player().orElseThrow());
});
}
});
}
);
}
if (clientConfiguration != null || serverConfiguration != null) {
registrar.configuration(
channel,
this::read,
handlers -> {
handlers.client((payload, context) -> {
registrar.play(
channel,
this::read,
handlers -> {
handlers.client((payload, context) -> {
if (client != null) {
enqueue(context.workHandler(), payload, () -> {
client.handlePacket(new PacketCustom(payload), Minecraft.getInstance());
});
}
});
handlers.server((payload, context) -> {
if (server != null) {
enqueue(context.workHandler(), payload, () -> {
server.handlePacket(new PacketCustom(payload), (ServerPlayer) context.player().orElseThrow());
});
}
});
}
);
registrar.configuration(
channel,
this::read,
handlers -> {
handlers.client((payload, context) -> {
if (clientConfiguration != null) {
enqueue(context.workHandler(), payload, () -> {
clientConfiguration.handlePacket(new PacketCustom(payload), Minecraft.getInstance());
});
});
}
);
}
}
});
}
);
}

private PacketCustom.Pkt read(FriendlyByteBuf buf) {
Expand Down

0 comments on commit 2df47fe

Please sign in to comment.