mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'architecture-memory-fix' of https://github.com/Vexatos/OpenComputers into master-MC1.7.10
This commit is contained in:
commit
a69c09e4be
@ -17,7 +17,8 @@ public interface Memory extends Item {
|
|||||||
* This factor has to be interpreted by each individual architecture to fit
|
* This factor has to be interpreted by each individual architecture to fit
|
||||||
* its own memory needs. The actual values returned here should roughly be
|
* its own memory needs. The actual values returned here should roughly be
|
||||||
* equivalent to the item's tier. For example, the built-in memory modules
|
* equivalent to the item's tier. For example, the built-in memory modules
|
||||||
* provide 1 for tier one, 2 for tier 1.5, 3 for tier 2, etc.
|
* provide defaults of 192 for tier one, 256 for tier 1.5, 384 for tier 2, etc.
|
||||||
|
* Mind that those values may be changed in the config file.
|
||||||
*
|
*
|
||||||
* @param stack the item to get the provided memory for.
|
* @param stack the item to get the provided memory for.
|
||||||
* @return the amount of memory the specified component provides.
|
* @return the amount of memory the specified component provides.
|
||||||
|
@ -12,7 +12,9 @@ import net.minecraft.item.ItemStack
|
|||||||
object DriverMemory extends Item with api.driver.item.Memory with api.driver.item.CallBudget {
|
object DriverMemory extends Item with api.driver.item.Memory with api.driver.item.CallBudget {
|
||||||
override def amount(stack: ItemStack) =
|
override def amount(stack: ItemStack) =
|
||||||
Delegator.subItem(stack) match {
|
Delegator.subItem(stack) match {
|
||||||
case Some(memory: item.Memory) => memory.tier + 1
|
case Some(memory: item.Memory) =>
|
||||||
|
val sizes = Settings.get.ramSizes
|
||||||
|
Settings.get.ramSizes(memory.tier max 0 min (sizes.length - 1))
|
||||||
case _ => 0.0
|
case _ => 0.0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,13 +157,10 @@ abstract class NativeLuaArchitecture(val machine: api.machine.Machine) extends A
|
|||||||
memory > 0
|
memory > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private def memoryInBytes(components: java.lang.Iterable[ItemStack]) = components.foldLeft(0)((acc, stack) => acc + (Option(api.Driver.driverFor(stack)) match {
|
private def memoryInBytes(components: java.lang.Iterable[ItemStack]) = components.foldLeft(0.0)((acc, stack) => acc + (Option(api.Driver.driverFor(stack)) match {
|
||||||
case Some(driver: Memory) =>
|
case Some(driver: Memory) => driver.amount(stack) * 1024
|
||||||
val sizes = Settings.get.ramSizes
|
|
||||||
val tier = math.round(driver.amount(stack)).toInt - 1
|
|
||||||
sizes(tier max 0 min (sizes.length - 1)) * 1024
|
|
||||||
case _ => 0
|
case _ => 0
|
||||||
}))
|
})).toInt max 0 min 50000000
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
@ -102,13 +102,10 @@ class LuaJLuaArchitecture(val machine: api.machine.Machine) extends Architecture
|
|||||||
memory > 0
|
memory > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
private def memoryInBytes(components: java.lang.Iterable[ItemStack]) = components.foldLeft(0)((acc, stack) => acc + (Option(api.Driver.driverFor(stack)) match {
|
private def memoryInBytes(components: java.lang.Iterable[ItemStack]) = components.foldLeft(0.0)((acc, stack) => acc + (Option(api.Driver.driverFor(stack)) match {
|
||||||
case Some(driver: Memory) =>
|
case Some(driver: Memory) => driver.amount(stack) * 1024
|
||||||
val sizes = Settings.get.ramSizes
|
|
||||||
val tier = math.round(driver.amount(stack)).toInt - 1
|
|
||||||
sizes(tier max 0 min (sizes.length - 1)) * 1024
|
|
||||||
case _ => 0
|
case _ => 0
|
||||||
}))
|
})).toInt max 0 min 50000000
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user