From 9b45cf894ab4f37248f91fb21494f1330f3b5d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 27 Dec 2015 13:25:10 +0100 Subject: [PATCH] Handle disabled command blocks more gracefully in driver, closes #1575. --- .../oc/integration/vanilla/DriverCommandBlock.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.scala b/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.scala index 5fa5b5941..f7e2f31d1 100644 --- a/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.scala +++ b/src/main/scala/li/cil/oc/integration/vanilla/DriverCommandBlock.scala @@ -12,6 +12,7 @@ import li.cil.oc.util.ResultWrapper.result import net.minecraft.block.Block import net.minecraft.init.Blocks import net.minecraft.item.ItemStack +import net.minecraft.server.MinecraftServer import net.minecraft.tileentity.TileEntityCommandBlock import net.minecraft.world.World @@ -41,9 +42,13 @@ object DriverCommandBlock extends DriverTileEntity { @Callback(doc = "function():number -- Execute the currently set command. This has a slight delay to allow the command block to properly update.") def executeCommand(context: Context, args: Arguments): Array[AnyRef] = { context.pause(0.1) - val commandSender = tileEntity.func_145993_a - commandSender.func_145755_a(tileEntity.getWorldObj) - result(commandSender.func_145760_g, commandSender.func_145749_h.getUnformattedText) + if (!MinecraftServer.getServer.isCommandBlockEnabled) { + result(null, "command blocks are disabled") + } else { + val commandSender = tileEntity.func_145993_a + commandSender.func_145755_a(tileEntity.getWorldObj) + result(commandSender.func_145760_g, commandSender.func_145749_h.getUnformattedText) + } } }