From e9b49e292f6f5b0f583065fedfc1b7718ad69439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 29 Jul 2014 14:23:18 +0200 Subject: [PATCH] Improved raytracing used for robot placement/interaction checks some and added range limit (so stuff like buckets can only be used in adjacent blocks, e.g.) --- .../scala/li/cil/oc/server/component/robot/Player.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/scala/li/cil/oc/server/component/robot/Player.scala b/src/main/scala/li/cil/oc/server/component/robot/Player.scala index 2b96628c7..ce03cc466 100644 --- a/src/main/scala/li/cil/oc/server/component/robot/Player.scala +++ b/src/main/scala/li/cil/oc/server/component/robot/Player.scala @@ -52,6 +52,8 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta override def getDisplayName = robot.name + theItemInWorldManager.setBlockReachDistance(1) + // ----------------------------------------------------------------------- // def updatePositionAndRotation(facing: ForgeDirection, side: ForgeDirection) { @@ -59,9 +61,9 @@ class Player(val robot: tileentity.Robot) extends FakePlayer(robot.world.asInsta this.side = side // Slightly offset in robot's facing to avoid glitches (e.g. Portal Gun). val direction = Vec3.createVectorHelper( - facing.offsetX + side.offsetX * 0.5 + robot.facing.offsetX * 0.01, - facing.offsetY + side.offsetY * 0.5 + robot.facing.offsetY * 0.01, - facing.offsetZ + side.offsetZ * 0.5 + robot.facing.offsetZ * 0.01).normalize() + facing.offsetX + side.offsetX + robot.facing.offsetX * 0.01, + facing.offsetY + side.offsetY + robot.facing.offsetY * 0.01, + facing.offsetZ + side.offsetZ + robot.facing.offsetZ * 0.01).normalize() val yaw = Math.toDegrees(-Math.atan2(direction.xCoord, direction.zCoord)).toFloat val pitch = Math.toDegrees(-Math.atan2(direction.yCoord, Math.sqrt((direction.xCoord * direction.xCoord) + (direction.zCoord * direction.zCoord)))).toFloat * 0.99f setLocationAndAngles(robot.x + 0.5, robot.y, robot.z + 0.5, yaw, pitch)