From a1e42e6f8e01c5caa4c55878500da406c48dae0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 5 Apr 2015 13:37:17 +0200 Subject: [PATCH 1/4] Added tooltip to prints that serve as beacon prints, to make the recipe self-explanatory when viewed in NEI. Added some more notifications: one for when the class transformer errors in general, one if SimpleComponent injection fails. --- .../assets/opencomputers/lang/en_US.lang | 3 +++ src/main/scala/li/cil/oc/Localization.scala | 6 ++++++ .../scala/li/cil/oc/common/EventHandler.scala | 7 +++++++ .../li/cil/oc/common/asm/ClassTransformer.scala | 15 ++++++++++++--- src/main/scala/li/cil/oc/common/block/Print.scala | 4 ++++ .../scala/li/cil/oc/common/recipe/Recipes.scala | 7 ++++++- 6 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main/resources/assets/opencomputers/lang/en_US.lang b/src/main/resources/assets/opencomputers/lang/en_US.lang index 238f1d85f..af4f3558a 100644 --- a/src/main/resources/assets/opencomputers/lang/en_US.lang +++ b/src/main/resources/assets/opencomputers/lang/en_US.lang @@ -174,6 +174,8 @@ oc:gui.Chat.WarningPower=No supported power providing mod available. Computers, oc:gui.Chat.TextureName=§7Texture name is §a%s§f. oc:gui.Chat.WarningProjectRed=You are using a version of Project: Red that is incompatible with OpenComputers. Try updating your version of Project: Red. oc:gui.Chat.WarningRecipes=There were errors loading one or more recipes. Some items may be uncraftable. Please check your log file for more information. +oc:gui.Chat.WarningClassTransformer=There were §cerrors§f running the class transformer. Please report this, together with your (full!) FML §alatest.log§f/§afml-server-latest.log§f logfile, thank you! +oc:gui.Chat.WarningSimpleComponent=An addon (yours?) using the §aSimpleComponent§f interface did §esomething wrong§f. Component logic could not be injected. Please check your log file for more information. oc:gui.Error.ComponentOverflow=Too many components connected to the computer. oc:gui.Error.InternalError=Internal error, please see the log file. This is probably a bug. oc:gui.Error.NoCPU=No CPU is installed in the computer. @@ -225,6 +227,7 @@ oc:tooltip.Adapter=Used to control non-component blocks, such as vanilla blocks oc:tooltip.ALU=Adds numbers so you don't have to. It might be better this way. oc:tooltip.Analyzer=Used to display information about blocks, such as their §faddress§7 and §fcomponent name§7.[nl] Also displays the error that caused a computer to crash if it did not shut down normally. oc:tooltip.Assembler=Allows constructing robots and other devices from a number of different computer parts. +oc:tooltip.BeaconBase=§8Works as a beacon base. oc:tooltip.Cable=A cheap way of connecting blocks. oc:tooltip.Capacitor=Stores energy for later use. Can be filled and emptied very quickly. oc:tooltip.CardBase=As the name indicates, this is the basic building block for all expansion cards. diff --git a/src/main/scala/li/cil/oc/Localization.scala b/src/main/scala/li/cil/oc/Localization.scala index 754a930fd..846cd47a6 100644 --- a/src/main/scala/li/cil/oc/Localization.scala +++ b/src/main/scala/li/cil/oc/Localization.scala @@ -85,6 +85,10 @@ object Localization { def WarningRecipes = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.WarningRecipes")) + def WarningClassTransformer = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.WarningClassTransformer")) + + def WarningSimpleComponent = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.WarningSimpleComponent")) + def InfoNewVersion(version: String) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.NewVersion", version)) def TextureName(name: String) = new ChatComponentText("§aOpenComputers§f: ").appendSibling(localizeLater("gui.Chat.TextureName", name)) @@ -140,6 +144,8 @@ object Localization { def Materials = localizeImmediately("tooltip.Materials") def Tier(tier: Int) = localizeImmediately("tooltip.Tier", tier.toString) + + def BeaconBase = localizeImmediately("tooltip.BeaconBase") } } diff --git a/src/main/scala/li/cil/oc/common/EventHandler.scala b/src/main/scala/li/cil/oc/common/EventHandler.scala index e115773d5..ea38c731c 100644 --- a/src/main/scala/li/cil/oc/common/EventHandler.scala +++ b/src/main/scala/li/cil/oc/common/EventHandler.scala @@ -14,6 +14,7 @@ import li.cil.oc.api.Network import li.cil.oc.api.detail.ItemInfo import li.cil.oc.client.renderer.PetRenderer import li.cil.oc.client.{PacketSender => ClientPacketSender} +import li.cil.oc.common.asm.ClassTransformer import li.cil.oc.common.item.data.MicrocontrollerData import li.cil.oc.common.item.data.RobotData import li.cil.oc.common.item.data.TabletData @@ -160,6 +161,12 @@ object EventHandler { if (Recipes.hadErrors) { player.addChatMessage(Localization.Chat.WarningRecipes) } + if (ClassTransformer.hadErrors) { + player.addChatMessage(Localization.Chat.WarningClassTransformer) + } + if (ClassTransformer.hadSimpleComponentErrors) { + player.addChatMessage(Localization.Chat.WarningSimpleComponent) + } ServerPacketSender.sendPetVisibility(None, Some(player)) // Do update check in local games and for OPs. if (!Mods.VersionChecker.isAvailable && (!MinecraftServer.getServer.isDedicatedServer || MinecraftServer.getServer.getConfigurationManager.func_152596_g(player.getGameProfile))) { diff --git a/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala b/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala index 6561ec357..f34c54d07 100644 --- a/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala +++ b/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala @@ -33,9 +33,13 @@ object ObfNames { final val Method_writeToNBT = Array("writeToNBT", "func_145841_b") } +object ClassTransformer { + var hadErrors = true + var hadSimpleComponentErrors = true +} + class ClassTransformer extends IClassTransformer { private val loader = classOf[ClassTransformer].getClassLoader.asInstanceOf[LaunchClassLoader] - private val log = LogManager.getLogger("OpenComputers") override def transform(name: String, transformedName: String, basicClass: Array[Byte]): Array[Byte] = { @@ -73,7 +77,7 @@ class ClassTransformer extends IClassTransformer { // Inject available interfaces where requested. if (classNode.visibleAnnotations != null) { def injectInterface(annotation: AnnotationNode): Unit = { - val values = annotation.values.grouped(2).map(buffer => buffer(0) -> buffer(1)).toMap + val values = annotation.values.grouped(2).map(buffer => buffer.head -> buffer.last).toMap (values.get("value"), values.get("modid")) match { case (Some(interfaceName: String), Some(modid: String)) => Mods.All.find(_.id == modid) match { @@ -93,6 +97,7 @@ class ClassTransformer extends IClassTransformer { else { log.warn(s"Missing implementations for interface $interfaceName, skipping injection.") missing.foreach(log.warn) + ClassTransformer.hadErrors = true } } } @@ -113,7 +118,7 @@ class ClassTransformer extends IClassTransformer { } classNode.visibleAnnotations.find(_.desc == "Lli/cil/oc/common/asm/Injectable$InterfaceList;") match { case Some(annotation) => - val values = annotation.values.grouped(2).map(buffer => buffer(0) -> buffer(1)).toMap + val values = annotation.values.grouped(2).map(buffer => buffer.head -> buffer.last).toMap values.get("value") match { case Some(interfaceList: java.lang.Iterable[AnnotationNode]@unchecked) => interfaceList.foreach(injectInterface) @@ -135,6 +140,7 @@ class ClassTransformer extends IClassTransformer { catch { case e: Throwable => log.warn(s"Failed injecting component logic into class $name.", e) + ClassTransformer.hadSimpleComponentErrors = true } } } @@ -220,6 +226,7 @@ class ClassTransformer extends IClassTransformer { catch { case t: Throwable => log.warn("Something went wrong!", t) + ClassTransformer.hadErrors = true basicClass } } @@ -233,10 +240,12 @@ class ClassTransformer extends IClassTransformer { } else { log.warn(s"Failed patching ${classNode.name}.${methodNames(0)}, injection point not found.") + ClassTransformer.hadErrors = true None } case _ => log.warn(s"Failed patching ${classNode.name}.${methodNames(0)}, method not found.") + ClassTransformer.hadErrors = true None } } diff --git a/src/main/scala/li/cil/oc/common/block/Print.scala b/src/main/scala/li/cil/oc/common/block/Print.scala index 6e8e4491f..4f65738a0 100644 --- a/src/main/scala/li/cil/oc/common/block/Print.scala +++ b/src/main/scala/li/cil/oc/common/block/Print.scala @@ -5,6 +5,7 @@ import java.util.Random import cpw.mods.fml.relauncher.Side import cpw.mods.fml.relauncher.SideOnly +import li.cil.oc.Localization import li.cil.oc.Settings import li.cil.oc.common.item.data.PrintData import li.cil.oc.common.tileentity @@ -49,6 +50,9 @@ class Print(protected implicit val tileTag: ClassTag[tileentity.Print]) extends override protected def tooltipBody(metadata: Int, stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean): Unit = { super.tooltipBody(metadata, stack, player, tooltip, advanced) val data = new PrintData(stack) + if (data.isBeaconBase) { + tooltip.add(Localization.Tooltip.BeaconBase) + } data.tooltip.foreach(s => tooltip.addAll(s.lines.toIterable)) } 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 a5723fb13..d630348db 100644 --- a/src/main/scala/li/cil/oc/common/recipe/Recipes.scala +++ b/src/main/scala/li/cil/oc/common/recipe/Recipes.scala @@ -10,6 +10,7 @@ import li.cil.oc._ import li.cil.oc.common.block.SimpleBlock import li.cil.oc.common.init.Items import li.cil.oc.common.item.SimpleItem +import li.cil.oc.common.item.data.PrintData import li.cil.oc.integration.Mods import li.cil.oc.integration.util.NEI import li.cil.oc.util.Color @@ -188,6 +189,10 @@ object Recipes { } // Print beaconification. + val beaconPrint = print.createItemStack(1) + val printData = new PrintData(beaconPrint) + printData.isBeaconBase = true + printData.save(beaconPrint) for (block <- Array( net.minecraft.init.Blocks.iron_block, net.minecraft.init.Blocks.gold_block, @@ -195,7 +200,7 @@ object Recipes { net.minecraft.init.Blocks.diamond_block )) { GameRegistry.addRecipe(new ExtendedShapelessOreRecipe( - print.createItemStack(1), + beaconPrint, print.createItemStack(1), new ItemStack(block))) } } From a213a07c7d71ac876cc065f2c6d86ba8ba013498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 5 Apr 2015 13:41:44 +0200 Subject: [PATCH 2/4] Got rid of another non-API reference in the AE2 integration. --- .../cil/oc/integration/appeng/DriverExportBus.scala | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala b/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala index bf4860703..d53a711e5 100644 --- a/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala +++ b/src/main/scala/li/cil/oc/integration/appeng/DriverExportBus.scala @@ -7,7 +7,6 @@ import appeng.api.config.Settings import appeng.api.config.Upgrades import appeng.api.networking.security.MachineSource import appeng.parts.automation.PartExportBus -import appeng.util.Platform import li.cil.oc.api.driver import li.cil.oc.api.driver.NamedBlock import li.cil.oc.api.internal.Database @@ -26,17 +25,17 @@ import net.minecraftforge.common.util.ForgeDirection import scala.collection.convert.WrapAsScala._ object DriverExportBus extends driver.Block { - type ExportBusTile = appeng.api.parts.IPartHost + type AETileType = appeng.api.parts.IPartHost override def worksWith(world: World, x: Int, y: Int, z: Int) = world.getTileEntity(x, y, z) match { - case container: ExportBusTile => ForgeDirection.VALID_DIRECTIONS.map(container.getPart).exists(_.isInstanceOf[PartExportBus]) + case container: AETileType => ForgeDirection.VALID_DIRECTIONS.map(container.getPart).exists(_.isInstanceOf[PartExportBus]) case _ => false } - override def createEnvironment(world: World, x: Int, y: Int, z: Int) = new Environment(world.getTileEntity(x, y, z).asInstanceOf[ExportBusTile]) + override def createEnvironment(world: World, x: Int, y: Int, z: Int) = new Environment(world.getTileEntity(x, y, z).asInstanceOf[AETileType]) - class Environment(host: ExportBusTile) extends ManagedTileEntityEnvironment[ExportBusTile](host, "me_exportbus") with NamedBlock { + class Environment(host: AETileType) extends ManagedTileEntityEnvironment[AETileType](host, "me_exportbus") with NamedBlock { override def preferredName = "me_exportbus" override def priority = 0 @@ -117,7 +116,7 @@ object DriverExportBus extends driver.Block { is.stackSize = count if (InventoryUtils.insertIntoInventorySlot(is, inventory, Option(side.getOpposite), targetSlot, count, simulate = true)) { ais.setStackSize(count - is.stackSize) - val eais = Platform.poweredExtraction(export.getProxy.getEnergy, itemStorage, ais, source) + val eais = AEApi.instance.storage.poweredExtraction(export.getProxy.getEnergy, itemStorage, ais, source) if (eais != null) { val eis = eais.getItemStack count -= eis.stackSize @@ -141,4 +140,5 @@ object DriverExportBus extends driver.Block { } } } + } From 7fd0ddac2226116844bc0570dc695933912d8db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 5 Apr 2015 13:56:55 +0200 Subject: [PATCH 3/4] Applying Forestry individual converter to item stacks, not just to stuff in analyzer/bee house/apiary/alveary. --- .../li/cil/oc/common/asm/ClassTransformer.scala | 4 ++-- .../forestry/ConverterItemStack.scala | 17 +++++++++++++++++ .../oc/integration/forestry/ModForestry.scala | 1 + 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/main/scala/li/cil/oc/integration/forestry/ConverterItemStack.scala diff --git a/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala b/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala index f34c54d07..fb8235ec8 100644 --- a/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala +++ b/src/main/scala/li/cil/oc/common/asm/ClassTransformer.scala @@ -34,8 +34,8 @@ object ObfNames { } object ClassTransformer { - var hadErrors = true - var hadSimpleComponentErrors = true + var hadErrors = false + var hadSimpleComponentErrors = false } class ClassTransformer extends IClassTransformer { diff --git a/src/main/scala/li/cil/oc/integration/forestry/ConverterItemStack.scala b/src/main/scala/li/cil/oc/integration/forestry/ConverterItemStack.scala new file mode 100644 index 000000000..fd2e64f67 --- /dev/null +++ b/src/main/scala/li/cil/oc/integration/forestry/ConverterItemStack.scala @@ -0,0 +1,17 @@ +package li.cil.oc.integration.forestry + +import java.util + +import forestry.api.genetics.AlleleManager +import li.cil.oc.api.driver.Converter +import net.minecraft.item.ItemStack + +import scala.collection.convert.WrapAsScala._ + +object ConverterItemStack extends Converter { + override def convert(value: scala.Any, output: util.Map[AnyRef, AnyRef]): Unit = value match { + case stack: ItemStack if AlleleManager.alleleRegistry.isIndividual(stack) => + output += "individual" -> AlleleManager.alleleRegistry.getIndividual(stack) + case _ => + } +} diff --git a/src/main/scala/li/cil/oc/integration/forestry/ModForestry.scala b/src/main/scala/li/cil/oc/integration/forestry/ModForestry.scala index bc22e9c92..c23dc4e9a 100644 --- a/src/main/scala/li/cil/oc/integration/forestry/ModForestry.scala +++ b/src/main/scala/li/cil/oc/integration/forestry/ModForestry.scala @@ -10,6 +10,7 @@ object ModForestry extends ModProxy { override def initialize() { Driver.add(new ConverterIAlleles) Driver.add(new ConverterIIndividual) + Driver.add(ConverterItemStack) Driver.add(new DriverAnalyzer) Driver.add(new DriverBeeHouse) } From e24e2dfc766ed915a1d77248c6e4a1ff58c6c2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sun, 5 Apr 2015 14:23:13 +0200 Subject: [PATCH 4/4] Floppy disks can no longer be "formatted" by shift-rightclicking, added crafting as alternative. Simply recrafting a single floppy (no other items in the crafting grid) will now format it. Same for loot disk, they can be converted to normal floppies the same way. In general, this removes the "shift-right-click to remove NBT tag" functionality, so you also can't format HHDs like this anymore - use `rm /*` or such. If you notice any items that needed the old functionality (looked through the list, didn't see one), let me know. --- .../scala/li/cil/oc/common/init/Items.scala | 5 ---- .../li/cil/oc/common/item/Delegate.scala | 10 +------ .../cil/oc/common/recipe/ExtendedRecipe.scala | 28 ++++++++++++------- .../recipe/ExtendedShapedOreRecipe.scala | 2 +- .../recipe/ExtendedShapelessOreRecipe.scala | 2 +- .../li/cil/oc/common/recipe/Recipes.scala | 13 ++++++--- 6 files changed, 30 insertions(+), 30 deletions(-) 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)