Back to mods
OC Sensors project artwork

CurseForge · Minecraft mod

OC Sensors

Sensor Addon for OpenComputers

Choose a version Pick your version below, then grab the matching file.

Quick answer

Which OC Sensors release should I use?

Updated 8 years ago
Latest stable file ocsensors-1.0.4-b23.jar
Game version 1.12.1, 1.12, 1.12.2
Loader Not required

OC Sensors ocsensors-1.0.4-b23.jar targets 1.12.1, 1.12, 1.12.2. The project page does not say whether this file belongs on the client, dedicated server, or both. All 1 required mods have matching files.

Where it goes

Is OC Sensors required on the client, server, or both?

The project page does not say whether this file belongs on the client, dedicated server, or both.

Client Source doesn’t say
Dedicated server Source doesn’t say
Loader for this release No loader listed
Required install it here Optional supported, not mandatory Not supported do not install here Source doesn’t say do not assume

The source does not explicitly classify this release as client-only or server-only.

What else does OC Sensors ocsensors-1.0.4-b23.jar need?

ocsensors-1.0.4-b23.jar. Change the file and its required mods may change too.

All 1 required mods have matching files

Install OpenComputers first. We found matching files for this game-version and loader setup.

OpenComputers Needed by OC Sensors ocsensors-1.0.4-b23.jar
required
Matching file found Matched file: OpenComputers-MC1.12.2-1.8.10+258943363.jar

We only count dependency files that match this setup. A file for another loader does not fill the gap.

Before you install it

Add OC Sensors without breaking your instance.

Built for OC Sensors ocsensors-1.0.4-b23.jar. Pick another file and the loader, install side or required mods may change.

  1. 01

    Stick to this file

    Use ocsensors-1.0.4-b23.jar. It targets 1.12.1, 1.12, 1.12.2; another release may have different loader, side or dependency requirements.

  2. 02

    Bring the mods it needs

    Install OpenComputers first. We found matching files for this game-version and loader setup.

  3. 03

    Put it on the correct side

    The project page does not say whether this file belongs on the client, dedicated server, or both.

  4. 04

    Pick the file you checked

    Use the “Get this file” button beside ocsensors-1.0.4-b23.jar. It opens that exact file at the source.

About this project

What does OC Sensors add?

ocsensors

Sensor Addon for OpenComputers

Similiar to the old OpenCCSensors mod this mod adds a sensor block that allows
computers to scan surrounding blocks.

Available Methods

Method Description
scan(x:number, y:number, z:number, [side:number]) Scans a block relative to the sensor
search([name:string=”“], [meta:number=-1], [section:string=”“], [range:number=]) Search for blocks matching the given criteria in the given range
searchEntities(x1:number, y1:number, z1:number, x2:number, y2:number, z3:number) Scans a region relative to the sensor for entities

Examples

Get stored energy of all energy-capable nearby blocks

local component = require('component')

local sensor = component.sensor

local totalCapacity = 0
local totalStored = 0

print("Searching for blocks handling energy")
local positions = sensor.search("", -1, "energy")

print("Scanning " .. #positions .. " blocks")
for _,pos in ipairs(positions) do
  local info = sensor.scan(pos.x, pos.y, pos.z)

  print("  " .. info.block.label .. " @ " .. pos.x .. "," .. pos.y .. "," .. pos.z)
  totalStored = totalStored + info.data.energy.energyStored
  totalCapacity = totalCapacity + info.data.energy.maxEnergyStored
end

print("")
print("Energy summary:")
print("  Total capacity: " .. totalCapacity);
print("  Total stored:   " .. totalStored);

Output a redstone signal when all nearby extra utilities 2 generators are ready to run

local component = require("component")
local sides = require("sides")

local sensor = component.sensor
local redstone = component.redstone

local redstoneSide = sides.back

-- Search for generators once
local generators = sensor.search("", -1, "extrautils2")

while(true) do
    -- Loop over nearby machines and see if they are all satisfied
    local missing = 0
    for _,pos in ipairs(generators) do
        local info = sensor.scan(pos.x, pos.y, pos.z)
        local xu = info.data.extrautils2

        -- Is the generator already running?
        local alreadyRunning = info.data.extrautils2.processTime > 0

        -- Is the Generator satisfied with items?
        local enoughItems = info.data.items.n == 0 or info.data.items.n == #info.data.items

        -- Is it satisfied with fluid?
        local enoughFluid = true
        if(info.data.fluid.n > 0) then
            for _,tank in ipairs(info.data.fluid) do
                if(tank.contents == nil or tank.contents.amount == 0) then
                    enoughFluid = false
                end
            end
        end

        if(alreadyRunning or (enoughItems and enoughFluid)) then
            --print(info.block.label .. ": " .. serialization.serialize(info.data))
            print("Ready:   " .. info.block.label)
        else
            print("Missing: " .. info.block.label)

            -- Immediately turn off all other generators
            redstone.setOutput(redstoneSide, 0)
            missing = missing + 1
        end
    end

    -- React accordingly
    if(missing == 0) then
        print("--> All generators good to go")
        redstone.setOutput(redstoneSide, 15)
    else
        print("--> Missing " .. missing .. " generators")
    end

    os.sleep(1)
end

Dump the fluid of all nearby MooFluid cows

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

local sensor = component.sensor

local range = 5

local foundFluids = {}
for _, entity in ipairs(sensor.searchEntities(-range, -range, -range, range, range, range)) do
    if(entity.type == "neutral" and entity.moofluids ~= nil) then
        foundFluids[#foundFluids+1] = entity.moofluids.fluid.name
    end
end

print(serialization.serialize(foundFluids))
-- {"lava", "lava", "lava", "water", "water", "lava"}

Project description from CurseForge.

Pick your setup

OC Sensors by Minecraft version and loader

Choose the version and loader you play, then open the matching release.

4 available setups

Check the dependencies, then try the file in a copied instance before changing a world you care about.

Recent files

OC Sensors versions and loaders

5 of 5 releases match

Looking for an older file? The official CurseForge project page is in Resources.