honor enableNanomachinePfx when false

also the distance check for nanomachine wireless comm was perhaps
not as intended. this change increases the range by correctly computing
the distance

closes #2505
This commit is contained in:
payonel 2018-10-10 00:38:26 -07:00
parent 1301ed8c3d
commit a5b6e3fec3
2 changed files with 2 additions and 2 deletions

View File

@ -65,7 +65,7 @@ class ControllerImpl(val player: EntityPlayer) extends Controller with WirelessE
override def receivePacket(packet: Packet, sender: WirelessEndpoint): Unit = { override def receivePacket(packet: Packet, sender: WirelessEndpoint): Unit = {
if (getLocalBuffer > 0 && commandDelay < 1 && !player.isDead) { if (getLocalBuffer > 0 && commandDelay < 1 && !player.isDead) {
val (dx, dy, dz) = ((sender.x + 0.5) - player.posX, (sender.y + 0.5) - player.posY, (sender.z + 0.5) - player.posZ) val (dx, dy, dz) = ((sender.x + 0.5) - player.posX, (sender.y + 0.5) - player.posY, (sender.z + 0.5) - player.posZ)
val dSquared = dx * dx + dy * dy + dz * dz val dSquared = Math.sqrt(dx * dx + dy * dy + dz * dz)
if (dSquared <= CommandRange) packet.data.headOption match { if (dSquared <= CommandRange) packet.data.headOption match {
case Some(header: Array[Byte]) if new String(header, Charsets.UTF_8) == "nanomachines" => case Some(header: Array[Byte]) if new String(header, Charsets.UTF_8) == "nanomachines" =>
val command = packet.data.drop(1).map { val command = packet.data.drop(1).map {

View File

@ -57,7 +57,7 @@ object PotionProvider extends ScalaProvider("c29e4eec-5a46-479a-9b3d-ad0f06da784
} }
override def update(): Unit = { override def update(): Unit = {
player.addPotionEffect(new PotionEffect(potion.id, Duration, amplifier(player))) player.addPotionEffect(new PotionEffect(potion.id, Duration, if (Settings.get.enableNanomachinePfx) amplifier(player) else -1))
} }
} }