mirror of
https://github.com/FabricMC/fabric.git
synced 2025-02-17 04:01:46 -05:00
Networking V1: Fool me once shame on me. Fool me twice shame on me. (#1207)
This commit is contained in:
parent
33708c72c9
commit
b08303c750
5 changed files with 12 additions and 0 deletions
|
@ -62,6 +62,8 @@ public abstract class AbstractChanneledNetworkAddon<H> extends AbstractNetworkAd
|
|||
this.sendableChannelsView = Collections.unmodifiableSet(sendableChannels);
|
||||
}
|
||||
|
||||
public abstract void lateInit();
|
||||
|
||||
protected void registerPendingChannels(ChannelInfoHolder holder) {
|
||||
final Collection<Identifier> pending = holder.getPendingChannelsNames();
|
||||
|
||||
|
|
|
@ -52,7 +52,10 @@ public final class ClientPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
|||
|
||||
// Register global receivers and attach to session
|
||||
this.receiver.startSession(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lateInit() {
|
||||
for (Map.Entry<Identifier, ClientPlayNetworking.PlayChannelHandler> entry : this.receiver.getHandlers().entrySet()) {
|
||||
this.registerChannel(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
|
|
@ -50,7 +50,10 @@ public final class ServerPlayNetworkAddon extends AbstractChanneledNetworkAddon<
|
|||
|
||||
// Register global receivers and attach to session
|
||||
this.receiver.startSession(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lateInit() {
|
||||
for (Map.Entry<Identifier, ServerPlayNetworking.PlayChannelHandler> entry : this.receiver.getHandlers().entrySet()) {
|
||||
this.registerChannel(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ abstract class ServerPlayNetworkHandlerMixin implements ServerPlayNetworkHandler
|
|||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void initAddon(CallbackInfo ci) {
|
||||
this.addon = new ServerPlayNetworkAddon((ServerPlayNetworkHandler) (Object) this, this.server);
|
||||
// A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field
|
||||
this.addon.lateInit();
|
||||
}
|
||||
|
||||
@Inject(method = "onCustomPayload", at = @At("HEAD"), cancellable = true)
|
||||
|
|
|
@ -47,6 +47,8 @@ abstract class ClientPlayNetworkHandlerMixin implements ClientPlayNetworkHandler
|
|||
@Inject(method = "<init>", at = @At("RETURN"))
|
||||
private void initAddon(CallbackInfo ci) {
|
||||
this.addon = new ClientPlayNetworkAddon((ClientPlayNetworkHandler) (Object) this, this.client);
|
||||
// A bit of a hack but it allows the field above to be set in case someone registers handlers during INIT event which refers to said field
|
||||
this.addon.lateInit();
|
||||
}
|
||||
|
||||
@Inject(method = "onGameJoin", at = @At("RETURN"))
|
||||
|
|
Loading…
Reference in a new issue