From a74157cb3ea5340bf0e9882e64c79f0cee955c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Thu, 24 Jul 2014 15:25:04 +0200 Subject: [PATCH 1/2] Catch potential exceptions in tick handler for SimpleComponents. --- .../cil/oc/common/asm/SimpleComponentTickHandler.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java b/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java index 6fc7d7ba0..45fbd54a7 100644 --- a/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java +++ b/src/main/java/li/cil/oc/common/asm/SimpleComponentTickHandler.java @@ -8,10 +8,14 @@ import net.minecraft.tileentity.TileEntity; import java.util.ArrayList; import java.util.EnumSet; +import java.util.logging.Level; +import java.util.logging.Logger; // This class is used for adding simple components to the component network. // It is triggered from a validate call, and executed in the next update tick. public final class SimpleComponentTickHandler implements ITickHandler { + private static final Logger log = Logger.getLogger("OpenComputers"); + public static final ArrayList pending = new java.util.ArrayList(); public static final SimpleComponentTickHandler Instance = new SimpleComponentTickHandler(); @@ -54,7 +58,11 @@ public final class SimpleComponentTickHandler implements ITickHandler { pending.clear(); } for (Runnable runnable : adds) { - runnable.run(); + try { + runnable.run(); + } catch (Throwable t) { + log.log(Level.WARNING, "Error in scheduled tick action.", t); + } } } } From 1e3b4a23443bfe3761981070baea28c9c7c84a0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Thu, 24 Jul 2014 16:16:01 +0200 Subject: [PATCH 2/2] Added method to query the address of the screen a GPU is currently bound to. --- src/main/scala/li/cil/oc/server/component/GraphicsCard.scala | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala b/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala index c7d24aa30..f489ab7b8 100644 --- a/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala +++ b/src/main/scala/li/cil/oc/server/component/GraphicsCard.scala @@ -71,6 +71,9 @@ abstract class GraphicsCard extends component.ManagedComponent { } } + @Callback(doc = """function():string -- Get the address of the screen the GPU is currently bound to.""") + def getScreen(context: Context, args: Arguments): Array[AnyRef] = screen(s => result(s.node.address)) + @Callback(direct = true, doc = """function():number, boolean -- Get the current background color and whether it's from the palette or not.""") def getBackground(context: Context, args: Arguments): Array[AnyRef] = screen(s => result(s.getBackgroundColor, s.isBackgroundFromPalette))