mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 01:39:36 -04:00
Fixed crafting of Lua BIOS and OpenOS floppy using "initialized" items (i.e. EEPROM or floppy that had been installed in a computer/disk drive before). Closes #1199.
This commit is contained in:
parent
6c7c28d550
commit
bc29a0b70d
@ -51,9 +51,8 @@ object ExtendedRecipe {
|
|||||||
def addNBTToResult(recipe: IRecipe, craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = {
|
def addNBTToResult(recipe: IRecipe, craftedStack: ItemStack, inventory: InventoryCrafting): ItemStack = {
|
||||||
if (api.Items.get(craftedStack) == navigationUpgrade) {
|
if (api.Items.get(craftedStack) == navigationUpgrade) {
|
||||||
Option(api.Driver.driverFor(craftedStack)).foreach(driver =>
|
Option(api.Driver.driverFor(craftedStack)).foreach(driver =>
|
||||||
for (slot <- 0 until inventory.getSizeInventory) {
|
for (stack <- getItems(inventory)) {
|
||||||
val stack = inventory.getStackInSlot(slot)
|
if (stack.getItem == net.minecraft.init.Items.filled_map) {
|
||||||
if (stack != null && stack.getItem == net.minecraft.init.Items.filled_map) {
|
|
||||||
// Store information of the map used for crafting in the result.
|
// Store information of the map used for crafting in the result.
|
||||||
val nbt = driver.dataTag(craftedStack)
|
val nbt = driver.dataTag(craftedStack)
|
||||||
nbt.setNewCompoundTag(Settings.namespace + "map", stack.writeToNBT)
|
nbt.setNewCompoundTag(Settings.namespace + "map", stack.writeToNBT)
|
||||||
@ -79,9 +78,8 @@ object ExtendedRecipe {
|
|||||||
if (recipe.getRecipeSize == 1) {
|
if (recipe.getRecipeSize == 1) {
|
||||||
// Formatting / loot to normal disk conversion, only keep coloring.
|
// Formatting / loot to normal disk conversion, only keep coloring.
|
||||||
val colorKey = Settings.namespace + "color"
|
val colorKey = Settings.namespace + "color"
|
||||||
for (slot <- 0 until inventory.getSizeInventory) {
|
for (stack <- getItems(inventory)) {
|
||||||
val stack = inventory.getStackInSlot(slot)
|
if (api.Items.get(stack) != null && (api.Items.get(stack) == floppy || api.Items.get(stack).name == "lootDisk") && stack.hasTagCompound) {
|
||||||
if (stack != null && api.Items.get(stack) != null && (api.Items.get(stack) == floppy || api.Items.get(stack).name == "lootDisk") && stack.hasTagCompound) {
|
|
||||||
val oldData = stack.getTagCompound
|
val oldData = stack.getTagCompound
|
||||||
if (oldData.hasKey(colorKey) && oldData.getInteger(colorKey) != Color.dyes.indexOf("lightGray")) {
|
if (oldData.hasKey(colorKey) && oldData.getInteger(colorKey) != Color.dyes.indexOf("lightGray")) {
|
||||||
nbt.setTag(colorKey, oldData.getTag(colorKey).copy())
|
nbt.setTag(colorKey, oldData.getTag(colorKey).copy())
|
||||||
@ -92,10 +90,10 @@ object ExtendedRecipe {
|
|||||||
craftedStack.setTagCompound(null)
|
craftedStack.setTagCompound(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (getItems(inventory).forall(api.Items.get(_) == floppy)) {
|
||||||
for (slot <- 0 until inventory.getSizeInventory) {
|
// Copy operation.
|
||||||
val stack = inventory.getStackInSlot(slot)
|
for (stack <- getItems(inventory)) {
|
||||||
if (stack != null && api.Items.get(stack) == floppy && stack.hasTagCompound) {
|
if (api.Items.get(stack) == floppy && stack.hasTagCompound) {
|
||||||
val oldData = stack.getTagCompound
|
val oldData = stack.getTagCompound
|
||||||
for (oldTagName <- oldData.func_150296_c().map(_.asInstanceOf[String])) {
|
for (oldTagName <- oldData.func_150296_c().map(_.asInstanceOf[String])) {
|
||||||
nbt.setTag(oldTagName, oldData.getTag(oldTagName).copy())
|
nbt.setTag(oldTagName, oldData.getTag(oldTagName).copy())
|
||||||
@ -111,7 +109,7 @@ object ExtendedRecipe {
|
|||||||
recipe.asInstanceOf[ExtendedShapelessOreRecipe].getInput.size == 2) {
|
recipe.asInstanceOf[ExtendedShapelessOreRecipe].getInput.size == 2) {
|
||||||
// First, copy old data.
|
// First, copy old data.
|
||||||
val data = new PrintData(craftedStack)
|
val data = new PrintData(craftedStack)
|
||||||
val inputs = (0 until inventory.getSizeInventory).map(inventory.getStackInSlot).filter(_ != null)
|
val inputs = getItems(inventory)
|
||||||
for (stack <- inputs) {
|
for (stack <- inputs) {
|
||||||
if (api.Items.get(stack) == print) {
|
if (api.Items.get(stack) == print) {
|
||||||
data.load(stack)
|
data.load(stack)
|
||||||
@ -158,13 +156,12 @@ object ExtendedRecipe {
|
|||||||
|
|
||||||
// EEPROM copying.
|
// EEPROM copying.
|
||||||
if (api.Items.get(craftedStack) == eeprom &&
|
if (api.Items.get(craftedStack) == eeprom &&
|
||||||
api.Items.get(craftedStack) != luaBios &&
|
craftedStack.stackSize == 2 &&
|
||||||
recipe.isInstanceOf[ExtendedShapelessOreRecipe] &&
|
recipe.isInstanceOf[ExtendedShapelessOreRecipe] &&
|
||||||
recipe.asInstanceOf[ExtendedShapelessOreRecipe].getInput != null &&
|
recipe.asInstanceOf[ExtendedShapelessOreRecipe].getInput != null &&
|
||||||
recipe.asInstanceOf[ExtendedShapelessOreRecipe].getInput.size == 2) breakable {
|
recipe.asInstanceOf[ExtendedShapelessOreRecipe].getInput.size == 2) breakable {
|
||||||
for (slot <- 0 until inventory.getSizeInventory) {
|
for (stack <- getItems(inventory)) {
|
||||||
val stack = inventory.getStackInSlot(slot)
|
if (api.Items.get(stack) == eeprom && stack.hasTagCompound) {
|
||||||
if (stack != null && api.Items.get(stack) == eeprom && stack.hasTagCompound) {
|
|
||||||
val copy = stack.getTagCompound.copy.asInstanceOf[NBTTagCompound]
|
val copy = stack.getTagCompound.copy.asInstanceOf[NBTTagCompound]
|
||||||
// Erase node address, just in case.
|
// Erase node address, just in case.
|
||||||
copy.getCompoundTag(Settings.namespace + "data").getCompoundTag("node").removeTag("address")
|
copy.getCompoundTag(Settings.namespace + "data").getCompoundTag("node").removeTag("address")
|
||||||
@ -183,10 +180,12 @@ object ExtendedRecipe {
|
|||||||
craftedStack
|
craftedStack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private def getItems(inventory: InventoryCrafting) = (0 until inventory.getSizeInventory).map(inventory.getStackInSlot).filter(_ != null)
|
||||||
|
|
||||||
private def recraft(craftedStack: ItemStack, inventory: InventoryCrafting, descriptor: ItemInfo, dataFactory: (ItemStack) => ItemDataWrapper) {
|
private def recraft(craftedStack: ItemStack, inventory: InventoryCrafting, descriptor: ItemInfo, dataFactory: (ItemStack) => ItemDataWrapper) {
|
||||||
if (api.Items.get(craftedStack) == descriptor) {
|
if (api.Items.get(craftedStack) == descriptor) {
|
||||||
// Find old Microcontroller.
|
// Find old Microcontroller.
|
||||||
(0 until inventory.getSizeInventory).map(inventory.getStackInSlot).find(api.Items.get(_) == descriptor) match {
|
getItems(inventory).find(api.Items.get(_) == descriptor) match {
|
||||||
case Some(oldMcu) =>
|
case Some(oldMcu) =>
|
||||||
val data = dataFactory(oldMcu)
|
val data = dataFactory(oldMcu)
|
||||||
|
|
||||||
@ -195,8 +194,7 @@ object ExtendedRecipe {
|
|||||||
data.components = data.components.diff(oldRom)
|
data.components = data.components.diff(oldRom)
|
||||||
|
|
||||||
// Insert new EEPROM.
|
// Insert new EEPROM.
|
||||||
for (slot <- 0 until inventory.getSizeInventory) {
|
for (stack <- getItems(inventory)) {
|
||||||
val stack = inventory.getStackInSlot(slot)
|
|
||||||
if (api.Items.get(stack) == eeprom) {
|
if (api.Items.get(stack) == eeprom) {
|
||||||
data.components :+= stack
|
data.components :+= stack
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package li.cil.oc.common.recipe
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack
|
||||||
|
import net.minecraftforge.oredict.ShapedOreRecipe
|
||||||
|
|
||||||
|
class NBTIgnoringShapedRecipe(result: ItemStack, recipe: AnyRef*) extends ShapedOreRecipe(result, recipe: _*) {
|
||||||
|
|
||||||
|
}
|
@ -7,7 +7,6 @@ import com.typesafe.config.ConfigValue
|
|||||||
import li.cil.oc.common.recipe.Recipes
|
import li.cil.oc.common.recipe.Recipes
|
||||||
import li.cil.oc.common.recipe.Recipes.RecipeException
|
import li.cil.oc.common.recipe.Recipes.RecipeException
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraftforge.fluids.FluidStack
|
|
||||||
import net.minecraftforge.oredict.OreDictionary
|
import net.minecraftforge.oredict.OreDictionary
|
||||||
|
|
||||||
import scala.collection.convert.WrapAsScala._
|
import scala.collection.convert.WrapAsScala._
|
||||||
|
@ -43,7 +43,7 @@ object RecipeHandler {
|
|||||||
shape += pattern.toString
|
shape += pattern.toString
|
||||||
input ++= ingredients
|
input ++= ingredients
|
||||||
}
|
}
|
||||||
if (input.size > 0 && output.stackSize > 0) {
|
if (input.nonEmpty && output.stackSize > 0) {
|
||||||
GameRegistry.addRecipe(new ExtendedShapedOreRecipe(output, shape ++ input: _*))
|
GameRegistry.addRecipe(new ExtendedShapedOreRecipe(output, shape ++ input: _*))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ object RecipeHandler {
|
|||||||
}
|
}
|
||||||
output.stackSize = Recipes.tryGetCount(recipe)
|
output.stackSize = Recipes.tryGetCount(recipe)
|
||||||
|
|
||||||
if (input.size > 0 && output.stackSize > 0) {
|
if (input.nonEmpty && output.stackSize > 0) {
|
||||||
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(output, input: _*))
|
GameRegistry.addRecipe(new ExtendedShapelessOreRecipe(output, input: _*))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -625,7 +625,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def processAddedComponents() {
|
private def processAddedComponents() {
|
||||||
if (addedComponents.size > 0) {
|
if (addedComponents.nonEmpty) {
|
||||||
for (component <- addedComponents) {
|
for (component <- addedComponents) {
|
||||||
if (component.canBeSeenFrom(node)) {
|
if (component.canBeSeenFrom(node)) {
|
||||||
_components.synchronized(_components += component.address -> component.name)
|
_components.synchronized(_components += component.address -> component.name)
|
||||||
@ -684,7 +684,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
else fs.load(SaveHandler.loadNBT(nbt, node.address + "_tmp"))
|
else fs.load(SaveHandler.loadNBT(nbt, node.address + "_tmp"))
|
||||||
})
|
})
|
||||||
|
|
||||||
if (state.size > 0 && isRunning && init()) try {
|
if (state.nonEmpty && isRunning && init()) try {
|
||||||
architecture.load(nbt)
|
architecture.load(nbt)
|
||||||
|
|
||||||
signals ++= nbt.getTagList("signals", NBT.TAG_COMPOUND).map((signalNbt: NBTTagCompound) => {
|
signals ++= nbt.getTagList("signals", NBT.TAG_COMPOUND).map((signalNbt: NBTTagCompound) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user