Project Red - Illumination

Project Red - Illumination

37M Downloads

Bundled Cable compatibility with ComputerCraft is broken

SquidDev opened this issue ยท 2 comments

commented

Describe the bug
There appears to be a couple of minor bugs with ProjectRed's bundled cable API which mean that its CC compatibility is non-functional.

To Reproduce
Steps to reproduce the behaviour:

  1. Place down a computer, a bundled cable to the right of it, then a white insulated cable and finally a lamp.
  2. Open the computer and run rs set right white true.
  3. Notice the lamp does not turn on.
  4. Replace the lamp with a lever and turn it on.
  5. Run rs probe on the computer.
  6. This detects no redstone inputs.

Expected behaviour
I would expect the lamp to turn on, and rs probe to indicate that the white channel is active.

Versions
Include versions of the dependencies. And since you're looking at it, make sure ProjectRed is up to date. Don't submit bugs for old versions, as they could have been fixed.

  • ProjectRed Version: Tested in a dev environment at 292850d.

Additional notes
I've managed to find the cause of a couple of these problems, but afraid not everything:

commented

Thanks for looking into this. Definitely seems like remnants from when we moved from Scala to Java.

According to the old Scala code, ITransmissionAPI#getBundledInput should give you the incoming signal to the block specified, meaning it will offset the given pos towards the face, then ask that neighbor block for its output. The function BundledSignalsLib.getBundledInput actually does this (see line 36), while the other does not (I believe I started writing this method in TransmissionAPI, then realized it fits better in BundledSignalsLib, copied it there, and forgot to redirect the call).

This is also why the IBundledRedstoneProvider I implemented offsets the side/face. Your API is an output getter, while mine is an input getter, so it has to operate from the other block's perspective. At the time, both of our APIs were stable so I couldn't just change mine to match unfortunately. Maybe I'll revisit it.

So overall, I think we fix it like this:

  1. For ProjectRed -> CC, point TransmissionAPI.getBundledInput to BundledSignalsLib.getBundledInput. This alone should fix probing.
  2. For CC -> ProjectRed, like you said, there's a bug with the sides that PR's cables are querying interactions with. Looking into this now.
commented

Found it! Here, the Bundled Cable asks its neighbor for a bundled signal. This line specifically is for registered interactions. For whatever reason, it's using the rotation index rather than converting it into a direction index.

byte[] externalSignal = BundledSignalsLib.getBundledSignalViaInteraction(lookup.tile.getLevel(), lookup.tile.getBlockPos(), Direction.values()[lookup.r]);

Instead it should be doing what line 230 does, converting that rotation to direction.

Same deal with Bundled gate parts:

return BundledSignalsLib.getBundledSignalViaInteraction(lookup.tile.getLevel(), lookup.tile.getBlockPos(), Direction.values()[lookup.r]);