<commit_before>package com.awesomesauce.minecraft.forge.openautomation.common.oc.baubles

import com.awesomesauce.minecraft.forge.openautomation.common.oc.baubles.item.MachineBaubleHost
import cpw.mods.fml.common.event.FMLInterModComms
import li.cil.oc.api
import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.driver.item.{Container, Memory, Processor}
import li.cil.oc.api.{Driver, Items}
import net.minecraft.inventory.IInventory
import net.minecraft.item.ItemStack
import net.minecraft.nbt.{NBTTagCompound, NBTTagList}


object BaubleAssembler {
  def validate(inv: IInventory): Array[AnyRef] = {
    var hasCPU = false
    var hasRAM = false
    var hasEEPROM = false
    for (i <- Range(0, inv.getSizeInventory)) {
      val item = inv.getStackInSlot(i)
      Driver.driverFor(item) match {
        case _: Memory => hasRAM = true
        case _: Processor => hasCPU = true
      }
      if (Items.get(item) == Items.get("eeprom"))
        hasEEPROM = true
    }
    if (!hasCPU) {
      return Array(java.lang.Boolean.FALSE, "Requires CPU.")
    }
    else if (!hasRAM) {
      return Array(java.lang.Boolean.FALSE, "Requires RAM.")
    }
    else if (!hasEEPROM) {
      return Array(java.lang.Boolean.FALSE, "Requires EEPROM.")
    }
    else if (complexity(inv) < maxComplexity(inv)) {
      return Array(java.lang.Boolean.TRUE, complexity(inv) + "/" + maxComplexity(inv) + " Complexity.")
    }
    else {
      return Array(java.lang.Boolean.FALSE, complexity(inv) + "/" + maxComplexity(inv) + " Complexity.")
    }
    Array[AnyRef](java.lang.Boolean.FALSE)
  }

  protected def complexity(inventory: IInventory) = {
    var acc = 0
    for (slot <- 1 until inventory.getSizeInventory) {
      val stack = inventory.getStackInSlot(slot)
      acc += (Option(api.Driver.driverFor(stack, hostClass)) match {
        case Some(driver: Processor) => 0 // CPUs are exempt, since they control the limit.
        case Some(driver: Container) => (1 + driver.tier(stack)) * 2
        case Some(driver) if driver.slot(stack) != "eeprom" => 1 + driver.tier(stack)
        case _ => 0
      })
    }
    acc
  }

  protected def hostClass: Class[_ <: EnvironmentHost] = classOf[MachineBaubleHost]

  def maxComplexity(inv: IInventory): Int = {
    if (selectRing(inv.getStackInSlot(0)))
      6
    else if (selectAmulet(inv.getStackInSlot(0)))
      10
    else if (selectBelt(inv.getStackInSlot(0)))
      20
    else
      0
  }

  def assemble(inventory: IInventory): Array[AnyRef] = {
    var stack: ItemStack = null
    if (selectRing(inventory.getStackInSlot(0))) {
      stack = new ItemStack(OpenAutomationOCBaubles.baubleRing)
    }
    else if (selectAmulet(inventory.getStackInSlot(0))) {
      stack = new ItemStack(OpenAutomationOCBaubles.baubleAmulet)
    }
    else if (selectBelt(inventory.getStackInSlot(0))) {
      stack = new ItemStack(OpenAutomationOCBaubles.baubleBelt)
    }
    val items = new NBTTagList
    for (i <- 1 until inventory.getSizeInventory) {
      items.appendTag(inventory.getStackInSlot(i).writeToNBT(new NBTTagCompound))
    }
    Array[AnyRef](stack, 500)
  }

  def selectRing(stack: ItemStack) = stack.getItem == OpenAutomationOCBaubles.baubleRingBase

  def selectAmulet(stack: ItemStack) = stack.getItem == OpenAutomationOCBaubles.baubleAmuletBase

  def selectBelt(stack: ItemStack) = stack.getItem == OpenAutomationOCBaubles.baubleBeltBase

  def register() = {

    val upgradeSlot1 = new NBTTagCompound
    upgradeSlot1.setInteger("tier", 0)
    val upgradeSlot2 = new NBTTagCompound
    upgradeSlot2.setInteger("tier", 1)
    val upgradeSlot3 = new NBTTagCompound
    upgradeSlot3.setInteger("tier", 2)
    val componentSlotCard1 = new NBTTagCompound
    componentSlotCard1.setInteger("tier", 0)
    componentSlotCard1.setString("type", "card")
    val componentSlotCard2 = new NBTTagCompound
    componentSlotCard2.setInteger("tier", 1)
    componentSlotCard2.setString("type", "card")
    val componentSlotCPU2 = new NBTTagCompound
    componentSlotCPU2.setInteger("tier", 1)
    componentSlotCPU2.setString("type", "cpu")<commit_msg>This ain't gonna end well. - part 2<commit_after>package com.awesomesauce.minecraft.forge.openautomation.common.oc.baubles

import com.awesomesauce.minecraft.forge.openautomation.common.oc.baubles.item.MachineBaubleHost
import cpw.mods.fml.common.event.FMLInterModComms
import li.cil.oc.api
import li.cil.oc.api.driver.EnvironmentHost
import li.cil.oc.api.driver.item.{Container, Memory, Processor}
import li.cil.oc.api.{Driver, Items}
import net.minecraft.inventory.IInventory
import net.minecraft.item.ItemStack
import net.minecraft.nbt.{NBTTagCompound, NBTTagList}


object BaubleAssembler {
  def validate(inv: IInventory): Array[AnyRef] = {
    var hasCPU = false
    var hasRAM = false
    var hasEEPROM = false
    for (i <- Range(0, inv.getSizeInventory)) {
      val item = inv.getStackInSlot(i)
      Driver.driverFor(item) match {
        case _: Memory => hasRAM = true
        case _: Processor => hasCPU = true
      }
      if (Items.get(item) == Items.get("eeprom"))
        hasEEPROM = true
    }
    if (!hasCPU) {
      return Array(java.lang.Boolean.FALSE, "Requires CPU.")
    }
    else if (!hasRAM) {
      return Array(java.lang.Boolean.FALSE, "Requires RAM.")
    }
    else if (!hasEEPROM) {
      return Array(java.lang.Boolean.FALSE, "Requires EEPROM.")
    }
    else if (complexity(inv) < maxComplexity(inv)) {
      return Array(java.lang.Boolean.TRUE, complexity(inv) + "/" + maxComplexity(inv) + " Complexity.")
    }
    else {
      return Array(java.lang.Boolean.FALSE, complexity(inv) + "/" + maxComplexity(inv) + " Complexity.")
    }
    Array[AnyRef](java.lang.Boolean.FALSE)
  }

  protected def complexity(inventory: IInventory) = {
    var acc = 0
    for (slot <- 1 until inventory.getSizeInventory) {
      val stack = inventory.getStackInSlot(slot)
      acc += (Option(api.Driver.driverFor(stack, hostClass)) match {
        case Some(driver: Processor) => 0 // CPUs are exempt, since they control the limit.
        case Some(driver: Container) => (1 + driver.tier(stack)) * 2
        case Some(driver) if driver.slot(stack) != "eeprom" => 1 + driver.tier(stack)
        case _ => 0
      })
    }
    acc
  }

  protected def hostClass: Class[_ <: EnvironmentHost] = classOf[MachineBaubleHost]

  def maxComplexity(inv: IInventory): Int = {
    if (selectRing(inv.getStackInSlot(0)))
      6
    else if (selectAmulet(inv.getStackInSlot(0)))
      10
    else if (selectBelt(inv.getStackInSlot(0)))
      20
    else
      0
  }

  def assemble(inventory: IInventory): Array[AnyRef] = {
    var stack: ItemStack = null
    if (selectRing(inventory.getStackInSlot(0))) {
      stack = new ItemStack(OpenAutomationOCBaubles.baubleRing)
    }
    else if (selectAmulet(inventory.getStackInSlot(0))) {
      stack = new ItemStack(OpenAutomationOCBaubles.baubleAmulet)
    }
    else if (selectBelt(inventory.getStackInSlot(0))) {
      stack = new ItemStack(OpenAutomationOCBaubles.baubleBelt)
    }
    val items = new NBTTagList
    for (i <- 1 until inventory.getSizeInventory) {
      items.appendTag(inventory.getStackInSlot(i).writeToNBT(new NBTTagCompound))
    }
    Array[AnyRef](stack, Integer.valueOf(500))
  }

  def selectRing(stack: ItemStack) = stack.getItem == OpenAutomationOCBaubles.baubleRingBase

  def selectAmulet(stack: ItemStack) = stack.getItem == OpenAutomationOCBaubles.baubleAmuletBase

  def selectBelt(stack: ItemStack) = stack.getItem == OpenAutomationOCBaubles.baubleBeltBase

  def register() = {

    val upgradeSlot1 = new NBTTagCompound
    upgradeSlot1.setInteger("tier", 0)
    val upgradeSlot2 = new NBTTagCompound
    upgradeSlot2.setInteger("tier", 1)
    val upgradeSlot3 = new NBTTagCompound
    upgradeSlot3.setInteger("tier", 2)
    val componentSlotCard1 = new NBTTagCompound
    componentSlotCard1.setInteger("tier", 0)
    componentSlotCard1.setString("type", "card")
    val componentSlotCard2 = new NBTTagCompound
    componentSlotCard2.setInteger("tier", 1)
    componentSlotCard2.setString("type", "card")
    val componentSlotCPU2 = new NBTTagCompound
    componentSlotCPU2.setInteger("tier", 1)
    componentSlotCPU2.setString("type", "cpu")
{'fraction_non_alphanumeric': 0.11794685111030215, 'fraction_numerical': 0.011042349229462444, 'mean_word_length': 3.5763464741810105, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1469642', 'n_tokens_mistral': 2857, 'n_tokens_neox': 2721, 'n_words': 534}