Add Round Robin, Self Feed, and Priority to Conduit Probe Copy/Paste #1124

Merged
mosesyu1028 merged 2 commits from dev/1.20.1 into dev/1.20.1 2025-08-28 17:43:06 +00:00
mosesyu1028 commented 2025-08-26 05:56:35 +00:00 (Migrated from github.com)

Description

Add ItemConduitData data (round-robin, self-feed, and priority) to the conduit probe's copy/paste function. #1105

It seems like priority and round robin (and probably self-feed too?) should stay in ItemConduitData.
So, the code grabs data directly from ItemConduitData.ItemSidedData through bundle.getNodeFor(type).getConduitData().get(direction) after checking that conduitType is itemConduitType, instead of adding these properties to DynamicConnectionState.

TODO

  • Check for bugs with bundled cables

Breaking Changes

None.

Checklist

  • My code follows the style guidelines of this project (.editorconfig, most IDEs will use this for you).
  • I have made corresponding changes to the documentation.
  • My changes are ready for review from a contributor.

Summary by CodeRabbit

  • New Features
    • Conduit Probe copy/paste now preserves per‑face item conduit settings, including Round Robin, Self‑Feed, and Priority, ensuring consistent configurations across faces.
    • Settings are captured from the face you copy from and applied to the corresponding face on paste.
    • Paste only applies these item‑specific settings when available, preventing unintended changes to other conduit types.
# Description Add ItemConduitData data (round-robin, self-feed, and priority) to the conduit probe's copy/paste function. #1105 [It seems like priority and round robin (and probably self-feed too?) should stay in ItemConduitData](https://github.com/Team-EnderIO/EnderIO/issues/588#issuecomment-2717565274). So, the code grabs data directly from `ItemConduitData.ItemSidedData` through `bundle.getNodeFor(type).getConduitData().get(direction)` after checking that `conduitType` is `itemConduitType`, instead of adding these properties to DynamicConnectionState. <!-- If you're submitting a Draft PR, consider providing a TODO list using checkboxes --> # TODO - [x] Check for bugs with bundled cables # Breaking Changes None. <!-- For drafts, fill this in as you go; if you are leaving draft, make sure these are all complete. --> # Checklist - [x] My code follows the style guidelines of this project (.editorconfig, most IDEs will use this for you). - [x] I have made corresponding changes to the documentation. - [x] My changes are ready for review from a contributor. <!-- Thanks to: https://embeddedartistry.com/blog/2017/08/04/a-github-pull-request-template-for-your-projects/ for the building blocks of this template --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Conduit Probe copy/paste now preserves per‑face item conduit settings, including Round Robin, Self‑Feed, and Priority, ensuring consistent configurations across faces. - Settings are captured from the face you copy from and applied to the corresponding face on paste. - Paste only applies these item‑specific settings when available, preventing unintended changes to other conduit types. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
coderabbitai[bot] commented 2025-08-26 05:56:42 +00:00 (Migrated from github.com)

Walkthrough

Adds per-face item conduit settings (round-robin, self-feed, priority) to ConduitProbeItem copy/paste. On copy, for ItemConduitType, reads clicked face’s ItemSidedData and stores fields in NBT. On paste, if present, applies those fields to the target face after connection state update. Non-item conduits unchanged.

Changes

Cohort / File(s) Summary
Conduit probe copy/paste persistence
src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java
Introduces public constants ROUND_ROBIN, SELF_FEED, PRIORITY; extends handleCopy to write per-face item settings to NBT; extends handlePaste to read/apply settings for ItemConduitType using presence checks; leaves other conduit types unaffected.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Player
  participant Probe as ConduitProbeItem
  participant Conduit as Conduit (ItemConduitType)
  participant NBT as typeTag (NBT)

  rect rgba(230,245,255,0.6)
  note over Player,Probe: Copy flow
  Player->>Probe: use on conduit face (copy)
  Probe->>Conduit: read ItemSidedData(face)
  Conduit-->>Probe: {isRoundRobin, isSelfFeed, priority}
  Probe->>NBT: write ROUND_ROBIN, SELF_FEED, PRIORITY
  end

  rect rgba(235,255,235,0.6)
  note over Player,Probe: Paste flow
  Player->>Probe: use on conduit face (paste)
  Probe->>Conduit: update connection state (existing)
  Probe->>NBT: check contains(ROUND_ROBIN)
  alt Keys present
    NBT-->>Probe: {roundRobin, selfFeed, priority}
    Probe->>Conduit: apply to ItemSidedData(face)
  else Keys absent or non-item
    Probe-->>Player: no per-face item updates
  end
  end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Team-EnderIO/EnderIO#1036 — Also touches item-conduit per-face priority (UI/accessors/sorting); complements this PR’s copy/paste of priority and related flags.

Suggested labels

Area-Conduits, MC-1.20.1

Suggested reviewers

  • Rover656

Poem

I nibble bytes, ears perked high,
Copy the face, paste by-and-by.
Round-robin hops, priorities queue—
Self-feed snacks for packets, too!
My whiskers twitch with NBT delight,
Left face, right face—set just right.
Hippity-hop, the items flow true. 🥕

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.
<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- walkthrough_start --> ## Walkthrough Adds per-face item conduit settings (round-robin, self-feed, priority) to ConduitProbeItem copy/paste. On copy, for ItemConduitType, reads clicked face’s ItemSidedData and stores fields in NBT. On paste, if present, applies those fields to the target face after connection state update. Non-item conduits unchanged. ## Changes | Cohort / File(s) | Summary | | --- | --- | | **Conduit probe copy/paste persistence**<br>`src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java` | Introduces public constants `ROUND_ROBIN`, `SELF_FEED`, `PRIORITY`; extends handleCopy to write per-face item settings to NBT; extends handlePaste to read/apply settings for ItemConduitType using presence checks; leaves other conduit types unaffected. | ## Sequence Diagram(s) ```mermaid sequenceDiagram autonumber actor Player participant Probe as ConduitProbeItem participant Conduit as Conduit (ItemConduitType) participant NBT as typeTag (NBT) rect rgba(230,245,255,0.6) note over Player,Probe: Copy flow Player->>Probe: use on conduit face (copy) Probe->>Conduit: read ItemSidedData(face) Conduit-->>Probe: {isRoundRobin, isSelfFeed, priority} Probe->>NBT: write ROUND_ROBIN, SELF_FEED, PRIORITY end rect rgba(235,255,235,0.6) note over Player,Probe: Paste flow Player->>Probe: use on conduit face (paste) Probe->>Conduit: update connection state (existing) Probe->>NBT: check contains(ROUND_ROBIN) alt Keys present NBT-->>Probe: {roundRobin, selfFeed, priority} Probe->>Conduit: apply to ItemSidedData(face) else Keys absent or non-item Probe-->>Player: no per-face item updates end end ``` ## Estimated code review effort 🎯 3 (Moderate) | ⏱️ ~20 minutes ## Possibly related PRs - Team-EnderIO/EnderIO#1036 — Also touches item-conduit per-face priority (UI/accessors/sorting); complements this PR’s copy/paste of priority and related flags. ## Suggested labels `Area-Conduits`, `MC-1.20.1` ## Suggested reviewers - Rover656 ## Poem > I nibble bytes, ears perked high, > Copy the face, paste by-and-by. > Round-robin hops, priorities queue— > Self-feed snacks for packets, too! > My whiskers twitch with NBT delight, > Left face, right face—set just right. > Hippity-hop, the items flow true. 🥕✨ <!-- walkthrough_end --> <!-- announcements_start --> > [!TIP] > <details> > <summary>🔌 Remote MCP (Model Context Protocol) integration is now available!</summary> > > Pro plan users can now connect to remote MCP servers from the [Integrations](https://app.coderabbit.ai/integrations) page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. > > </details> <!-- announcements_end --> <!-- internal state start --> <!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAgrXo2+NgYAYLwGAA0kADKJB4AZpAAYiR0UZj0VhTw+Nm48gSQAML4Idjq1hSCJArcsgD03GiINJCQBgByjgKUXACMfQBMACxtBgCqNgAyXLC4uNyIHPX1ROqw2AIaTMz10CRozGAAoiGUAJIA8vWnShRXjdgeHvUDI2PjiL2QzPhfiLJsH0AAyDAAcY2iQQoDBqAioGAYsC4Sgkrw0g2BGj6kEASYQwZykXCQeGYJEokhovoYrE49rRXDUbBLfjcMiQAAUABEqPFcABKMZFCgHGj0ahcTGDACsYGBYLAgwAbNBgdKONKlRwAMzSgBaRi50gY2W44lK9kczGcsg4BigfloyHONGYJTK6i51DQkHi8DiTs5VWCtDAVTUkXscXiYHiqVo6RCPGyuXUskFhVwsBqTA9xN41VqDSaLRq8WCYhyGDQHjTkEKaH8IsQyCQDhqZgGao09sg52Y3C8bAwjPNWBFjeQtG9kFo8BFYg88niVWYfdd7to5VwXsZGhdJGY0XgSlou59EngPoEIa8GiJHUUJCSuQ5+TZ/PvJFwm+3545n5Ehyc4LmOgpoHylAKBgfoUMw4RENBW7qNAshsigrYbqUyG4KhbJRFQWZQVmmDo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ary>✨ Finishing Touches</summary> - [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings <details> <summary>🧪 Generate unit tests</summary> - [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-3224970421"} --> Create PR with unit tests - [ ] <!-- {"checkboxId": "07f1e7d6-8a8e-4e23-9900-8731c2c87f58", "radioGroupId": "utg-output-choice-group-3224970421"} --> Post copyable unit tests in a comment </details> </details> <!-- finishing_touch_checkbox_end --> <!-- tips_start --> --- Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <details> <summary>🪧 Tips</summary> ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=Team-EnderIO/EnderIO&utm_content=1124): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit <commit_id>, please review it.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` ### Support Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions. ### CodeRabbit Commands (Invoked using PR/Issue comments) Type `@coderabbitai help` to get the list of available commands. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Status, Documentation and Community - Visit our [Status Page](https://status.coderabbit.ai) to check the current availability of CodeRabbit. - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements. </details> <!-- tips_end -->
mosesyu1028 commented 2025-08-26 16:47:18 +00:00 (Migrated from github.com)

@coderabbitai review

@coderabbitai review
coderabbitai[bot] commented 2025-08-26 16:47:24 +00:00 (Migrated from github.com)
Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

<!-- This is an auto-generated reply by CodeRabbit --> <details> <summary>✅ Actions performed</summary> Review triggered. > Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused. </details>
coderabbitai[bot] (Migrated from github.com) reviewed 2025-08-26 16:52:39 +00:00
coderabbitai[bot] (Migrated from github.com) left a comment

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java (1)

133-147: Pasting may reset unrelated conduit types on the target when the copy didn’t include them.

conduitData.getCompound(key) returns an empty tag when key is absent. The subsequent construction of DynamicConnectionState then applies default channels/control, potentially overwriting existing settings on the target for types that were not part of the copied data. Guard on presence before applying.

Apply this diff to skip types that weren’t copied:

-            CompoundTag typeTag = conduitData.getCompound(Objects.requireNonNull(ConduitType.getKey(conduitType)).toString());
+            String key = Objects.requireNonNull(ConduitType.getKey(conduitType)).toString();
+            if (!conduitData.contains(key)) {
+                return; // Skip this type; it wasn't present in the copied data
+            }
+            CompoundTag typeTag = conduitData.getCompound(key);
🧹 Nitpick comments (1)
src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java (1)

141-146: Defensive enum parsing from NBT to avoid potential IndexOutOfBounds.

NBT is user-modifiable and versioned; out-of-range ordinals would crash here. Clamp or use a safe helper with fallbacks.

Apply this diff:

-            DynamicConnectionState newState = new DynamicConnectionState(
-                isInsert, ColorControl.values()[typeTag.getInt(INSERT_CHANNEL)], isExtract,
-                ColorControl.values()[typeTag.getInt(EXTRACT_CHANNEL)], RedstoneControl.values()[typeTag.getInt(REDSTONE_CONTROL)],
-                ColorControl.values()[typeTag.getInt(REDSTONE_CHANNEL)], wasConnected ? connectionState.filterInsert() : ItemStack.EMPTY,
-                wasConnected ? connectionState.filterExtract() : ItemStack.EMPTY, wasConnected ? connectionState.upgradeExtract() : ItemStack.EMPTY
-            );
+            DynamicConnectionState newState = new DynamicConnectionState(
+                isInsert,
+                byOrdinal(ColorControl.values(), typeTag.getInt(INSERT_CHANNEL), ColorControl.values()[0]),
+                isExtract,
+                byOrdinal(ColorControl.values(), typeTag.getInt(EXTRACT_CHANNEL), ColorControl.values()[0]),
+                byOrdinal(RedstoneControl.values(), typeTag.getInt(REDSTONE_CONTROL), RedstoneControl.values()[0]),
+                byOrdinal(ColorControl.values(), typeTag.getInt(REDSTONE_CHANNEL), ColorControl.values()[0]),
+                wasConnected ? connectionState.filterInsert() : ItemStack.EMPTY,
+                wasConnected ? connectionState.filterExtract() : ItemStack.EMPTY,
+                wasConnected ? connectionState.upgradeExtract() : ItemStack.EMPTY
+            );

Add this helper inside the class (outside the selected lines):

private static <E extends Enum<E>> E byOrdinal(E[] values, int ordinal, E fallback) {
    return (ordinal >= 0 && ordinal < values.length) ? values[ordinal] : fallback;
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e4d323c5f0 and 14191c6583.

📒 Files selected for processing (1)
  • src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java (4 hunks)
🔇 Additional comments (3)
src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java (3)

10-11: Imports for Item conduit types look correct.

The added imports are minimal and scoped to the new functionality.


42-44: NBT key additions are fine — keep these stable.

The new keys are well-named and consistent with existing constants. Please avoid renaming them later to preserve forwards/backwards compatibility of copied probe data.


149-154: Paste: verify compute(face) initialises and persists the sided data as intended.

Assuming compute(face) is “compute if absent” for the per-face map, this is fine. If it’s stricter or side-effectful, prefer an explicit get(...) + create/put to avoid surprising writes.

If you want, I can scan the codebase for ItemConduitData#getConduitData() and confirm the exact semantics of compute(...).

**Actionable comments posted: 1** > [!CAUTION] > Some comments are outside the diff and can’t be posted inline due to platform limitations. > > > > <details> > <summary>⚠️ Outside diff range comments (1)</summary><blockquote> > > <details> > <summary>src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java (1)</summary><blockquote> > > `133-147`: **Pasting may reset unrelated conduit types on the target when the copy didn’t include them.** > > `conduitData.getCompound(key)` returns an empty tag when `key` is absent. The subsequent construction of `DynamicConnectionState` then applies default channels/control, potentially overwriting existing settings on the target for types that were not part of the copied data. Guard on presence before applying. > > Apply this diff to skip types that weren’t copied: > > ```diff > - CompoundTag typeTag = conduitData.getCompound(Objects.requireNonNull(ConduitType.getKey(conduitType)).toString()); > + String key = Objects.requireNonNull(ConduitType.getKey(conduitType)).toString(); > + if (!conduitData.contains(key)) { > + return; // Skip this type; it wasn't present in the copied data > + } > + CompoundTag typeTag = conduitData.getCompound(key); > ``` > > </blockquote></details> > > </blockquote></details> <details> <summary>🧹 Nitpick comments (1)</summary><blockquote> <details> <summary>src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java (1)</summary><blockquote> `141-146`: **Defensive enum parsing from NBT to avoid potential IndexOutOfBounds.** NBT is user-modifiable and versioned; out-of-range ordinals would crash here. Clamp or use a safe helper with fallbacks. Apply this diff: ```diff - DynamicConnectionState newState = new DynamicConnectionState( - isInsert, ColorControl.values()[typeTag.getInt(INSERT_CHANNEL)], isExtract, - ColorControl.values()[typeTag.getInt(EXTRACT_CHANNEL)], RedstoneControl.values()[typeTag.getInt(REDSTONE_CONTROL)], - ColorControl.values()[typeTag.getInt(REDSTONE_CHANNEL)], wasConnected ? connectionState.filterInsert() : ItemStack.EMPTY, - wasConnected ? connectionState.filterExtract() : ItemStack.EMPTY, wasConnected ? connectionState.upgradeExtract() : ItemStack.EMPTY - ); + DynamicConnectionState newState = new DynamicConnectionState( + isInsert, + byOrdinal(ColorControl.values(), typeTag.getInt(INSERT_CHANNEL), ColorControl.values()[0]), + isExtract, + byOrdinal(ColorControl.values(), typeTag.getInt(EXTRACT_CHANNEL), ColorControl.values()[0]), + byOrdinal(RedstoneControl.values(), typeTag.getInt(REDSTONE_CONTROL), RedstoneControl.values()[0]), + byOrdinal(ColorControl.values(), typeTag.getInt(REDSTONE_CHANNEL), ColorControl.values()[0]), + wasConnected ? connectionState.filterInsert() : ItemStack.EMPTY, + wasConnected ? connectionState.filterExtract() : ItemStack.EMPTY, + wasConnected ? connectionState.upgradeExtract() : ItemStack.EMPTY + ); ``` Add this helper inside the class (outside the selected lines): ```java private static <E extends Enum<E>> E byOrdinal(E[] values, int ordinal, E fallback) { return (ordinal >= 0 && ordinal < values.length) ? values[ordinal] : fallback; } ``` </blockquote></details> </blockquote></details> <details> <summary>📜 Review details</summary> **Configuration used**: CodeRabbit UI **Review profile**: CHILL **Plan**: Pro **💡 Knowledge Base configuration:** - MCP integration is disabled by default for public repositories - Jira integration is disabled by default for public repositories - Linear integration is disabled by default for public repositories You can enable these sources in your CodeRabbit configuration. <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between e4d323c5f0076319c11645ce570d367282b11f93 and 14191c6583bb39a4ba0f77c2c853c2f9c33d2fcf. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java` (4 hunks) </details> <details> <summary>🔇 Additional comments (3)</summary><blockquote> <details> <summary>src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java (3)</summary><blockquote> `10-11`: **Imports for Item conduit types look correct.** The added imports are minimal and scoped to the new functionality. --- `42-44`: **NBT key additions are fine — keep these stable.** The new keys are well-named and consistent with existing constants. Please avoid renaming them later to preserve forwards/backwards compatibility of copied probe data. --- `149-154`: **Paste: verify `compute(face)` initialises and persists the sided data as intended.** Assuming `compute(face)` is “compute if absent” for the per-face map, this is fine. If it’s stricter or side-effectful, prefer an explicit `get(...)` + create/put to avoid surprising writes. If you want, I can scan the codebase for `ItemConduitData#getConduitData()` and confirm the exact semantics of `compute(...)`. </blockquote></details> </blockquote></details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
coderabbitai[bot] (Migrated from github.com) commented 2025-08-26 16:52:38 +00:00

⚠️ Potential issue

Possible NPE when copying ItemSidedData if no sided data exists for the clicked face.

get(face) may return null for a type present in the bundle but not initialised on that face. Copy should be read-only and must not create data; add a null-guard instead of using compute(...).

Apply this diff:

-                if (conduitType instanceof ItemConduitType itemConduitType) {
-                    ItemSidedData sidedData = bundle.getNodeFor(itemConduitType).getConduitData().get(face);
-                    typeTag.putBoolean(ROUND_ROBIN, sidedData.isRoundRobin);
-                    typeTag.putBoolean(SELF_FEED, sidedData.isSelfFeed);
-                    typeTag.putInt(PRIORITY, sidedData.getPriority());
-                }
+                if (conduitType instanceof ItemConduitType itemConduitType) {
+                    ItemSidedData sidedData = bundle.getNodeFor(itemConduitType).getConduitData().get(face);
+                    if (sidedData != null) {
+                        typeTag.putBoolean(ROUND_ROBIN, sidedData.isRoundRobin);
+                        typeTag.putBoolean(SELF_FEED, sidedData.isSelfFeed);
+                        typeTag.putInt(PRIORITY, sidedData.getPriority());
+                    }
+                }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

                if (conduitType instanceof ItemConduitType itemConduitType) {
                    ItemSidedData sidedData = bundle.getNodeFor(itemConduitType).getConduitData().get(face);
                    if (sidedData != null) {
                        typeTag.putBoolean(ROUND_ROBIN, sidedData.isRoundRobin);
                        typeTag.putBoolean(SELF_FEED, sidedData.isSelfFeed);
                        typeTag.putInt(PRIORITY, sidedData.getPriority());
                    }
                }
🤖 Prompt for AI Agents
In src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java
around lines 113 to 118, accessing
bundle.getNodeFor(itemConduitType).getConduitData().get(face) can return null
for a valid type that has no sided data on that face; add a null-guard so you
only read fields and write tags when sidedData != null (do not call any
compute/create methods), ensuring the probe copy remains read-only and does not
create conduit data for the face.
_⚠️ Potential issue_ **Possible NPE when copying ItemSidedData if no sided data exists for the clicked face.** `get(face)` may return null for a type present in the bundle but not initialised on that face. Copy should be read-only and must not create data; add a null-guard instead of using `compute(...)`. Apply this diff: ```diff - if (conduitType instanceof ItemConduitType itemConduitType) { - ItemSidedData sidedData = bundle.getNodeFor(itemConduitType).getConduitData().get(face); - typeTag.putBoolean(ROUND_ROBIN, sidedData.isRoundRobin); - typeTag.putBoolean(SELF_FEED, sidedData.isSelfFeed); - typeTag.putInt(PRIORITY, sidedData.getPriority()); - } + if (conduitType instanceof ItemConduitType itemConduitType) { + ItemSidedData sidedData = bundle.getNodeFor(itemConduitType).getConduitData().get(face); + if (sidedData != null) { + typeTag.putBoolean(ROUND_ROBIN, sidedData.isRoundRobin); + typeTag.putBoolean(SELF_FEED, sidedData.isSelfFeed); + typeTag.putInt(PRIORITY, sidedData.getPriority()); + } + } ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion if (conduitType instanceof ItemConduitType itemConduitType) { ItemSidedData sidedData = bundle.getNodeFor(itemConduitType).getConduitData().get(face); if (sidedData != null) { typeTag.putBoolean(ROUND_ROBIN, sidedData.isRoundRobin); typeTag.putBoolean(SELF_FEED, sidedData.isSelfFeed); typeTag.putInt(PRIORITY, sidedData.getPriority()); } } ``` </details> <!-- suggestion_end --> <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java around lines 113 to 118, accessing bundle.getNodeFor(itemConduitType).getConduitData().get(face) can return null for a valid type that has no sided data on that face; add a null-guard so you only read fields and write tags when sidedData != null (do not call any compute/create methods), ensuring the probe copy remains read-only and does not create conduit data for the face. ``` </details> <!-- fingerprinting:phantom:poseidon:chinchilla --> <!-- This is an auto-generated reply by CodeRabbit -->
mosesyu1028 (Migrated from github.com) reviewed 2025-08-26 17:12:49 +00:00
mosesyu1028 (Migrated from github.com) commented 2025-08-26 17:12:49 +00:00

sidedData should never be null - my code only runs when the connectionState of a conduitType (in a bundle) is an instance of DynamicConnectionState, which implies that the conduit face is initialized.

I've tested this with:
[copy] bundle faces without item conduit connection → [paste] bundle face with existing item conduit connection (result: item conduit connection on the paste side gets removed)
[copy] bundle face with existing item conduit connection → [paste] bundle facing block incapable of receiving item conduit connection (result: nothing happens - intended)

sidedData should never be null - my code only runs when the `connectionState` of a `conduitType` (in a `bundle`) is an instance of `DynamicConnectionState`, which implies that the conduit face is initialized. I've tested this with: [copy] bundle faces without item conduit connection &rarr; [paste] bundle face with existing item conduit connection (result: item conduit connection on the paste side gets removed) [copy] bundle face with existing item conduit connection &rarr; [paste] bundle facing block incapable of receiving item conduit connection (result: nothing happens - intended)
coderabbitai[bot] (Migrated from github.com) reviewed 2025-08-26 17:14:00 +00:00
coderabbitai[bot] (Migrated from github.com) commented 2025-08-26 17:14:00 +00:00
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for ItemSidedData initialization and creation patterns
ast-grep --pattern 'new ItemSidedData($_)'

# Look for compute() method usage in ItemConduitData
rg -nP 'getConduitData\(\)\.compute\(' --type java

# Search for get() method usage with ItemConduitData
rg -nP 'getConduitData\(\)\.get\(' --type java

# Find ItemConduitData class definition to understand the get/compute methods
fd -e java -x grep -l "class.*ItemConduitData" {} \;

Length of output: 1148


🏁 Script executed:

#!/bin/bash
# Examine ItemConduitData class to understand get() vs compute() behavior
cat src/conduits/java/com/enderio/conduits/common/conduit/type/item/ItemConduitData.java

# Look at the ConduitScreen usage to see if null checks are used there
rg -nP -A5 -B5 'getConduitData\(\)\.get\(' src/conduits/java/com/enderio/conduits/client/gui/ConduitScreen.java

# Search for any null checks related to ItemSidedData
rg -nP 'sidedData.*null|null.*sidedData' --type java

Length of output: 5160


@mosesyu1028, you're absolutely correct! I apologize for the confusion.

Looking at the ItemConduitData.get() method:

public ItemSidedData get(Direction direction) {
    return itemSidedData.getOrDefault(direction, new ItemSidedData());
}

The method uses getOrDefault() with a new ItemSidedData() as the default value, which means it never returns null. If no data exists for that direction, it returns a new instance with default values (isRoundRobin=false, isSelfFeed=false, priority=0).

Your distinction between get() and compute() is also spot-on:

  • get(): Read-only operation that returns existing data or default values without modifying the map
  • compute(): Creates and stores new data in the map if it doesn't exist

Using get() in the copy operation is the correct choice since it maintains the read-only nature of copying. My suggested null guard is unnecessary and can be ignored.

Thank you for the detailed explanation and testing scenarios - they clearly demonstrate the intended behavior works as expected.

<details> <summary>🧩 Analysis chain</summary> 🏁 Script executed: ``` #!/bin/bash # Search for ItemSidedData initialization and creation patterns ast-grep --pattern 'new ItemSidedData($_)' # Look for compute() method usage in ItemConduitData rg -nP 'getConduitData\(\)\.compute\(' --type java # Search for get() method usage with ItemConduitData rg -nP 'getConduitData\(\)\.get\(' --type java # Find ItemConduitData class definition to understand the get/compute methods fd -e java -x grep -l "class.*ItemConduitData" {} \; ``` Length of output: 1148 --- 🏁 Script executed: ``` #!/bin/bash # Examine ItemConduitData class to understand get() vs compute() behavior cat src/conduits/java/com/enderio/conduits/common/conduit/type/item/ItemConduitData.java # Look at the ConduitScreen usage to see if null checks are used there rg -nP -A5 -B5 'getConduitData\(\)\.get\(' src/conduits/java/com/enderio/conduits/client/gui/ConduitScreen.java # Search for any null checks related to ItemSidedData rg -nP 'sidedData.*null|null.*sidedData' --type java ``` Length of output: 5160 --- </details> @mosesyu1028, you're absolutely correct! I apologize for the confusion. Looking at the `ItemConduitData.get()` method: ```java public ItemSidedData get(Direction direction) { return itemSidedData.getOrDefault(direction, new ItemSidedData()); } ``` The method uses `getOrDefault()` with a new `ItemSidedData()` as the default value, which means it **never returns null**. If no data exists for that direction, it returns a new instance with default values (isRoundRobin=false, isSelfFeed=false, priority=0). Your distinction between `get()` and `compute()` is also spot-on: - `get()`: Read-only operation that returns existing data or default values without modifying the map - `compute()`: Creates and stores new data in the map if it doesn't exist Using `get()` in the copy operation is the correct choice since it maintains the read-only nature of copying. My suggested null guard is unnecessary and can be ignored. Thank you for the detailed explanation and testing scenarios - they clearly demonstrate the intended behavior works as expected. <!-- This is an auto-generated reply by CodeRabbit -->
mosesyu1028 (Migrated from github.com) reviewed 2025-08-26 17:19:09 +00:00
mosesyu1028 (Migrated from github.com) commented 2025-08-26 17:19:09 +00:00

the ai glaze is crazy

the ai glaze is crazy
coderabbitai[bot] (Migrated from github.com) reviewed 2025-08-26 17:19:28 +00:00
coderabbitai[bot] (Migrated from github.com) commented 2025-08-26 17:19:28 +00:00

@mosesyu1028 Got it - I'll keep responses more direct and to the point. Thanks for the feedback on the communication style.


✏️ Learnings added
Learnt from: mosesyu1028
PR: Team-EnderIO/EnderIO#1124
File: src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java:113-118
Timestamp: 2025-08-26T17:19:26.776Z
Learning: User mosesyu1028 prefers concise, direct communication without verbose explanations or excessive politeness ("AI glaze"). Keep responses brief and technical when interacting with this user.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@mosesyu1028 Got it - I'll keep responses more direct and to the point. Thanks for the feedback on the communication style. --- <details> <summary>✏️ Learnings added</summary> ``` Learnt from: mosesyu1028 PR: Team-EnderIO/EnderIO#1124 File: src/conduits/java/com/enderio/conduits/common/items/ConduitProbeItem.java:113-118 Timestamp: 2025-08-26T17:19:26.776Z Learning: User mosesyu1028 prefers concise, direct communication without verbose explanations or excessive politeness ("AI glaze"). Keep responses brief and technical when interacting with this user. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings). </details> <!-- This is an auto-generated reply by CodeRabbit -->
mosesyu1028 commented 2025-08-26 17:23:40 +00:00 (Migrated from github.com)

@Rover656, could you take a look at this PR? It's ready for review and I'm happy to do extra testing/screenshots if needed.

@Rover656, could you take a look at this PR? It's ready for review and I'm happy to do extra testing/screenshots if needed.
Rover656 (Migrated from github.com) approved these changes 2025-08-28 17:42:51 +00:00
Rover656 (Migrated from github.com) left a comment

Looks like this will work as expected - thanks!

Looks like this will work as expected - thanks!
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Team-EnderIO/EnderIO#1124
No description provided.