-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support packetflow based payload handling.
Add packet registration for registry packets.
- Loading branch information
1 parent
f4b4702
commit 3ccaaea
Showing
18 changed files
with
319 additions
and
46 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
patches/net/minecraft/network/protocol/PacketFlow.java.patch
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,10 @@ | ||
--- a/net/minecraft/network/protocol/PacketFlow.java | ||
+++ b/net/minecraft/network/protocol/PacketFlow.java | ||
@@ -1,6 +1,6 @@ | ||
package net.minecraft.network.protocol; | ||
|
||
-public enum PacketFlow { | ||
+public enum PacketFlow implements net.neoforged.neoforge.common.extensions.IPacketFlowExtension { | ||
SERVERBOUND, | ||
CLIENTBOUND; | ||
|
18 changes: 18 additions & 0 deletions
18
src/main/java/net/neoforged/neoforge/common/extensions/IPacketFlowExtension.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,18 @@ | ||
package net.neoforged.neoforge.common.extensions; | ||
|
||
import net.minecraft.network.protocol.PacketFlow; | ||
|
||
public interface IPacketFlowExtension { | ||
|
||
default PacketFlow self() { | ||
return (PacketFlow) this; | ||
} | ||
|
||
default boolean isClientbound() { | ||
return self() == PacketFlow.CLIENTBOUND; | ||
} | ||
|
||
default boolean isServerbound() { | ||
return self() == PacketFlow.SERVERBOUND; | ||
} | ||
} |
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
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
21 changes: 0 additions & 21 deletions
21
src/main/java/net/neoforged/neoforge/network/payload/FrozenRegistrySyncCompletedPayload.java
This file was deleted.
Oops, something went wrong.
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
52 changes: 52 additions & 0 deletions
52
...va/net/neoforged/neoforge/network/registration/registrar/ConfigurationPayloadHandler.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,52 @@ | ||
package net.neoforged.neoforge.network.registration.registrar; | ||
|
||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload; | ||
import net.neoforged.neoforge.network.handling.ConfigurationPayloadContext; | ||
import net.neoforged.neoforge.network.handling.IConfigurationPayloadHandler; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public final class ConfigurationPayloadHandler<T extends CustomPacketPayload> implements IConfigurationPayloadHandler<T> { | ||
|
||
@Nullable | ||
private final IConfigurationPayloadHandler<T> clientSide; | ||
@Nullable | ||
private final IConfigurationPayloadHandler<T> serverSide; | ||
|
||
private ConfigurationPayloadHandler(@Nullable IConfigurationPayloadHandler<T> clientSide, @Nullable IConfigurationPayloadHandler<T> serverSide) { | ||
this.clientSide = clientSide; | ||
this.serverSide = serverSide; | ||
} | ||
|
||
@Override | ||
public void handle(ConfigurationPayloadContext context, T payload) { | ||
if (context.flow().isClientbound()) { | ||
if (clientSide != null) { | ||
clientSide.handle(context, payload); | ||
} | ||
} else if (context.flow().isServerbound()) { | ||
if (serverSide != null) { | ||
serverSide.handle(context, payload); | ||
} | ||
} | ||
} | ||
|
||
public static class Builder<T extends CustomPacketPayload> { | ||
private @Nullable IConfigurationPayloadHandler<T> clientSide; | ||
private @Nullable IConfigurationPayloadHandler<T> serverSide; | ||
|
||
public Builder<T> client(@NotNull IConfigurationPayloadHandler<T> clientSide) { | ||
this.clientSide = clientSide; | ||
return this; | ||
} | ||
|
||
public Builder<T> server(@NotNull IConfigurationPayloadHandler<T> serverSide) { | ||
this.serverSide = serverSide; | ||
return this; | ||
} | ||
|
||
ConfigurationPayloadHandler<T> create() { | ||
return new ConfigurationPayloadHandler<T>(clientSide, serverSide); | ||
} | ||
} | ||
} |
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.