Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into bc7

This commit is contained in:
Florian Nücke 2015-06-12 00:11:04 +02:00
commit c92dfe413c
20 changed files with 44 additions and 35 deletions

View File

@ -208,7 +208,7 @@ opencomputers {
# can reconfigure any CPU to use the Lua 5.3 architecture. This is
# not enabled by default for the time being, because it needs some
# more stability testing.
enableLua53: false
enableLua53: true
# The sizes of the six levels of RAM, in kilobytes. This list must
# contain exactly six entries, or it will be ignored. Note that while

View File

@ -2,7 +2,7 @@
![It's over 9000.](oredict:oc:capacitor)
The capacitor stores energy to be used by the network, acting as an energy buffer when needed. Unlike conversion from other mod's energy to OpenComputers' internal energy type (using a [power converter](powerConverter.md) for example), transferring energy inside a single subnetwork is instantaneous. Having an internal energy bugger will be useful for tasks that require a lot of energy, such as [assembling](assembler.md) and/or [charging](charger.md) devices such as [robots](robot.md) or [drones](../item/drone.md).
The capacitor stores energy to be used by the network, acting as an energy buffer when needed. Unlike conversion from other mod's energy to OpenComputers' internal energy type (using a [power converter](powerConverter.md) for example), transferring energy inside a single subnetwork is instantaneous. Having an internal energy buffer will be useful for tasks that require a lot of energy, such as [assembling](assembler.md) and/or [charging](charger.md) devices such as [robots](robot.md) or [drones](../item/drone.md).
The storage efficiency of capacitors increases with the number of capacitors in direct contact or in the vicinity. For example, two capacitors directly next to each other will have a higher storage capacity than the sum of two separated capacitors. This adjacency bonus applies for capacitors up to two blocks away, and is reduced as the distance between capacitors increases.

View File

@ -2,7 +2,8 @@
The Lua [reference manual](http://www.lua.org/manual/5.2/manual.html) and the [Programming in Lua](http://www.lua.org/pil/) books (first edition is available for free online) are a good place to get started with the basics of Lua and becoming familiar with the basic syntax and standard libraries. [OpenOS](openOS.md) strives to emulate the standard libraries very closely, with a few deviations, such as the mostly missing debug library (for sandboxing reasons). These differences are [documented on the wiki](http://ocdoc.cil.li/api:non-standard-lua-libs).
Non-standard libraries will need to be `require`d in order to use them in a script. For example:
Non-standard libraries will need to be
`require`d in order to use them in a script. For example:
`local component = require("component")`
`local rs = component.redstone`

View File

@ -27,13 +27,11 @@ class Screen(val buffer: api.component.TextBuffer, val hasMouse: Boolean, val ha
if (hasMouse && Mouse.hasWheel && Mouse.getEventDWheel != 0) {
val mouseX = Mouse.getEventX * width / mc.displayWidth
val mouseY = height - Mouse.getEventY * height / mc.displayHeight - 1
val bx = (mouseX - x - bufferMargin) / TextBufferRenderCache.renderer.charRenderWidth.toDouble
val by = (mouseY - y - bufferMargin) / TextBufferRenderCache.renderer.charRenderHeight.toDouble
val bw = buffer.getWidth
val bh = buffer.getHeight
if (bx >= 0 && by >= 0 && bx < bw && by < bh) {
val scroll = math.signum(Mouse.getEventDWheel)
buffer.mouseScroll(bx, by, scroll, null)
toBufferCoordinates(mouseX, mouseY) match {
case Some((bx, by)) =>
val scroll = math.signum(Mouse.getEventDWheel)
buffer.mouseScroll(bx, by, scroll, null)
case _ => // Ignore when out of bounds.
}
}
}
@ -60,15 +58,9 @@ class Screen(val buffer: api.component.TextBuffer, val hasMouse: Boolean, val ha
super.mouseMovedOrUp(mouseX, mouseY, button)
if (hasMouse && button >= 0) {
if (didDrag) {
val bx = (mouseX - x - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderWidth
val by = (mouseY - y - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderHeight
val bw = buffer.getWidth
val bh = buffer.getHeight
if (bx >= 0 && by >= 0 && bx < bw && by < bh) {
buffer.mouseUp(bx, by, button, null)
}
else {
buffer.mouseUp(-1.0, -1.0, button, null)
toBufferCoordinates(mouseX, mouseY) match {
case Some((bx, by)) => buffer.mouseUp(bx, by, button, null)
case _ => buffer.mouseUp(-1.0, -1.0, button, null)
}
}
didDrag = false
@ -78,21 +70,26 @@ class Screen(val buffer: api.component.TextBuffer, val hasMouse: Boolean, val ha
}
private def clickOrDrag(mouseX: Int, mouseY: Int, button: Int) {
val bx = (mouseX - x - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderWidth
val by = (mouseY - y - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderHeight
val bw = buffer.getWidth
val bh = buffer.getHeight
if (bx >= 0 && by >= 0 && bx < bw && by < bh) {
if (bx.toInt != mx || by.toInt != my) {
toBufferCoordinates(mouseX, mouseY) match {
case Some((bx, by)) if bx.toInt != mx || by.toInt != my =>
if (mx >= 0 && my >= 0) buffer.mouseDrag(bx, by, button, null)
else buffer.mouseDown(bx, by, button, null)
didDrag = mx >= 0 && my >= 0
mx = bx.toInt
my = by.toInt
}
case _ =>
}
}
private def toBufferCoordinates(mouseX: Int, mouseY: Int): Option[(Double, Double)] = {
val bx = (mouseX - x - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderWidth
val by = (mouseY - y - bufferMargin) / scale / TextBufferRenderCache.renderer.charRenderHeight
val bw = buffer.getWidth
val bh = buffer.getHeight
if (bx >= 0 && by >= 0 && bx < bw && by < bh) Some((bx, by))
else None
}
override def drawScreen(mouseX: Int, mouseY: Int, dt: Float): Unit = {
super.drawScreen(mouseX, mouseY, dt)
drawBufferLayer()

View File

@ -134,7 +134,8 @@ class ClassTransformer extends IClassTransformer {
{
val classNode = newClassNode(transformedClass)
if (classNode.interfaces.contains("li/cil/oc/api/network/SimpleComponent") &&
!classNode.visibleAnnotations.exists(_.desc == "Lli/cil/oc/api/network/SimpleComponent$SkipInjection;")) {
(classNode.visibleAnnotations == null || !classNode.visibleAnnotations.
exists(annotation => annotation != null && annotation.desc == "Lli/cil/oc/api/network/SimpleComponent$SkipInjection;"))) {
try {
transformedClass = injectEnvironmentImplementation(classNode)
log.info(s"Successfully injected component logic into class $name.")

View File

@ -17,7 +17,7 @@ class TransformerLoader extends DummyModContainer({
val md = new ModMetadata()
md.authorList.add("Sangar")
md.modId = "OpenComputers|Core"
md.version = "1.0.0"
md.version = "@VERSION@"
md.name = "OpenComputers (Core)"
md.url = "http://oc.cil.li/"
md.description = "OC core mod used for class transformer and as API owner to avoid cyclic dependencies."

View File

@ -49,7 +49,7 @@ abstract class Template {
val progress =
if (!hasCPU) Localization.Assembler.InsertCPU
else if (!hasRAM) Localization.Assembler.InsertRAM
else if (!hasRAM && requiresRAM) Localization.Assembler.InsertRAM
else Localization.Assembler.Complexity(complexity, maxComplexity)
val warnings = mutable.ArrayBuffer.empty[IChatComponent]

View File

@ -35,6 +35,7 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.language.existentials
// Note to self: this class is used by ExtraCells (and potentially others), do not rename / drastically change it.
trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActionHost] {
def tile: AETile

View File

@ -12,6 +12,7 @@ import li.cil.oc.common.Slot
import li.cil.oc.common.Tier
import li.cil.oc.common.item
import li.cil.oc.common.item.Delegator
import li.cil.oc.server.machine.luac.NativeLuaArchitecture
import net.minecraft.item.ItemStack
import scala.collection.convert.WrapAsScala._
@ -40,7 +41,13 @@ abstract class DriverCPU extends Item with Processor {
override def architecture(stack: ItemStack): Class[_ <: Architecture] = {
if (stack.hasTagCompound) {
val archClass = stack.getTagCompound.getString(Settings.namespace + "archClass")
val archClass = stack.getTagCompound.getString(Settings.namespace + "archClass") match {
case clazz if clazz == classOf[NativeLuaArchitecture].getName =>
// Migrate old saved CPUs to new versions (since the class they refer still
// exists, but is abstract, which would lead to issues).
api.Machine.LuaArchitecture.getName
case clazz => clazz
}
if (!archClass.isEmpty) try return Class.forName(archClass).asSubclass(classOf[Architecture]) catch {
case t: Throwable =>
OpenComputers.log.warn("Failed getting class for CPU architecture. Resetting CPU to use the default.", t)

View File

@ -124,9 +124,12 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
case Some(driver: Processor) if driver.slot(stack) == Slot.CPU =>
Option(driver.architecture(stack)) match {
case Some(clazz) =>
if (architecture == null || architecture.getClass != clazz) {
if (architecture == null || architecture.getClass != clazz) try {
newArchitecture = clazz.getConstructor(classOf[machine.Machine]).newInstance(this)
}
catch {
case t: Throwable => OpenComputers.log.warn("Failed instantiating a CPU architecture.", t)
}
else {
newArchitecture = architecture
}

View File

@ -57,9 +57,8 @@ object LuaStateFactory {
state.openLib(jnlua.LuaState.Library.MATH)
state.openLib(jnlua.LuaState.Library.STRING)
state.openLib(jnlua.LuaState.Library.TABLE)
// TODO Enable once I update the natives.
// state.openLib(jnlua.LuaState.Library.UTF8)
state.pop(7)
state.openLib(jnlua.LuaState.Library.UTF8)
state.pop(8)
}
}

View File

@ -72,7 +72,7 @@ object GameTimeFormatter {
day = yearDay
val monthLengths = monthLengthsForYear(year)
var month = 0
while (day > monthLengths(month)) {
while (day >= monthLengths(month)) {
day = day - monthLengths(month)
month = month + 1
}