mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Added EEPROM cloning recipe (EEPROM + EEPROM -> 2x EEPROM with same data). If one is empty, the one with data is preferred. If both have data, the first one gets copied onto the second. Closes #756.
This commit is contained in:
parent
6bb2233cb8
commit
b13f319018
@ -15,6 +15,7 @@ import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
import scala.util.control.Breaks._
|
||||
|
||||
object ExtendedRecipe {
|
||||
private lazy val drone = api.Items.get("drone")
|
||||
@ -61,17 +62,28 @@ object ExtendedRecipe {
|
||||
val nbt = craftedStack.getTagCompound
|
||||
for (slot <- 0 until inventory.getSizeInventory) {
|
||||
val stack = inventory.getStackInSlot(slot)
|
||||
if (stack != null) {
|
||||
if (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())
|
||||
}
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (api.Items.get(craftedStack) == eeprom) breakable {
|
||||
for (slot <- 0 until inventory.getSizeInventory) {
|
||||
val stack = inventory.getStackInSlot(slot)
|
||||
if (stack != null && api.Items.get(stack) == eeprom && stack.hasTagCompound) {
|
||||
val copy = stack.getTagCompound.copy.asInstanceOf[NBTTagCompound]
|
||||
// Erase node address, just in case.
|
||||
copy.getCompoundTag(Settings.namespace + "data").getCompoundTag("node").removeTag("address")
|
||||
craftedStack.setTagCompound(copy)
|
||||
break()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recraftMCU(craftedStack, inventory, mcu)
|
||||
recraftMCU(craftedStack, inventory, drone)
|
||||
|
||||
|
@ -119,27 +119,41 @@ object Recipes {
|
||||
addRecipe(stack, recipes, name)
|
||||
}
|
||||
|
||||
// Recrafting operations.
|
||||
val navigationUpgrade = api.Items.get("navigationUpgrade")
|
||||
val mcu = api.Items.get("microcontroller")
|
||||
val floppy = api.Items.get("floppy")
|
||||
val drone = api.Items.get("drone")
|
||||
val eeprom = api.Items.get("eeprom")
|
||||
|
||||
// Navigation upgrade recrafting.
|
||||
val navigationUpgrade = api.Items.get("navigationUpgrade").createItemStack(1)
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(navigationUpgrade, navigationUpgrade, new ItemStack(net.minecraft.init.Items.filled_map, 1, OreDictionary.WILDCARD_VALUE)))
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(
|
||||
navigationUpgrade.createItemStack(1),
|
||||
navigationUpgrade.createItemStack(1), new ItemStack(net.minecraft.init.Items.filled_map, 1, OreDictionary.WILDCARD_VALUE)))
|
||||
|
||||
// Floppy disk coloring.
|
||||
val floppy = api.Items.get("floppy").createItemStack(1)
|
||||
for (dye <- Color.dyes) {
|
||||
val result = api.Items.get("floppy").createItemStack(1)
|
||||
val result = floppy.createItemStack(1)
|
||||
val tag = new NBTTagCompound()
|
||||
tag.setInteger(Settings.namespace + "color", Color.dyes.indexOf(dye))
|
||||
result.setTagCompound(tag)
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(result, floppy, dye))
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(result, floppy.createItemStack(1), dye))
|
||||
}
|
||||
|
||||
// Microcontroller recrafting.
|
||||
val mcu = api.Items.get("microcontroller").createItemStack(1)
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(mcu, mcu, api.Items.get("eeprom").createItemStack(1)))
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(
|
||||
mcu.createItemStack(1),
|
||||
mcu.createItemStack(1), eeprom.createItemStack(1)))
|
||||
|
||||
// Drone recrafting.
|
||||
val drone = api.Items.get("drone").createItemStack(1)
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(drone, drone, api.Items.get("eeprom").createItemStack(1)))
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(
|
||||
drone.createItemStack(1),
|
||||
drone.createItemStack(1), eeprom.createItemStack(1)))
|
||||
|
||||
// EEPROM copying via crafting.
|
||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(
|
||||
eeprom.createItemStack(2),
|
||||
eeprom.createItemStack(1), eeprom.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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user