public abstract class TileEntityEnvironment extends net.minecraft.tileentity.TileEntity implements Environment
Environment
interface to allow them to interact with the component network, by providing
a Node
and connecting it to said network.
Nodes in such a network can communicate with each other, or just use the
network as an index structure to find other nodes connected to them.Modifier and Type | Field and Description |
---|---|
protected boolean |
addedToNetwork |
protected Node |
node
This must be set in subclasses to the node that is used to represent
this tile entity.
|
Constructor and Description |
---|
TileEntityEnvironment() |
Modifier and Type | Method and Description |
---|---|
void |
invalidate() |
Node |
node()
The node this environment wraps.
|
void |
onChunkUnload() |
void |
onConnect(Node node)
This is called when a node is added to a network.
|
void |
onDisconnect(Node node)
This is called when a node is removed from the network.
|
void |
onMessage(Message message)
This is the generic message handler.
|
void |
readFromNBT(net.minecraft.nbt.NBTTagCompound nbt) |
void |
updateEntity() |
void |
writeToNBT(net.minecraft.nbt.NBTTagCompound nbt) |
addMapping, canUpdate, createAndLoadEntity, func_145828_a, getBlockMetadata, getBlockType, getDescriptionPacket, getDistanceFrom, getMaxRenderDistanceSquared, getRenderBoundingBox, getWorldObj, hasWorldObj, isInvalid, markDirty, onDataPacket, receiveClientEvent, setWorldObj, shouldRefresh, shouldRenderInPass, updateContainingBlockInfo, validate
protected Node node
Network.newNode(Environment, Visibility)
.
For example:
// The first parameters to newNode is the host() of the node, which will // usually be this tile entity. The second one is it's reachability, // which determines how other nodes in the same network can query this // node. SeeNetwork.nodes(li.cil.oc.api.network.Node)
. node = Network.newNode(this, Visibility.Network) // This call allows the node to consume energy from the // component network it is in and act as a consumer, or to // inject energy into that network and act as a producer. // If you do not need energy remove this call. .withConnector() // This call marks the tile entity as a component. This means you // can mark methods in it using theCallback
// annotation, making them callable from user code. The first // parameter is the name by which the component will be known in // the computer, in this case it could be accessed as // component.example. The second parameter is the // component's visibility. This is like the node's reachability, // but only applies to computers. For example, network cards can // only be seen by the computer they're installed in, but // can be reached by all other network cards in the same // network. If you do not need callbacks remove this call. .withComponent("example", Visibility.Neighbors) // Finalizes the construction of the node and returns it. .create();
protected boolean addedToNetwork
public Node node()
Environment
node
in interface Environment
public void onConnect(Node node)
Environment
onConnect
in interface Environment
public void onDisconnect(Node node)
Environment
onDisconnect
in interface Environment
public void onMessage(Message message)
Environment
Node
receives a message
that was sent via one of the send methods in the Network
or the Node itself.onMessage
in interface Environment
message
- the message to handle.public void updateEntity()
updateEntity
in class net.minecraft.tileentity.TileEntity
public void onChunkUnload()
onChunkUnload
in class net.minecraft.tileentity.TileEntity
public void invalidate()
invalidate
in class net.minecraft.tileentity.TileEntity
public void readFromNBT(net.minecraft.nbt.NBTTagCompound nbt)
readFromNBT
in class net.minecraft.tileentity.TileEntity
public void writeToNBT(net.minecraft.nbt.NBTTagCompound nbt)
writeToNBT
in class net.minecraft.tileentity.TileEntity