From b718f22c9cc549122fa2cd2e44571c68f772a887 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 22 Jul 2014 16:48:27 +0200 Subject: [PATCH] Added an HDD to tablet for testing. --- build.properties | 2 +- .../scala/li/cil/oc/common/item/Tablet.scala | 25 ++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/build.properties b/build.properties index 119683e28..788ac383a 100644 --- a/build.properties +++ b/build.properties @@ -3,5 +3,5 @@ forge.version=9.11.1.964 oc.version=1.3.2 oc.subversion=dev ccl.version=1.0.0.62 -fmp.version=1.0.0.250 +fmp.version=1.0.1.268 maven.url=file:///var/www/users/fnuecke/maven.cil.li \ No newline at end of file diff --git a/src/main/scala/li/cil/oc/common/item/Tablet.scala b/src/main/scala/li/cil/oc/common/item/Tablet.scala index 0b58a0509..cd3a891d2 100644 --- a/src/main/scala/li/cil/oc/common/item/Tablet.scala +++ b/src/main/scala/li/cil/oc/common/item/Tablet.scala @@ -41,7 +41,7 @@ class Tablet(val parent: Delegator) extends Delegate { } } -class TabletWrapper(val stack: ItemStack, var holder: Entity) extends ComponentInventory with Container with Owner { +class TabletWrapper(var stack: ItemStack, var holder: Entity) extends ComponentInventory with Container with Owner { lazy val computer = if (holder.worldObj.isRemote) null else Machine.create(this) val items = Array( @@ -53,6 +53,7 @@ class TabletWrapper(val stack: ItemStack, var holder: Entity) extends ComponentI Option(api.Items.get("batteryUpgrade2").createItemStack(1)), Option(api.Items.get("navigationUpgrade").createItemStack(1)), Option(api.Items.get("openOS").createItemStack(1)), + Option(api.Items.get("hdd1").createItemStack(1)), Option(api.Items.get("wlanCard").createItemStack(1)) ) @@ -230,7 +231,7 @@ object Tablet extends Callable[TabletWrapper] with RemovalListener[String, Table private var currentHolder: Entity = _ - def get(stack: ItemStack, holder: Entity) = clientCache.synchronized { + def get(stack: ItemStack, holder: Entity) = (if (holder.worldObj.isRemote) clientCache else serverCache).synchronized { currentStack = stack currentHolder = holder if (!stack.hasTagCompound) { @@ -240,18 +241,14 @@ object Tablet extends Callable[TabletWrapper] with RemovalListener[String, Table stack.getTagCompound.setString(Settings.namespace + "tablet", UUID.randomUUID().toString) } val id = stack.getTagCompound.getString(Settings.namespace + "tablet") - if (holder.worldObj.isRemote) - clientCache.get(id, this) - else - serverCache.get(id, this) - } - - def get(stack: ItemStack) = clientCache.synchronized { - if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "tablet")) { - val id = stack.getTagCompound.getString(Settings.namespace + "tablet") - Option(clientCache.getIfPresent(id)) - } - else None + val wrapper = + if (holder.worldObj.isRemote) + clientCache.get(id, this) + else + serverCache.get(id, this) + wrapper.stack = stack + wrapper.holder = holder + wrapper } def call = {