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) }