public enum NetworkRegistry extends java.lang.Enum<NetworkRegistry>
Modifier and Type | Class and Description |
---|---|
static class |
NetworkRegistry.TargetPoint
Represents a target point for the ALLROUNDPOINT target.
|
Enum Constant and Description |
---|
INSTANCE |
Modifier and Type | Field and Description |
---|---|
static io.netty.util.AttributeKey<Side> |
CHANNEL_SOURCE |
private java.util.EnumMap<Side,java.util.Map<java.lang.String,FMLEmbeddedChannel>> |
channels |
private java.util.Map<ModContainer,IGuiHandler> |
clientGuiHandlers |
static io.netty.util.AttributeKey<java.lang.String> |
FML_CHANNEL
Set in the
ChannelHandlerContext |
static io.netty.util.AttributeKey<java.lang.Boolean> |
FML_MARKER |
static byte |
FML_PROTOCOL |
static io.netty.util.AttributeKey<ModContainer> |
MOD_CONTAINER |
static io.netty.util.AttributeKey<INetHandler> |
NET_HANDLER |
private java.util.Map<ModContainer,NetworkModHolder> |
registry |
private java.util.Map<ModContainer,IGuiHandler> |
serverGuiHandlers |
Modifier and Type | Method and Description |
---|---|
java.util.Set<java.lang.String> |
channelNamesFor(Side side)
All the valid channel names for a side
|
void |
cleanAttributes() |
void |
fireNetworkHandshake(NetworkDispatcher networkDispatcher,
Side origin)
INTERNAL fire a handshake to all channels
|
FMLEmbeddedChannel |
getChannel(java.lang.String name,
Side source) |
java.lang.Object |
getLocalGuiContainer(ModContainer mc,
EntityPlayer player,
int modGuiId,
World world,
int x,
int y,
int z)
INTERNAL method for accessing the Gui registry
|
Container |
getRemoteGuiContainer(ModContainer mc,
EntityPlayerMP player,
int modGuiId,
World world,
int x,
int y,
int z)
INTERNAL method for accessing the Gui registry
|
java.util.Collection<java.lang.String> |
getRequiredMods(Side from) |
boolean |
hasChannel(java.lang.String channelName,
Side source)
Is there a channel with this name on this side?
|
boolean |
isVanillaAccepted(Side from) |
java.util.EnumMap<Side,FMLEmbeddedChannel> |
newChannel(ModContainer container,
java.lang.String name,
io.netty.channel.ChannelHandler... handlers)
INTERNAL Create a new channel pair with the specified name and channel handlers.
|
java.util.EnumMap<Side,FMLEmbeddedChannel> |
newChannel(java.lang.String name,
io.netty.channel.ChannelHandler... handlers)
Create a new synchronous message channel pair based on netty.
|
FMLEventChannel |
newEventDrivenChannel(java.lang.String name)
Construct a new
FMLEventChannel for the channel. |
SimpleNetworkWrapper |
newSimpleChannel(java.lang.String name)
Construct a new
SimpleNetworkWrapper for the channel. |
void |
register(ModContainer fmlModContainer,
java.lang.Class<?> clazz,
java.lang.String remoteVersionRange,
ASMDataTable asmHarvestedData)
INTERNAL method for registering a mod as a network capable thing
|
void |
registerGuiHandler(java.lang.Object mod,
IGuiHandler handler)
Register an
IGuiHandler for the supplied mod object. |
java.util.Map<ModContainer,NetworkModHolder> |
registry() |
static NetworkRegistry |
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.
|
static NetworkRegistry[] |
values()
Returns an array containing the constants of this enum type, in
the order they are declared.
|
public static final NetworkRegistry INSTANCE
private java.util.EnumMap<Side,java.util.Map<java.lang.String,FMLEmbeddedChannel>> channels
private java.util.Map<ModContainer,NetworkModHolder> registry
private java.util.Map<ModContainer,IGuiHandler> serverGuiHandlers
private java.util.Map<ModContainer,IGuiHandler> clientGuiHandlers
public static final io.netty.util.AttributeKey<java.lang.String> FML_CHANNEL
ChannelHandlerContext
public static final io.netty.util.AttributeKey<Side> CHANNEL_SOURCE
public static final io.netty.util.AttributeKey<ModContainer> MOD_CONTAINER
public static final io.netty.util.AttributeKey<INetHandler> NET_HANDLER
public static final io.netty.util.AttributeKey<java.lang.Boolean> FML_MARKER
public static final byte FML_PROTOCOL
public static NetworkRegistry[] values()
for (NetworkRegistry c : NetworkRegistry.values()) System.out.println(c);
public static NetworkRegistry valueOf(java.lang.String name)
name
- the name of the enum constant to be returned.java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is nullpublic java.util.EnumMap<Side,FMLEmbeddedChannel> newChannel(java.lang.String name, io.netty.channel.ChannelHandler... handlers)
newSimpleChannel(String)
provides SimpleNetworkWrapper
, a simple implementation of a netty handler, suitable for those who don't
wish to dive too deeply into netty.
newEventDrivenChannel(String)
(String)} provides FMLEventChannel
an event driven implementation, with lower level
access to the network data stream, for those with advanced bitbanging needs that don't wish to poke netty too hard.
FMLProxyPacket
. All operation is synchronous, as the
asynchronous behaviour occurs at a lower level in netty.
The first handler in the pipeline is special and should not be removed or moved from the head - it transforms
packets from the outbound of this pipeline into custom packets, based on the current AttributeKey
value
FMLOutboundHandler.FML_MESSAGETARGET
and FMLOutboundHandler.FML_MESSAGETARGETARGS
set on the channel.
For the client to server channel (source side : CLIENT) this is fixed as "TOSERVER". For SERVER to CLIENT packets,
several possible values exist.
Mod Messages should be transformed using a something akin to a MessageToMessageCodec
. FML provides
a utility codec, FMLIndexedMessageToMessageCodec
that transforms from FMLProxyPacket
to a mod
message using a message discriminator byte. This is optional, but highly recommended for use.
Note also that the handlers supplied need to be ChannelHandler.Sharable
- they are injected into two
channels.name
- handlers
- public SimpleNetworkWrapper newSimpleChannel(java.lang.String name)
SimpleNetworkWrapper
for the channel.name
- The name of the channelSimpleNetworkWrapper
for handling this channelpublic FMLEventChannel newEventDrivenChannel(java.lang.String name)
FMLEventChannel
for the channel.name
- The name of the channelFMLEventChannel
for handling this channelpublic java.util.EnumMap<Side,FMLEmbeddedChannel> newChannel(ModContainer container, java.lang.String name, io.netty.channel.ChannelHandler... handlers)
container
- The container to associate the channel withname
- The name for the channelhandlers
- Some ChannelHandler
for the channelEnumMap
of the pair of channels. keys are Side
. There will always be two entries.public FMLEmbeddedChannel getChannel(java.lang.String name, Side source)
public void registerGuiHandler(java.lang.Object mod, IGuiHandler handler)
IGuiHandler
for the supplied mod object.mod
- The mod to handle GUIs forhandler
- A handler for creating GUI related objects@Nullable public Container getRemoteGuiContainer(ModContainer mc, EntityPlayerMP player, int modGuiId, World world, int x, int y, int z)
mc
- Mod Containerplayer
- PlayermodGuiId
- guiIdworld
- Worldx
- X coordy
- Y coordz
- Z coordContainer
)@Nullable public java.lang.Object getLocalGuiContainer(ModContainer mc, EntityPlayer player, int modGuiId, World world, int x, int y, int z)
mc
- Mod Containerplayer
- PlayermodGuiId
- guiIdworld
- Worldx
- X coordy
- Y coordz
- Z coordGui
)public boolean hasChannel(java.lang.String channelName, Side source)
channelName
- The namesource
- the sidepublic void register(ModContainer fmlModContainer, java.lang.Class<?> clazz, @Nullable java.lang.String remoteVersionRange, ASMDataTable asmHarvestedData)
fmlModContainer
- The fml mod containerclazz
- a classremoteVersionRange
- the acceptable remote rangeasmHarvestedData
- internal datapublic boolean isVanillaAccepted(Side from)
public java.util.Collection<java.lang.String> getRequiredMods(Side from)
public java.util.Map<ModContainer,NetworkModHolder> registry()
public java.util.Set<java.lang.String> channelNamesFor(Side side)
side
- the sidepublic void fireNetworkHandshake(NetworkDispatcher networkDispatcher, Side origin)
networkDispatcher
- The dispatcher firingorigin
- which side the dispatcher is onpublic void cleanAttributes()