Package net.minecraftforge.fml.network
Class NetworkHooks
- java.lang.Object
-
- net.minecraftforge.fml.network.NetworkHooks
-
public class NetworkHooks extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static org.apache.logging.log4j.Logger
LOGGER
-
Constructor Summary
Constructors Constructor Description NetworkHooks()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static FMLConnectionData
getConnectionData(NetworkManager mgr)
private static ConnectionType
getConnectionType(io.netty.channel.Channel channel)
static ConnectionType
getConnectionType(io.netty.channel.ChannelHandlerContext context)
static ConnectionType
getConnectionType(java.util.function.Supplier<NetworkManager> connection)
static IPacket<?>
getEntitySpawningPacket(Entity entity)
static java.lang.String
getFMLVersion(java.lang.String ip)
static void
handleClientLoginSuccess(NetworkManager manager)
static boolean
isVanillaConnection(NetworkManager manager)
static boolean
onCustomPayload(ICustomPacket<?> packet, NetworkManager manager)
static void
openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier)
Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORY
for how to provide a function to consume these GUI requests on the client.static void
openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, java.util.function.Consumer<PacketBuffer> extraDataWriter)
Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORY
for how to provide a function to consume these GUI requests on the client.static void
openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, BlockPos pos)
Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORY
for how to provide a function to consume these GUI requests on the client.static void
registerClientLoginChannel(NetworkManager manager)
static void
registerServerLoginChannel(NetworkManager manager, CHandshakePacket packet)
static void
sendMCRegistryPackets(NetworkManager manager, java.lang.String direction)
static void
syncCustomTagTypes(ServerPlayerEntity player, ITagCollectionSupplier tagCollectionSupplier)
Syncs the custom tag types attached to aITagCollectionSupplier
to the given player.static void
syncCustomTagTypes(ITagCollectionSupplier tagCollectionSupplier)
Syncs the custom tag types attached to aITagCollectionSupplier
to all connected players.static boolean
tickNegotiation(ServerLoginNetHandler netHandlerLoginServer, NetworkManager networkManager, ServerPlayerEntity player)
static void
validatePacketDirection(NetworkDirection packetDirection, java.util.Optional<NetworkDirection> expectedDirection, NetworkManager connection)
private static boolean
validateSideForProcessing(ICustomPacket<?> packet, NetworkInstance ni, NetworkManager manager)
-
-
-
Method Detail
-
getFMLVersion
public static java.lang.String getFMLVersion(java.lang.String ip)
-
getConnectionType
public static ConnectionType getConnectionType(java.util.function.Supplier<NetworkManager> connection)
-
getConnectionType
public static ConnectionType getConnectionType(io.netty.channel.ChannelHandlerContext context)
-
getConnectionType
private static ConnectionType getConnectionType(io.netty.channel.Channel channel)
-
onCustomPayload
public static boolean onCustomPayload(ICustomPacket<?> packet, NetworkManager manager)
-
validateSideForProcessing
private static boolean validateSideForProcessing(ICustomPacket<?> packet, NetworkInstance ni, NetworkManager manager)
-
validatePacketDirection
public static void validatePacketDirection(NetworkDirection packetDirection, java.util.Optional<NetworkDirection> expectedDirection, NetworkManager connection)
-
registerServerLoginChannel
public static void registerServerLoginChannel(NetworkManager manager, CHandshakePacket packet)
-
registerClientLoginChannel
public static void registerClientLoginChannel(NetworkManager manager)
-
sendMCRegistryPackets
public static void sendMCRegistryPackets(NetworkManager manager, java.lang.String direction)
-
isVanillaConnection
public static boolean isVanillaConnection(NetworkManager manager)
-
handleClientLoginSuccess
public static void handleClientLoginSuccess(NetworkManager manager)
-
tickNegotiation
public static boolean tickNegotiation(ServerLoginNetHandler netHandlerLoginServer, NetworkManager networkManager, ServerPlayerEntity player)
-
openGui
public static void openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier)
Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORY
for how to provide a function to consume these GUI requests on the client. TheIInteractionObject#getGuiID()
is treated as aResourceLocation
. It should refer to a valid modId namespace, to trigger opening on the client. The namespace is directly used to lookup the modId in the client side.- Parameters:
player
- The player to open the GUI forcontainerSupplier
- A supplier of container properties including the registry name of the container
-
openGui
public static void openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, BlockPos pos)
Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORY
for how to provide a function to consume these GUI requests on the client. TheIInteractionObject#getGuiID()
is treated as aResourceLocation
. It should refer to a valid modId namespace, to trigger opening on the client. The namespace is directly used to lookup the modId in the client side.- Parameters:
player
- The player to open the GUI forcontainerSupplier
- A supplier of container properties including the registry name of the containerpos
- A block pos, which will be encoded into the auxillary data for this request
-
openGui
public static void openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, java.util.function.Consumer<PacketBuffer> extraDataWriter)
Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORY
for how to provide a function to consume these GUI requests on the client. TheIInteractionObject#getGuiID()
is treated as aResourceLocation
. It should refer to a valid modId namespace, to trigger opening on the client. The namespace is directly used to lookup the modId in the client side. The maximum size for #extraDataWriter is 32600 bytes.- Parameters:
player
- The player to open the GUI forcontainerSupplier
- A supplier of container properties including the registry name of the containerextraDataWriter
- Consumer to write any additional data the GUI needs
-
syncCustomTagTypes
public static void syncCustomTagTypes(ITagCollectionSupplier tagCollectionSupplier)
Syncs the custom tag types attached to aITagCollectionSupplier
to all connected players.- Parameters:
tagCollectionSupplier
- The tag collection supplier containing the custom tags
-
syncCustomTagTypes
public static void syncCustomTagTypes(ServerPlayerEntity player, ITagCollectionSupplier tagCollectionSupplier)
Syncs the custom tag types attached to aITagCollectionSupplier
to the given player.- Parameters:
player
- The player to sync the custom tags to.tagCollectionSupplier
- The tag collection supplier containing the custom tags
-
getConnectionData
@Nullable public static FMLConnectionData getConnectionData(NetworkManager mgr)
-
-