mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-28 02:26:01 -05:00
Backport networking v1 fixes from 1.16 to 1.15 (#1235)
* Fix registry sync being applied when its not supposed to be. Fixes #1217 Fixes #1216 * Check channels the server can receive, not channels the client can (#1224) * Fix v0 deprecation javadoc error (#1209) Co-authored-by: modmuss50 <modmuss50@gmail.com>
This commit is contained in:
parent
463fa90e22
commit
7f3984e3f4
4 changed files with 6 additions and 4 deletions
|
@ -24,6 +24,7 @@ import net.minecraft.util.Identifier;
|
|||
import net.fabricmc.fabric.api.client.networking.v1.C2SPlayChannelEvents;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.fabricmc.fabric.api.networking.v1.S2CPlayChannelEvents;
|
||||
|
||||
/**
|
||||
* Event for listening to packet type registration and unregistration notifications
|
||||
|
@ -32,7 +33,7 @@ import net.fabricmc.fabric.api.event.EventFactory;
|
|||
* <p>Registrations received will be for <em>server -> client</em> packets
|
||||
* that the sending client can understand.
|
||||
*
|
||||
* @deprecated Please migrate to {@link C2SPlayChannelEvents}.
|
||||
* @deprecated Please migrate to {@link S2CPlayChannelEvents} since this was incorrectly named.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface C2SPacketTypeCallback {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Collection;
|
|||
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import net.fabricmc.fabric.api.client.networking.v1.C2SPlayChannelEvents;
|
||||
import net.fabricmc.fabric.api.event.Event;
|
||||
import net.fabricmc.fabric.api.event.EventFactory;
|
||||
import net.fabricmc.fabric.api.networking.v1.S2CPlayChannelEvents;
|
||||
|
@ -31,7 +32,7 @@ import net.fabricmc.fabric.api.networking.v1.S2CPlayChannelEvents;
|
|||
* <p>Registrations received will be for <em>client -> server</em> packets
|
||||
* that the sending server can understand.
|
||||
*
|
||||
* @deprecated Please migrate to {@link S2CPlayChannelEvents}.
|
||||
* @deprecated Please migrate to {@link C2SPlayChannelEvents} since this was incorrectly named.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface S2CPacketTypeCallback {
|
||||
|
|
|
@ -38,7 +38,7 @@ import net.fabricmc.fabric.api.network.PacketRegistry;
|
|||
public class ClientSidePacketRegistryImpl implements ClientSidePacketRegistry, PacketRegistry {
|
||||
@Override
|
||||
public boolean canServerReceive(Identifier id) {
|
||||
return ClientPlayNetworking.getReceived().contains(id);
|
||||
return ClientPlayNetworking.getSendable().contains(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,7 +31,7 @@ public class FabricRegistryClientInit implements ClientModInitializer {
|
|||
public void onInitializeClient() {
|
||||
ClientPlayNetworking.registerGlobalReceiver(RegistrySyncManager.ID, (client, handler, buf, responseSender) -> {
|
||||
// if not hosting server, apply packet
|
||||
RegistrySyncManager.receivePacket(client, buf, RegistrySyncManager.DEBUG || client.isInSingleplayer(), (e) -> {
|
||||
RegistrySyncManager.receivePacket(client, buf, RegistrySyncManager.DEBUG || !client.isInSingleplayer(), (e) -> {
|
||||
LOGGER.error("Registry remapping failed!", e);
|
||||
|
||||
client.execute(() -> {
|
||||
|
|
Loading…
Reference in a new issue