-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1.20.2] Support common registration packets. Add configuration task …
…API (#3244) * Config networking refactor :) * Add some unit tests for common packets. * write FabricPacket on network thread. Split ServerConfigurationConnectionEvents into two. * Fixes * Rename event * Add a testmod + ssome docs * Improve registry sync fixing deadlock in a number of cases. * Cleanup channel events. * Review feedback and fixes.
- Loading branch information
Showing
41 changed files
with
1,637 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...ient/java/net/fabricmc/fabric/api/client/networking/v1/C2SConfigurationChannelEvents.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.fabricmc.fabric.api.client.networking.v1; | ||
|
||
import java.util.List; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.network.ClientConfigurationNetworkHandler; | ||
import net.minecraft.util.Identifier; | ||
|
||
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.fabricmc.fabric.api.networking.v1.PacketSender; | ||
|
||
/** | ||
* Offers access to events related to the indication of a connected server's ability to receive packets in certain channels. | ||
*/ | ||
public final class C2SConfigurationChannelEvents { | ||
/** | ||
* An event for the client configuration network handler receiving an update indicating the connected server's ability to receive packets in certain channels. | ||
* This event may be invoked at any time after login and up to disconnection. | ||
*/ | ||
public static final Event<Register> REGISTER = EventFactory.createArrayBacked(Register.class, callbacks -> (handler, sender, client, channels) -> { | ||
for (Register callback : callbacks) { | ||
callback.onChannelRegister(handler, sender, client, channels); | ||
} | ||
}); | ||
|
||
/** | ||
* An event for the client configuration network handler receiving an update indicating the connected server's lack of ability to receive packets in certain channels. | ||
* This event may be invoked at any time after login and up to disconnection. | ||
*/ | ||
public static final Event<Unregister> UNREGISTER = EventFactory.createArrayBacked(Unregister.class, callbacks -> (handler, sender, client, channels) -> { | ||
for (Unregister callback : callbacks) { | ||
callback.onChannelUnregister(handler, sender, client, channels); | ||
} | ||
}); | ||
|
||
private C2SConfigurationChannelEvents() { | ||
} | ||
|
||
/** | ||
* @see C2SConfigurationChannelEvents#REGISTER | ||
*/ | ||
@FunctionalInterface | ||
public interface Register { | ||
void onChannelRegister(ClientConfigurationNetworkHandler handler, PacketSender sender, MinecraftClient client, List<Identifier> channels); | ||
} | ||
|
||
/** | ||
* @see C2SConfigurationChannelEvents#UNREGISTER | ||
*/ | ||
@FunctionalInterface | ||
public interface Unregister { | ||
void onChannelUnregister(ClientConfigurationNetworkHandler handler, PacketSender sender, MinecraftClient client, List<Identifier> channels); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.