diff --git a/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala b/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala index 93b29f145..84469859f 100644 --- a/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala +++ b/src/main/scala/li/cil/oc/client/renderer/PetRenderer.scala @@ -19,7 +19,11 @@ import scala.collection.mutable object PetRenderer { val hidden = mutable.Set.empty[String] - private val entitledPlayers = Map("Kethtar" ->(0.3, 0.9, 0.6)) + private val entitledPlayers = Map( + "Kethtar" -> (0.3, 0.9, 0.6), + "Jodarion" -> (1.0, 0.0, 0.0), + "DaKaTotal" -> (0.5, 0.7, 1.0) + ) private val petLocations = com.google.common.cache.CacheBuilder.newBuilder(). expireAfterAccess(5, TimeUnit.SECONDS). diff --git a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala index b658974c9..55a2011f0 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala @@ -189,6 +189,9 @@ class Robot extends traits.Computer with traits.PowerInformation with api.machin } assert(!isInvalid) } + else { + world.setBlockToAir(nx, ny, nz) + } created } finally { diff --git a/src/main/scala/li/cil/oc/server/driver/Registry.scala b/src/main/scala/li/cil/oc/server/driver/Registry.scala index 2e9b2abf4..6cf2b6fda 100644 --- a/src/main/scala/li/cil/oc/server/driver/Registry.scala +++ b/src/main/scala/li/cil/oc/server/driver/Registry.scala @@ -53,7 +53,7 @@ private[oc] object Registry extends api.detail.DriverAPI { def driverFor(world: World, x: Int, y: Int, z: Int) = blocks.filter(_.worksWith(world, x, y, z)) match { - case drivers if !drivers.isEmpty => new CompoundBlockDriver(drivers: _*) + case drivers if drivers.nonEmpty => new CompoundBlockDriver(drivers: _*) case _ => null } diff --git a/src/main/scala/li/cil/oc/server/network/ArgumentsImpl.scala b/src/main/scala/li/cil/oc/server/network/ArgumentsImpl.scala index 07f26a1dc..f26ea5d4a 100644 --- a/src/main/scala/li/cil/oc/server/network/ArgumentsImpl.scala +++ b/src/main/scala/li/cil/oc/server/network/ArgumentsImpl.scala @@ -18,6 +18,11 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { } } + def optAny(index: Int, default: AnyRef) = { + if (!isDefined(index)) default + else checkAny(index) + } + def checkBoolean(index: Int) = { checkIndex(index, "boolean") args(index) match { @@ -26,6 +31,11 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { } } + def optBoolean(index: Int, default: Boolean) = { + if (!isDefined(index)) default + else checkBoolean(index) + } + def checkDouble(index: Int) = { checkIndex(index, "number") args(index) match { @@ -34,6 +44,11 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { } } + def optDouble(index: Int, default: Double) = { + if (!isDefined(index)) default + else checkDouble(index) + } + def checkInteger(index: Int) = { checkIndex(index, "number") args(index) match { @@ -42,6 +57,11 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { } } + def optInteger(index: Int, default: Int) = { + if (!isDefined(index)) default + else checkInteger(index) + } + def checkString(index: Int) = { checkIndex(index, "string") args(index) match { @@ -51,6 +71,11 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { } } + def optString(index: Int, default: String) = { + if (!isDefined(index)) default + else checkString(index) + } + def checkByteArray(index: Int) = { checkIndex(index, "string") args(index) match { @@ -60,6 +85,11 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { } } + def optByteArray(index: Int, default: Array[Byte]) = { + if (!isDefined(index)) default + else checkByteArray(index) + } + def checkTable(index: Int) = { checkIndex(index, "table") args(index) match { @@ -70,6 +100,11 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { } } + def optTable(index: Int, default: Map[_, _]) = { + if (!isDefined(index)) default + else checkTable(index) + } + def isBoolean(index: Int) = index >= 0 && index < count && (args(index) match { case value: java.lang.Boolean => true @@ -111,6 +146,8 @@ class ArgumentsImpl(val args: Seq[AnyRef]) extends network.Arguments { case _ => false }) + private def isDefined(index: Int) = index >= 0 && index < args.length + private def checkIndex(index: Int, name: String) = if (index < 0) throw new IndexOutOfBoundsException() else if (args.length <= index) throw new IllegalArgumentException(