Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redstone relay #2002

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Redstone relay #2002

merged 1 commit into from
Nov 12, 2024

Conversation

SquidDev
Copy link
Member

@SquidDev SquidDev commented Oct 26, 2024

This adds a separate redstone peripheral, as described in #1624.

There's still a lot to do here, but felt it was worth making this public and getting some feedback here.

  • The peripheral is currently called "Redstone Control". I'm not wild about the name, so here's some alternatives I considered:

    • Redstone Control/Redstone Controller: My main worry here is that this suggests it only outputs redstone signals, not that it can receive them too.
    • Redstone IO: this is what OC uses. It makes sense, but I don't just want to steal the name from another mod.
    • Redstone Integrator: This is what Plethora does (my mod so I can steal from it :p). However, Plethora intentionally went for kinda pretentious(?) names (i.e. Kinetic Augment, Introspection module) — I'm not sure this quite fits the vibes of CC itself though.

    Not sure, feedback welcome!

  • I'm using @TheStraying11's proposed textures from Add a separate redstone peripheral #1624. These originally came in an on/off variety for each face. I've decided against this for now, and the block is always "on", as doing the models for this is really awkward. We could just have the whole block be on/off, rather than each face. Not sure!

  • The block is directional and uses relative sides ("left", "right", etc...), like the redstone API. We use the same direction mapping as turtles, where left/right are relative to the direction the block is facing (like turtles), rather than the player facing the block (like computers).

Still to do

  • Tests
  • Documentation

@SquidDev SquidDev added enhancement An extension of a feature or a new feature. feedback wanted Tell me what you want, what you really really want. area-Minecraft This affects CC's Minecraft-specific content. labels Oct 26, 2024
@Karotte128
Copy link
Contributor

I really like this feature!
Another possible name is "Redstone Port", but not sure if this name is good.

@Wojbie
Copy link
Contributor

Wojbie commented Oct 26, 2024

One alternative naming scheme worth considering could be Redstone extender or Redstone relay? As it extends/relays computer redstone control over peripheral network.

@SquidDev
Copy link
Member Author

Oh, "Relay" is a good one!

@SquidDev SquidDev linked an issue Oct 26, 2024 that may be closed by this pull request
@SquidDev SquidDev force-pushed the feature/redstone-control branch from 203f129 to b6e90f0 Compare November 10, 2024 22:19
 - Move redstone methods out of the IAPIEnvironment, and into a new
   RedstoneAccess. We similarly move the implementation from Environment
   into a new RedstoneState class.

   The interface is possibly a little redundant (interfaces with a
   single implementation are always a little suspect), but it's nice to
   keep the consumer/producer interfaces separate.

 - Abstract most redstone API methods into a separate shared class, that
   can be used by both the rs API and the new redstone relay.

 - Add the new redstone relay block.

The docs are probably a little lacking here, but I really struggled to
write anything which wasn't just "look, it's the same as the redstone
API".
@SquidDev SquidDev force-pushed the feature/redstone-control branch from b6e90f0 to 997f330 Compare November 12, 2024 09:04
@SquidDev SquidDev changed the title [WIP] Redstone control(ler) Redstone relay Nov 12, 2024
@SquidDev SquidDev merged commit 4f66ac7 into mc-1.20.x Nov 12, 2024
6 checks passed
@SquidDev SquidDev deleted the feature/redstone-control branch November 12, 2024 09:05
@MCJack123
Copy link
Contributor

I know this was already merged, but could we get a side parameter on the redstone event? It can be frustrating to have to check every single input on all connected relays to see if one side changed, especially if there's a lot of inputs - it would be much simpler code-wise if the input change could be narrowed down to a single relay.

(For my specific use case, I'm wrapping peripherals with a driver that limits peripheral events to programs that request them. Not knowing which event corresponds to which peripheral means I have to figure it out myself through a lot of peripheral calls, or the event needs to be sent to all redstone devices, regardless of whether that peripheral changed.)

@Wojbie
Copy link
Contributor

Wojbie commented Nov 14, 2024

Question is how its implemented.
Correct me if i am wrong but currently even if multiple changes happened at once, they would all generate only one redstone event right? Or would there be several of them?

  • If its just one per all changes, then adding name/side argument would mean increasing amount of events generated on busy redstone control system. It may be problematic due to event queue size?
  • But if its already generating multiple of them, then adding names/sides it would add some clarity.

I am about 90% sure its just one event for all changes.

@fatboychummy
Copy link
Contributor

fatboychummy commented Nov 15, 2024

Looking through the code, it looks to me like it is one event per relay. Which, if the relay included its own name (and assuming I've read things correctly), would not increase the number of events. However, this would decrease the amount of getInput calls required per event from n*6 (n=#relays) to just 6. This would keep the current limit of 256 redstone relays changing any number of sides per tick (1536 total redstone changes per tick).

Including the side of the relay that changed as well would increase the number of events received, but could then also include the previous and current redstone values, thus eliminating the need to even call getInput at all. This would, however, limit a network to having 256 redstone changes per tick, which is still a decent amount (in my opinion at least). However, since the computer would now be yielding for every change, I don't know if this would have any performance impacts for the increased resumes.

My overall thoughts? Having just the relay name in the event would be a significant upgrade, but going to per-change events may be overkill.

@Lupus590
Copy link
Contributor

I would also be surprised if (in most setups) any given restone relay has more one side being used. While it would make usercode more complex, one could map which side of each relay is being used and thus not need to check all 6 sides of that relay when its redstone event is pulled.

So yeah, having a second return value on redstone events for which relay queued that event would be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Minecraft This affects CC's Minecraft-specific content. enhancement An extension of a feature or a new feature. feedback wanted Tell me what you want, what you really really want.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a separate redstone peripheral
6 participants