From df461d1185a34a1f1098ce4b0115ecf49166e720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Tue, 30 Sep 2014 21:36:50 +0200 Subject: [PATCH] Fixed floppy disks losing their contents when recolored. --- .../cil/oc/common/recipe/ExtendedRecipe.scala | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala b/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala index 843a96482..4d6259b9c 100644 --- a/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala +++ b/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala @@ -7,7 +7,9 @@ import li.cil.oc.util.{Color, SideTracker} import li.cil.oc.{Settings, api} import net.minecraft.inventory.InventoryCrafting import net.minecraft.item.{Item, ItemStack} -import net.minecraft.nbt.NBTTagCompound +import net.minecraft.nbt.{NBTBase, NBTTagCompound} + +import scala.collection.convert.WrapAsScala._ object ExtendedRecipe { private lazy val navigationUpgrade = api.Items.get("navigationUpgrade") @@ -41,10 +43,18 @@ object ExtendedRecipe { val nbt = craftedStack.getTagCompound for (i <- 0 until inventory.getSizeInventory) { val stack = inventory.getStackInSlot(i) - if (stack != null) Color.findDye(stack) match { - case Some(oreDictName) => - nbt.setInteger(Settings.namespace + "color", Color.dyes.indexOf(oreDictName)) - case _ => + if (stack != null) { + Color.findDye(stack) match { + case Some(oreDictName) => + nbt.setInteger(Settings.namespace + "color", Color.dyes.indexOf(oreDictName)) + case _ => + } + if (api.Items.get(stack) == floppy && stack.hasTagCompound) { + val oldData = stack.getTagCompound + for (oldTag <- oldData.getTags.map(_.asInstanceOf[NBTBase])) { + nbt.setTag(oldTag.getName, oldTag.copy()) + } + } } } }