From 5f5a63203af175887b26afb9211ca1500fae8b7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 14 May 2017 21:53:35 +0200 Subject: [PATCH] 1.8.9 adjustments. --- .../oc/common/tileentity/MotionSensor.scala | 4 +++- .../oc/server/component/MotionSensor.scala | 24 ++++++++++--------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala b/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala index fdfd2ee06..9d09d5d0d 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/MotionSensor.scala @@ -11,7 +11,9 @@ class MotionSensor extends traits.Environment with traits.Tickable { override def updateEntity() { super.updateEntity() - motionSensor.update() + if (isServer) { + motionSensor.update() + } } override def readFromNBTForServer(nbt: NBTTagCompound) { diff --git a/src/main/scala/li/cil/oc/server/component/MotionSensor.scala b/src/main/scala/li/cil/oc/server/component/MotionSensor.scala index 9432a00b4..94bf2294e 100644 --- a/src/main/scala/li/cil/oc/server/component/MotionSensor.scala +++ b/src/main/scala/li/cil/oc/server/component/MotionSensor.scala @@ -91,7 +91,7 @@ class MotionSensor(val host: EnvironmentHost) extends prefab.ManagedEnvironment } } - private def sensorBounds = AxisAlignedBB.getBoundingBox( + private def sensorBounds = AxisAlignedBB.fromBounds( x + 0.5 - radius, y + 0.5 - radius, z + 0.5 - radius, x + 0.5 + radius, y + 0.5 + radius, z + 0.5 + radius) @@ -103,21 +103,23 @@ class MotionSensor(val host: EnvironmentHost) extends prefab.ManagedEnvironment // is pseudo-infrared driven (it only works for *living* entities, after // all), so I think it makes more sense for it to work in the dark, too. /* entity.getBrightness(0) > 0.2 && */ { - val origin = Vec3.createVectorHelper(x + 0.5, y + 0.5, z + 0.5) - val target = Vec3.createVectorHelper(entity.posX, entity.posY, entity.posZ) + var ox = x + 0.5 + var oy = y + 0.5 + var oz = z + 0.5 + val target = new Vec3(entity.posX, entity.posY, entity.posZ) // Start trace outside of this block. - if (entity.posX < x) origin.xCoord -= 0.75 - if (entity.posX > x + 1) origin.xCoord += 0.75 - if (entity.posY < y) origin.yCoord -= 0.75 - if (entity.posY > y + 1) origin.yCoord += 0.75 - if (entity.posZ < z) origin.zCoord -= 0.75 - if (entity.posZ > z + 1) origin.zCoord += 0.75 - world.rayTraceBlocks(origin, target) == null + if (entity.posX < x) ox -= 0.75 + if (entity.posX > x + 1) ox += 0.75 + if (entity.posY < y) oy -= 0.75 + if (entity.posY > y + 1) oy += 0.75 + if (entity.posZ < z) oz -= 0.75 + if (entity.posZ > z + 1) oz += 0.75 + world.rayTraceBlocks(new Vec3(ox, oy, oz), target) == null } private def sendSignal(entity: EntityLivingBase) { if (Settings.get.inputUsername) { - node.sendToReachable("computer.signal", "motion", Double.box(entity.posX - (x + 0.5)), Double.box(entity.posY - (y + 0.5)), Double.box(entity.posZ - (z + 0.5)), entity.getCommandSenderName) + node.sendToReachable("computer.signal", "motion", Double.box(entity.posX - (x + 0.5)), Double.box(entity.posY - (y + 0.5)), Double.box(entity.posZ - (z + 0.5)), entity.getName) } else { node.sendToReachable("computer.signal", "motion", Double.box(entity.posX - (x + 0.5)), Double.box(entity.posY - (y + 0.5)), Double.box(entity.posZ - (z + 0.5)))