From 28c504d342b3567c053c9f8dbbb43a6ad31dae2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 23 Dec 2013 19:17:01 +0100 Subject: [PATCH 1/3] added `sneaky` parameter to robot.swing, as discussed in #13 --- assets/opencomputers/lua/rom/lib/robot.lua | 12 ++++++------ li/cil/oc/server/component/Robot.scala | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/assets/opencomputers/lua/rom/lib/robot.lua b/assets/opencomputers/lua/rom/lib/robot.lua index 634af2563..f490e7779 100644 --- a/assets/opencomputers/lua/rom/lib/robot.lua +++ b/assets/opencomputers/lua/rom/lib/robot.lua @@ -117,19 +117,19 @@ function robot.durability() end -function robot.swing(side) +function robot.swing(side, sneaky) checkArg(1, side, "nil", "number") - return component.computer.swing(sides.front, side) + return component.computer.swing(sides.front, side, sneaky ~= nil and sneaky ~= false) end -function robot.swingUp(side) +function robot.swingUp(side, sneaky) checkArg(1, side, "nil", "number") - return component.computer.swing(sides.up, side) + return component.computer.swing(sides.up, side, sneaky ~= nil and sneaky ~= false) end -function robot.swingDown(side) +function robot.swingDown(side, sneaky) checkArg(1, side, "nil", "number") - return component.computer.swing(sides.down, side) + return component.computer.swing(sides.down, side, sneaky ~= nil and sneaky ~= false) end function robot.use(side, sneaky, duration) diff --git a/li/cil/oc/server/component/Robot.scala b/li/cil/oc/server/component/Robot.scala index 234da2607..b307c7f2b 100644 --- a/li/cil/oc/server/component/Robot.scala +++ b/li/cil/oc/server/component/Robot.scala @@ -324,6 +324,7 @@ class Robot(val robot: tileentity.Robot) extends Computer(robot) with RobotConte else { ForgeDirection.VALID_DIRECTIONS.filter(_ != facing.getOpposite).toIterable } + val sneaky = args.isBoolean(2) && args.checkBoolean(2) def triggerDelay(delay: Double = Settings.get.swingDelay) = { context.pause(delay) @@ -358,6 +359,8 @@ class Robot(val robot: tileentity.Robot) extends Computer(robot) with RobotConte for (side <- sides) { val player = robot.player(facing, side) + player.setSneaking(sneaky) + val (success, what) = Option(pick(player, Settings.get.swingRange)) match { case Some(hit) => hit.typeOfHit match { @@ -378,6 +381,8 @@ class Robot(val robot: tileentity.Robot) extends Computer(robot) with RobotConte else (false, "air") } } + + player.setSneaking(false) if (success) { return result(true, what) } From 22bcc5756eade2d7e2090be66bc2a89e84825e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 24 Dec 2013 12:58:47 +0100 Subject: [PATCH 2/3] moved example whitelist entries to comment so we default to using the blacklist as suggested in #19; better message when http api fails parsing binary data (see #21) --- li/cil/oc/server/component/WirelessNetworkCard.scala | 3 +++ reference.conf | 8 +++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/li/cil/oc/server/component/WirelessNetworkCard.scala b/li/cil/oc/server/component/WirelessNetworkCard.scala index faa7f7a99..a168cadce 100644 --- a/li/cil/oc/server/component/WirelessNetworkCard.scala +++ b/li/cil/oc/server/component/WirelessNetworkCard.scala @@ -12,6 +12,7 @@ import net.minecraft.server.MinecraftServer import net.minecraft.tileentity.TileEntity import scala.collection.convert.WrapAsScala._ import scala.language.implicitConversions +import java.nio.charset.MalformedInputException class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard { override val node = api.Network.newNode(this, Visibility.Network). @@ -87,6 +88,8 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard { catch { case e: FileNotFoundException => context.signal("http_response", address, Unit, "not found: " + Option(e.getMessage).getOrElse(e.toString)) + case _: MalformedInputException => + context.signal("http_response", address, Unit, "binary data not yet supported") case e: Throwable => context.signal("http_response", address, Unit, Option(e.getMessage).getOrElse(e.toString)) } diff --git a/reference.conf b/reference.conf index ebe66eeb2..957cda471 100644 --- a/reference.conf +++ b/reference.conf @@ -573,11 +573,9 @@ opencomputers { # blacklist is always applied, so if an entry is present in both the # whitelist and the blacklist, the blacklist will win. # All entries are regular expression patterns, but they will only be - # applied to the host name (domain) of a given URL. - whitelist: [ - "^gist\\.github\\.com$" - "^(:?www\\.)?pastebin\\.com$" - ] + # applied to the host name (domain) of a given URL. Examples: + # "^gist\\.github\\.com$", "^(:?www\\.)?pastebin\\.com$" + whitelist: [] } # Other settings that you might find useful to tweak. From b78bdef513b8cf59d935ccc8a087eead7728b14c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 24 Dec 2013 13:12:59 +0100 Subject: [PATCH 3/3] no longer using client side method for cable neighbor checking on server, fixes #23 --- li/cil/oc/common/block/Cable.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/li/cil/oc/common/block/Cable.scala b/li/cil/oc/common/block/Cable.scala index 49aba4dd8..774dcc772 100644 --- a/li/cil/oc/common/block/Cable.scala +++ b/li/cil/oc/common/block/Cable.scala @@ -94,7 +94,8 @@ object Cable { world.getBlockTileEntity(x + side.offsetX, y + side.offsetY, z + side.offsetZ) match { case robot: tileentity.RobotProxy => case host: SidedEnvironment => - if (host.canConnect(side.getOpposite)) { + val connects = if (host.getWorldObj.isRemote) host.canConnect(side.getOpposite) else host.sidedNode(side.getOpposite) != null + if (connects) { result |= side.flag } case host: Environment => result |= side.flag