Search in sources :

Example 1 with Node

use of li.cil.oc.api.network.Node in project OpenLights by PC-Logix.

the class TileEntitySidedEnvironment method writeToNBT.

@Override
public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    int index = 0;
    for (Node node : nodes) {
        // See readFromNBT() regarding host check.
        if (node != null && node.host() == this) {
            final NBTTagCompound nodeNbt = new NBTTagCompound();
            node.save(nodeNbt);
            nbt.setTag("oc:node" + index, nodeNbt);
        }
        ++index;
    }
}
Also used : Node(li.cil.oc.api.network.Node) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 2 with Node

use of li.cil.oc.api.network.Node in project OpenLights by PC-Logix.

the class TileEntitySidedEnvironment method readFromNBT.

// ----------------------------------------------------------------------- //
@Override
public void readFromNBT(final NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    int index = 0;
    for (Node node : nodes) {
        // nodes in this tile entity).
        if (node != null && node.host() == this) {
            // This restores the node's address, which is required for networks
            // to continue working without interruption across loads. If the
            // node is a power connector this is also required to restore the
            // internal energy buffer of the node.
            node.load(nbt.getCompoundTag("oc:node" + index));
        }
        ++index;
    }
}
Also used : Node(li.cil.oc.api.network.Node)

Example 3 with Node

use of li.cil.oc.api.network.Node in project LogisticsPipes by RS485.

the class OpenComputersProxy method handleWriteToNBT.

@Override
public void handleWriteToNBT(IOCTile tile, NBTTagCompound nbt) {
    if (((Node) tile.getOCNode()) != null && ((Node) tile.getOCNode()).host() == tile) {
        final NBTTagCompound nodeNbt = new NBTTagCompound();
        ((Node) tile.getOCNode()).save(nodeNbt);
        nbt.setTag("oc:node", nodeNbt);
    }
}
Also used : Node(li.cil.oc.api.network.Node) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

Node (li.cil.oc.api.network.Node)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2