Package net.minecraftforge.fml.network
Class NetworkHooks
java.lang.Object
net.minecraftforge.fml.network.NetworkHooks
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FMLConnectionDataprivate static ConnectionTypegetConnectionType(io.netty.channel.Channel channel) static ConnectionTypegetConnectionType(io.netty.channel.ChannelHandlerContext context) static ConnectionTypegetConnectionType(Supplier<NetworkManager> connection) static IPacket<?>getEntitySpawningPacket(Entity entity) static StringgetFMLVersion(String ip) static voidhandleClientLoginSuccess(NetworkManager manager) static booleanisVanillaConnection(NetworkManager manager) static booleanonCustomPayload(ICustomPacket<?> packet, NetworkManager manager) static voidopenGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier) Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORYfor how to provide a function to consume these GUI requests on the client.static voidopenGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, Consumer<PacketBuffer> extraDataWriter) Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORYfor how to provide a function to consume these GUI requests on the client.static voidopenGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier, BlockPos pos) Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORYfor how to provide a function to consume these GUI requests on the client.static voidregisterClientLoginChannel(NetworkManager manager) static voidregisterServerLoginChannel(NetworkManager manager, CHandshakePacket packet) static voidsendMCRegistryPackets(NetworkManager manager, String direction) static voidsyncCustomTagTypes(ServerPlayerEntity player, ITagCollectionSupplier tagCollectionSupplier) Syncs the custom tag types attached to aITagCollectionSupplierto the given player.static voidsyncCustomTagTypes(ITagCollectionSupplier tagCollectionSupplier) Syncs the custom tag types attached to aITagCollectionSupplierto all connected players.static booleantickNegotiation(ServerLoginNetHandler netHandlerLoginServer, NetworkManager networkManager, ServerPlayerEntity player) static voidvalidatePacketDirection(NetworkDirection packetDirection, Optional<NetworkDirection> expectedDirection, NetworkManager connection) private static booleanvalidateSideForProcessing(ICustomPacket<?> packet, NetworkInstance ni, NetworkManager manager)
-
Field Details
-
LOGGER
private static final org.apache.logging.log4j.Logger LOGGER
-
-
Constructor Details
-
NetworkHooks
public NetworkHooks()
-
-
Method Details
-
getFMLVersion
-
getConnectionType
-
getConnectionType
-
getConnectionType
-
getEntitySpawningPacket
-
onCustomPayload
-
validateSideForProcessing
private static boolean validateSideForProcessing(ICustomPacket<?> packet, NetworkInstance ni, NetworkManager manager) -
validatePacketDirection
public static void validatePacketDirection(NetworkDirection packetDirection, Optional<NetworkDirection> expectedDirection, NetworkManager connection) -
registerServerLoginChannel
-
registerClientLoginChannel
-
sendMCRegistryPackets
-
isVanillaConnection
-
handleClientLoginSuccess
-
tickNegotiation
public static boolean tickNegotiation(ServerLoginNetHandler netHandlerLoginServer, NetworkManager networkManager, ServerPlayerEntity player) -
openGui
Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORYfor 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#GUIFACTORYfor 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, Consumer<PacketBuffer> extraDataWriter) Request to open a GUI on the client, from the server Refer tonet.minecraftforge.fml.ExtensionPoint#GUIFACTORYfor 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
Syncs the custom tag types attached to aITagCollectionSupplierto 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 aITagCollectionSupplierto the given player.- Parameters:
player- The player to sync the custom tags to.tagCollectionSupplier- The tag collection supplier containing the custom tags
-
getConnectionData
-