public final class Network
extends java.lang.Object
API.network
may not have been initialized
at that time. Only start calling these methods in the init phase or later.Modifier and Type | Method and Description |
---|---|
static void |
joinNewNetwork(Node node)
Creates a new network with the specified node as its initial node.
|
static void |
joinOrCreateNetwork(net.minecraft.world.IBlockReader world,
net.minecraft.util.math.BlockPos pos)
Tries to add network node(s) at the specified coordinates to adjacent
networks.
|
static void |
joinOrCreateNetwork(net.minecraft.tileentity.TileEntity tileEntity)
Convenience overload for
joinOrCreateNetwork(IBlockReader, BlockPos) . |
static void |
joinWirelessNetwork(WirelessEndpoint endpoint)
Makes a wireless endpoint join the wireless network defined by the mod.
|
static void |
leaveWirelessNetwork(WirelessEndpoint endpoint)
Removes a wireless endpoint from the wireless network.
|
static void |
leaveWirelessNetwork(WirelessEndpoint endpoint,
net.minecraft.util.RegistryKey<net.minecraft.world.World> dimension)
Removes a wireless endpoint from the wireless network of a specific dimension.
|
static Builder.NodeBuilder |
newNode(Environment host,
Visibility reachability)
Factory function for creating new nodes.
|
static Packet |
newPacket(net.minecraft.nbt.CompoundNBT nbt)
Re-creates a network packet from a previously stored state.
|
static Packet |
newPacket(java.lang.String source,
java.lang.String destination,
int port,
java.lang.Object[] data)
Creates a new network packet as it would be sent or received by a
network card.
|
static void |
sendWirelessPacket(WirelessEndpoint source,
double strength,
Packet packet)
Sends a packet via the wireless network.
|
static void |
updateWirelessNetwork(WirelessEndpoint endpoint)
Updates a wireless endpoint in the wireless network.
|
public static void joinOrCreateNetwork(net.minecraft.tileentity.TileEntity tileEntity)
joinOrCreateNetwork(IBlockReader, BlockPos)
.
Environment
its one node will be
connected to any existing adjacent tile entity nodes. If none exist a
new network with the specified tile entity's node as its sole entry.
SidedEnvironment
the same rules as for simple environments apply, except that the
respective for each side is used when connecting, and each side's node
is added to its own new network, if necessary.tileEntity
- the tile entity to initialize.public static void joinOrCreateNetwork(net.minecraft.world.IBlockReader world, net.minecraft.util.math.BlockPos pos)
world
- the world containing the location to connect.pos
- the position at which to update the network.public static void joinNewNetwork(Node node)
node
- the node to create the network for.java.lang.IllegalArgumentException
- if the node already is in a network.public static void joinWirelessNetwork(WirelessEndpoint endpoint)
sendWirelessPacket(WirelessEndpoint, double, Packet)
method. The packets will only be sent to endpoints registered
with the network.
endpoint
- the endpoint to register with the network.public static void updateWirelessNetwork(WirelessEndpoint endpoint)
endpoint
- the endpoint for which to update the position.public static void leaveWirelessNetwork(WirelessEndpoint endpoint)
endpoint
- the endpoint to remove from the wireless network.public static void leaveWirelessNetwork(WirelessEndpoint endpoint, net.minecraft.util.RegistryKey<net.minecraft.world.World> dimension)
endpoint
- the endpoint to remove from the wireless network.dimension
- the dimension with the wireless network to remove the endpoint from.public static void sendWirelessPacket(WirelessEndpoint source, double strength, Packet packet)
source
- the endpoint that is sending the message.strength
- the signal strength with which to send the packet.packet
- the packet to send.public static Builder.NodeBuilder newNode(Environment host, Visibility reachability)
class YourThing extends TileEntity implements Environment { private ComponentConnector node_ = api.Network.newNode(this, Visibility.Network). withComponent("your_thing"). withConnector(32). create(); public Node node() { return node_; } // ... }
host
- the environment the node is created for.reachability
- the reachability of the node.public static Packet newPacket(java.lang.String source, java.lang.String destination, int port, java.lang.Object[] data)
source
- the address of the sending node.destination
- the address of the destination, or null
for a broadcast.port
- the port to send the packet to.data
- the payload of the packet.public static Packet newPacket(net.minecraft.nbt.CompoundNBT nbt)
nbt
- the tag to load the packet from.