public interface NetworkAPI
Modifier and Type | Method and Description |
---|---|
void |
joinNewNetwork(Node node)
Creates a new network with the specified node as its initial node.
|
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.
|
void |
joinOrCreateNetwork(net.minecraft.tileentity.TileEntity tileEntity)
Convenience overload for
joinOrCreateNetwork(IBlockReader, BlockPos) . |
void |
joinWirelessNetwork(WirelessEndpoint endpoint)
Makes a wireless endpoint join the wireless network defined by the mod.
|
void |
leaveWirelessNetwork(WirelessEndpoint endpoint)
Removes a wireless endpoint from the wireless network.
|
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.
|
Builder.NodeBuilder |
newNode(Environment host,
Visibility reachability)
Factory function for creating new nodes.
|
Packet |
newPacket(net.minecraft.nbt.CompoundNBT nbt)
Re-creates a network packet from a previously stored state.
|
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.
|
void |
sendWirelessPacket(WirelessEndpoint source,
double strength,
Packet packet)
Sends a packet via the wireless network.
|
void |
updateWirelessNetwork(WirelessEndpoint endpoint)
Updates a wireless endpoint in the wireless network.
|
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.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.void joinNewNetwork(Node node)
node
- the node to create the network for.java.lang.IllegalArgumentException
- if the node already is in a network.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.void updateWirelessNetwork(WirelessEndpoint endpoint)
endpoint
- the endpoint for which to update the position.void leaveWirelessNetwork(WirelessEndpoint endpoint)
endpoint
- the endpoint to remove from the wireless network.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.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.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.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.Packet newPacket(net.minecraft.nbt.CompoundNBT nbt)
nbt
- the tag to load the packet from.