Download OC XNet Driver — Minecraft Mods — MetaMods

OC XNet Driver

Active

Downloads

0

Last update

6 years ago
Client
Addons

OC XNet Driver

This mod bridges two popular Minecraft extensions - OpenComputers and XNet, providing programmable control over resource transportation networks. It enables computer systems to interact with connected devices through the XNet infrastructure.

Core Features

The mod allows automated transfer of items, liquids, and energy between various blocks connected to the XNet network. Full programmatic control is available for all transfer operations.

Available Control Methods

  • getConnectedBlocks() - returns a list of all blocks connected to the XNet network
  • getSupportedCapabilities(pos[, side]) - displays all capabilities supported by the specified block
  • getItems(pos[, side]) - shows contents of any inventory container
  • getFluids(pos[, side]) - displays contents of fluid tanks
  • getEnergy(pos[, side]) - shows current charge and capacity of energy storage devices
  • transferItem(sourcePos, sourceSlot, amount, targetPos[, sourceSide[, targetSide]]) - moves items between inventories
  • transferFluid(sourcePos, amount, targetPos[, fluidName][, sourceSide[, targetSide]]) - transfers liquids between tanks
  • transferEnergy(sourcePos, amount, targetPos[, sourceSide[, targetSide]]) - transfers energy between power storage devices
  • store(sourcePos, sourceSlot, database, entry[, sourceSide]) - saves items from the network to a database

Usage Example

local component = require('component')
local sides = require('sides')
local serialization = require('serialization');

local xnet = component.xnet

-- Find and classify all connected blocks
local chests = {}
local tanks = {}
local cells = {}
for i,block in ipairs(xnet.getConnectedBlocks()) do
    print(serialization.serialize(block))
    if(block.name == "minecraft:chest") then
        chests[#chests+1] = block
    elseif(block.name == "thermalexpansion:tank") then
        tanks[#tanks+1] = block
    elseif(block.name == "thermalexpansion:cell") then
        cells[#cells+1] = block
    end
end

-- Display chest contents
print(serialization.serialize(xnet.getItems(chests[1].pos)))

-- Transfer items between chests
print("Transferred: " .. tostring(xnet.transferItem(chests[1].pos, 1, 5, chests[2].pos)))

Energy Transfer: Practical Example

local component = require('component')
local sides = require('sides')
local serialization = require('serialization')

local xnet = component.xnet

-- Locate energy source and target
local energySource = nil
local energyTarget = nil

for i,block in ipairs(xnet.getConnectedBlocks()) do
    if(block.name == "thermalexpansion:dynamo") then
        energySource = block
    elseif(block.name == "thermalexpansion:cell") then
        energyTarget = block
    end
end

-- Transfer 1000RF energy
if energySource and energyTarget then
    local transferred, error = xnet.transferEnergy(energySource.pos, 1000, energyTarget.pos, sides[energySource.side], sides[energyTarget.side])
    if(transferred ~= nil) then
        print(" - Transferred " .. transferred .. "RF " .. serialization.serialize(energyTarget.pos))
    else
        print("Error: " .. error)
    end
end

Current Limitations

In the current version, there are no restrictions on transfer volumes - users can move enormous amounts of resources almost instantaneously.

The mod maintains full compatibility with key modifications such as Thermal Expansion and other devices that support standard interaction methods.

Project members
davenonymous

davenonymous

Created: 2 Nov 2018

ID: 92380