Skip to content

Commit

Permalink
Fix AE2 Integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelotrio committed Dec 31, 2023
1 parent 44f59fb commit cec0bab
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions src/main/scala/li/cil/oc/integration/appeng/NetworkControl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,26 @@ object NetworkControl {
val status = new CraftingStatus()
Future {
try {
val job = future.get() // Make 100% sure we wait for this outside the scheduled closure.
EventHandler.scheduleServer(() => {
val link = craftingGrid.submitJob(job, Craftable.this, cpu, prioritizePower, source)
if (link != null) {
status.setLink(link)
links += link
}
else {
status.fail("missing resources?")
}
})
while (!future.isDone) {
Thread.sleep(10)
}

val job = future.get()

if (future.isCancelled) {
status.fail("missing resources")
} else {
EventHandler.scheduleServer(() => {
val link = craftingGrid.submitJob(job, Craftable.this, cpu, prioritizePower, source)
if (link != null) {
status.setLink(link)
links += link
}
else {
status.fail("missing resources?")
}
})
}
}
catch {
case e: Exception =>
Expand Down Expand Up @@ -365,6 +374,12 @@ object NetworkControl {
this.reason = s"request failed ($reason)"
}

@Callback(doc = "function():boolean -- Get whether the crafting request is currently computing.")
def isComputing(context: Context, args: Arguments): Array[AnyRef] = result(isComputing)

@Callback(doc = "function():boolean -- Get whether the crafting request has failed.")
def hasFailed(context: Context, args: Arguments): Array[AnyRef] = result(failed)

@Callback(doc = "function():boolean -- Get whether the crafting request has been canceled.")
def isCanceled(context: Context, args: Arguments): Array[AnyRef] = {
if (isComputing) return result(false, "computing")
Expand Down

0 comments on commit cec0bab

Please sign in to comment.