Skip to content

forcecompletecraftingtasks() function - #782

Closed
Zexylz wants to merge 3 commits into
IntelligenceModding:dev/1.21.1from
Zexylz:dev/1.21.1
Closed

forcecompletecraftingtasks() function#782
Zexylz wants to merge 3 commits into
IntelligenceModding:dev/1.21.1from
Zexylz:dev/1.21.1

Conversation

@Zexylz

@Zexylz Zexylz commented Sep 7, 2025

Copy link
Copy Markdown

Add forceCompleteCraftingTasks() function

  • Added forceCompleteCraftingTasks() method to ME Bridge that instantly completes active AE2 crafting jobs by inserting crafted items directly into storage, bypassing normal crafting time

Files modified:

  • MEBridgePeripheral.java: Added forceCompleteCraftingTasks() method and simplified notification flow

This allows you to instantly complete slow or stuck crafting jobs

PLEASE READ THE GUIDELINES BEFORE MAKING A CONTRIBUTION

  • Please check if the PR fulfills these requirements
  • The commit message are well described
  • Docs have been added / updated (for features or maybe bugs which were noted). If not, please update the needed documentation here. Feel free to remove this check if you don't need it
  • All changes have fully been tested
  • What kind of change does this PR introduce? (Bug fix, feature, ...) feature

  • What is the current behavior? (You can also link to an open issue here) there was no possible way to forcecomplete a job you could cancel one but it wasnt the same as being marked complete vs canceling

  • What is the new behavior (if this is a feature change)? can now forcecomplete a job

  • Does this PR introduce a breaking change? (What changes might users need to make in their scripts due to this PR?) should not break anything

forceCompleteCraftingTasks([filter]) -> number
Instantly completes active AE2 crafting jobs by bypassing the normal crafting process and directly inserting the crafted items into the ME storage system.

docs

  • filter ('table', optional) - Filter criteria to specify which jobs to complete
    • If exist or {}, completes all active crafting jobs
    • Supports the same filter format as other ME Bridge functions

…ridge

- Add AE2 config integration using reflection to access notification settings
- Respect both AdvancedPeripherals and AE2 wireless terminal notify button state
- Visual toast notifications now require both settings to be enabled
- ComputerCraft events continue to work regardless of notification settings
- Use AE2's authentic FinishedJobToast for consistent user experience
- Graceful fallback when AE2 config methods cannot be accessed
- Update configuration comments to reflect actual AE2 integration

Files modified:
- CraftingCompleteToastPacket.java: Added AE2 config reflection logic
- MEBridgePeripheral.java: Updated notification flow comments
- PeripheralsConfig.java: Updated config description for dual-setting system

This ensures the ME Bridge peripheral respects user preferences set in
AE2's wireless terminal interface, providing seamless integration between
the two notification systems.
@github-actions

github-actions Bot commented Sep 7, 2025

Copy link
Copy Markdown
Contributor

Build Preview

badge

You can find files attached to the below linked Workflow Run URL (Logs).

Name Link
Commit ae6ba68
Logs https://github.com/IntelligenceModding/AdvancedPeripherals/actions/runs/17527902688

@Zexylz Zexylz changed the title feat: integrate AE2 wireless terminal notification settings with ME B… forcecompletecraftingtasks() function Sep 7, 2025
@Zexylz
Zexylz requested a review from SirEndii September 7, 2025 11:34

@zyxkad zyxkad left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope this is not AI written.


return MethodResult.of(true, "Successfully force completed task: " + taskIdOrResourceName
+ " (" + inserted + "/" + amount + " items added, completion notification sent)");
} catch (Exception e) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not abuse try catch.


// Cancel the job without relying on AE2 notification logic
cpu.cancelJob();
Thread.sleep(50);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use Thread.sleep for whatever reason. It is not a reliable way to wait for something.


MEStorage storage = AEApi.getMonitor(node);
long inserted = storage.insert(craftedItem, amountToInsert, Actionable.MODULATE, bridge);
AdvancedPeripherals.debug("[DEBUG] ==> Actually inserted into storage: " + inserted);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not abuse debug also. If the information provide no help for user to debug an unexpected error, do not print it.

boolean isNowIdle = !cpu.isBusy();

if (inserted == craftedAmount && isNowIdle) {
return MethodResult.of(true, "Successfully force completed CPU: " + cpuName

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't return such complex string. return an easy to read & use constant string.

ResourceKey resource = status.info().resource();

// Insert the completed items into storage first
long inserted = storage.insert(resource, amount, Action.EXECUTE, Actor.EMPTY);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you just insert something without take anything?

@SirEndii

SirEndii commented Sep 8, 2025

Copy link
Copy Markdown
Member

I think we can close this AI generated garbage

@SirEndii SirEndii closed this Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants