diff --git a/src/main/scala/li/cil/oc/common/init/Items.scala b/src/main/scala/li/cil/oc/common/init/Items.scala index d656918a6..e6ac8bdd1 100644 --- a/src/main/scala/li/cil/oc/common/init/Items.scala +++ b/src/main/scala/li/cil/oc/common/init/Items.scala @@ -370,11 +370,6 @@ object Items extends ItemAPI { // v1.2.3 registerItem(new item.FloppyDisk(multi) { showInItemList = false - - override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer) = { - if (player.isSneaking) get("floppy").createItemStack(1) - else super.onItemRightClick(stack, world, player) - } }, "lootDisk") // v1.2.6 diff --git a/src/main/scala/li/cil/oc/common/item/Delegate.scala b/src/main/scala/li/cil/oc/common/item/Delegate.scala index 95f45035c..d50e5e7fa 100644 --- a/src/main/scala/li/cil/oc/common/item/Delegate.scala +++ b/src/main/scala/li/cil/oc/common/item/Delegate.scala @@ -46,15 +46,7 @@ trait Delegate { def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = false - def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = { - if (player.isSneaking) { - if (stack.hasTagCompound && stack.getTagCompound.hasKey(Settings.namespace + "data")) { - stack.setTagCompound(null) - player.swingItem() - } - } - stack - } + def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = stack def getItemUseAction(stack: ItemStack): EnumAction = EnumAction.none 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 cd58408a1..8eb8686e7 100644 --- a/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala +++ b/src/main/scala/li/cil/oc/common/recipe/ExtendedRecipe.scala @@ -16,6 +16,7 @@ import li.cil.oc.util.SideTracker import net.minecraft.init.Blocks import net.minecraft.inventory.InventoryCrafting import net.minecraft.item.ItemStack +import net.minecraft.item.crafting.IRecipe import net.minecraft.nbt.NBTTagCompound import scala.collection.convert.WrapAsScala._ @@ -29,6 +30,7 @@ object ExtendedRecipe { private lazy val navigationUpgrade = api.Items.get("navigationUpgrade") private lazy val linkedCard = api.Items.get("linkedCard") private lazy val floppy = api.Items.get("floppy") + private lazy val lootDisk = api.Items.get("lootDisk") private lazy val robot = api.Items.get("robot") private lazy val tablet = api.Items.get("tablet") private lazy val print = api.Items.get("print") @@ -40,7 +42,7 @@ object ExtendedRecipe { stack } - def addNBTToResult(craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = { + def addNBTToResult(recipe: IRecipe, craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = { if (api.Items.get(craftedStack) == navigationUpgrade) { Option(api.Driver.driverFor(craftedStack)).foreach(driver => for (slot <- 0 until inventory.getSizeInventory) { @@ -64,16 +66,22 @@ object ExtendedRecipe { } if (api.Items.get(craftedStack) == floppy) { - if (!craftedStack.hasTagCompound) { - craftedStack.setTagCompound(new NBTTagCompound()) + if (recipe.getRecipeSize == 1) { + // Formatting / loot to normal disk conversion. + craftedStack.setTagCompound(null) } - val nbt = craftedStack.getTagCompound - for (slot <- 0 until inventory.getSizeInventory) { - val stack = inventory.getStackInSlot(slot) - if (stack != null && api.Items.get(stack) == floppy && stack.hasTagCompound) { - val oldData = stack.getTagCompound - for (oldTagName <- oldData.func_150296_c().map(_.asInstanceOf[String])) { - nbt.setTag(oldTagName, oldData.getTag(oldTagName).copy()) + else { + if (!craftedStack.hasTagCompound) { + craftedStack.setTagCompound(new NBTTagCompound()) + } + val nbt = craftedStack.getTagCompound + for (slot <- 0 until inventory.getSizeInventory) { + val stack = inventory.getStackInSlot(slot) + if (stack != null && api.Items.get(stack) == floppy && stack.hasTagCompound) { + val oldData = stack.getTagCompound + for (oldTagName <- oldData.func_150296_c().map(_.asInstanceOf[String])) { + nbt.setTag(oldTagName, oldData.getTag(oldTagName).copy()) + } } } } diff --git a/src/main/scala/li/cil/oc/common/recipe/ExtendedShapedOreRecipe.scala b/src/main/scala/li/cil/oc/common/recipe/ExtendedShapedOreRecipe.scala index 3672d8ed7..552d82a9b 100644 --- a/src/main/scala/li/cil/oc/common/recipe/ExtendedShapedOreRecipe.scala +++ b/src/main/scala/li/cil/oc/common/recipe/ExtendedShapedOreRecipe.scala @@ -6,5 +6,5 @@ import net.minecraftforge.oredict.ShapedOreRecipe class ExtendedShapedOreRecipe(result: ItemStack, ingredients: AnyRef*) extends ShapedOreRecipe(result, ingredients: _*) { override def getCraftingResult(inventory: InventoryCrafting) = - ExtendedRecipe.addNBTToResult(super.getCraftingResult(inventory), inventory) + ExtendedRecipe.addNBTToResult(this, super.getCraftingResult(inventory), inventory) } diff --git a/src/main/scala/li/cil/oc/common/recipe/ExtendedShapelessOreRecipe.scala b/src/main/scala/li/cil/oc/common/recipe/ExtendedShapelessOreRecipe.scala index d94e04caa..afd700ff2 100644 --- a/src/main/scala/li/cil/oc/common/recipe/ExtendedShapelessOreRecipe.scala +++ b/src/main/scala/li/cil/oc/common/recipe/ExtendedShapelessOreRecipe.scala @@ -6,5 +6,5 @@ import net.minecraftforge.oredict.ShapelessOreRecipe class ExtendedShapelessOreRecipe(result: ItemStack, ingredients: AnyRef*) extends ShapelessOreRecipe(result, ingredients: _*) { override def getCraftingResult(inventory: InventoryCrafting) = - ExtendedRecipe.addNBTToResult(super.getCraftingResult(inventory), inventory) + ExtendedRecipe.addNBTToResult(this, super.getCraftingResult(inventory), inventory) } diff --git a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala index d630348db..99b6bc206 100644 --- a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala +++ b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala @@ -125,6 +125,7 @@ object Recipes { val navigationUpgrade = api.Items.get("navigationUpgrade") val mcu = api.Items.get("microcontroller") val floppy = api.Items.get("floppy") + val lootDisk = api.Items.get("lootDisk") val drone = api.Items.get("drone") val eeprom = api.Items.get("eeprom") val robot = api.Items.get("robot") @@ -203,6 +204,10 @@ object Recipes { beaconPrint, print.createItemStack(1), new ItemStack(block))) } + + // Floppy disk formatting. + GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(floppy.createItemStack(1), floppy.createItemStack(1))) + GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(floppy.createItemStack(1), lootDisk.createItemStack(1))) } catch { case e: Throwable => OpenComputers.log.error("Error parsing recipes, you may not be able to craft any items from this mod!", e) @@ -328,10 +333,10 @@ object Recipes { (inputs, inputCount).zipped.foreach((stacks, count) => stacks.foreach(stack => if (stack != null && count > 0) stack.stackSize = stack.getMaxStackSize min count)) inputs.padTo(2, null) - if (inputs(0) != null) { - for (input1 <- inputs(0)) { - if (inputs(1) != null) { - for (input2 <- inputs(1)) + if (inputs.head != null) { + for (input1 <- inputs.head) { + if (inputs.last != null) { + for (input2 <- inputs.last) gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, input2, output, duration, eu) } else gregtech.api.GregTech_API.sRecipeAdder.addAssemblerRecipe(input1, null, output, duration, eu)