mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Merge branch 'robot_components' of cil.li:oc into recipes
This commit is contained in:
commit
5c5ddd1f72
BIN
assets/opencomputers/textures/font/chars_aliased.png
Normal file
BIN
assets/opencomputers/textures/font/chars_aliased.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
@ -13,7 +13,7 @@ import li.cil.oc.client.{PacketHandler => ClientPacketHandler}
|
|||||||
import li.cil.oc.common.Proxy
|
import li.cil.oc.common.Proxy
|
||||||
import li.cil.oc.server.{PacketHandler => ServerPacketHandler}
|
import li.cil.oc.server.{PacketHandler => ServerPacketHandler}
|
||||||
|
|
||||||
@Mod(modid = "OpenComputers", name = "OpenComputers", version = "1.0.4",
|
@Mod(modid = "OpenComputers", name = "OpenComputers", version = "1.0.5a",
|
||||||
dependencies = "required-after:Forge@[9.11.1.940,);after:BuildCraft|Energy;after:ComputerCraft;after:IC2;after:MineFactoryReloaded;after:RedLogic;after:ThermalExpansion",
|
dependencies = "required-after:Forge@[9.11.1.940,);after:BuildCraft|Energy;after:ComputerCraft;after:IC2;after:MineFactoryReloaded;after:RedLogic;after:ThermalExpansion",
|
||||||
modLanguage = "scala")
|
modLanguage = "scala")
|
||||||
@NetworkMod(clientSideRequired = true, serverSideRequired = false,
|
@NetworkMod(clientSideRequired = true, serverSideRequired = false,
|
||||||
|
@ -21,6 +21,7 @@ class Settings(config: Config) {
|
|||||||
val screenTextFadeStartDistance = config.getDouble("client.screenTextFadeStartDistance")
|
val screenTextFadeStartDistance = config.getDouble("client.screenTextFadeStartDistance")
|
||||||
val maxScreenTextRenderDistance = config.getDouble("client.maxScreenTextRenderDistance")
|
val maxScreenTextRenderDistance = config.getDouble("client.maxScreenTextRenderDistance")
|
||||||
val textLinearFiltering = config.getBoolean("client.textLinearFiltering")
|
val textLinearFiltering = config.getBoolean("client.textLinearFiltering")
|
||||||
|
val textAntiAlias = config.getBoolean("client.textAntiAlias")
|
||||||
val rTreeDebugRenderer = false // *Not* to be configurable via config file.
|
val rTreeDebugRenderer = false // *Not* to be configurable via config file.
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -11,6 +11,7 @@ import scala.io.Source
|
|||||||
|
|
||||||
object MonospaceFontRenderer {
|
object MonospaceFontRenderer {
|
||||||
val font = new ResourceLocation(Settings.resourceDomain, "textures/font/chars.png")
|
val font = new ResourceLocation(Settings.resourceDomain, "textures/font/chars.png")
|
||||||
|
val fontAliased = new ResourceLocation(Settings.resourceDomain, "textures/font/chars_aliased.png")
|
||||||
|
|
||||||
private val chars = Source.fromInputStream(MonospaceFontRenderer.getClass.getResourceAsStream("/assets/" + Settings.resourceDomain + "/textures/font/chars.txt"))("UTF-8").mkString
|
private val chars = Source.fromInputStream(MonospaceFontRenderer.getClass.getResourceAsStream("/assets/" + Settings.resourceDomain + "/textures/font/chars.txt"))("UTF-8").mkString
|
||||||
|
|
||||||
@ -71,7 +72,10 @@ object MonospaceFontRenderer {
|
|||||||
def drawString(x: Int, y: Int, value: Array[Char], color: Array[Short], depth: PackedColor.Depth.Value) = {
|
def drawString(x: Int, y: Int, value: Array[Char], color: Array[Short], depth: PackedColor.Depth.Value) = {
|
||||||
if (color.length != value.length) throw new IllegalArgumentException("Color count must match char count.")
|
if (color.length != value.length) throw new IllegalArgumentException("Color count must match char count.")
|
||||||
|
|
||||||
textureManager.bindTexture(MonospaceFontRenderer.font)
|
if (Settings.get.textAntiAlias)
|
||||||
|
textureManager.bindTexture(MonospaceFontRenderer.font)
|
||||||
|
else
|
||||||
|
textureManager.bindTexture(MonospaceFontRenderer.fontAliased)
|
||||||
GL11.glPushMatrix()
|
GL11.glPushMatrix()
|
||||||
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_TEXTURE_BIT)
|
GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_TEXTURE_BIT)
|
||||||
GL11.glTranslatef(x, y, 0)
|
GL11.glTranslatef(x, y, 0)
|
||||||
|
@ -50,6 +50,10 @@ class RobotAfterimage(val parent: SpecialDelegator) extends SpecialDelegate {
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
override def addedToWorld(world: World, x: Int, y: Int, z: Int) {
|
||||||
|
world.scheduleBlockUpdate(x, y, z, parent.blockID, math.max((Settings.get.moveDelay * 20).toInt, 1) - 1)
|
||||||
|
}
|
||||||
|
|
||||||
override def update(world: World, x: Int, y: Int, z: Int) {
|
override def update(world: World, x: Int, y: Int, z: Int) {
|
||||||
parent.subBlock(world, x, y, z) match {
|
parent.subBlock(world, x, y, z) match {
|
||||||
case Some(_: RobotAfterimage) => world.setBlockToAir(x, y, z)
|
case Some(_: RobotAfterimage) => world.setBlockToAir(x, y, z)
|
||||||
|
@ -85,8 +85,10 @@ class RobotProxy(val parent: SpecialDelegator) extends RedstoneAware with Specia
|
|||||||
|
|
||||||
override def intersect(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) = {
|
override def intersect(world: World, x: Int, y: Int, z: Int, origin: Vec3, direction: Vec3) = {
|
||||||
val bounds = parent.getCollisionBoundingBoxFromPool(world, x, y, z)
|
val bounds = parent.getCollisionBoundingBoxFromPool(world, x, y, z)
|
||||||
if (bounds.isVecInside(origin)) null
|
world.getBlockTileEntity(x, y, z) match {
|
||||||
else super.intersect(world, x, y, z, origin, direction)
|
case proxy: tileentity.RobotProxy if proxy.robot.animationTicksLeft <= 0 && bounds.isVecInside(origin) => null
|
||||||
|
case _ => super.intersect(world, x, y, z, origin, direction)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def updateBounds(world: IBlockAccess, x: Int, y: Int, z: Int) {
|
override def updateBounds(world: IBlockAccess, x: Int, y: Int, z: Int) {
|
||||||
|
@ -86,14 +86,20 @@ trait BundledRedstoneAware extends RedstoneAware with IBundledEmitter with IBund
|
|||||||
super.load(nbt)
|
super.load(nbt)
|
||||||
|
|
||||||
nbt.getTagList(Settings.namespace + "rs.bundledInput").iterator[NBTTagIntArray].zipWithIndex.foreach {
|
nbt.getTagList(Settings.namespace + "rs.bundledInput").iterator[NBTTagIntArray].zipWithIndex.foreach {
|
||||||
case (input, side) => input.intArray.copyToArray(_bundledInput(side))
|
case (input, side) if side < _bundledInput.length =>
|
||||||
|
val safeLength = input.intArray.length min _bundledInput(side).length
|
||||||
|
input.intArray.copyToArray(_bundledInput(side), 0, safeLength)
|
||||||
}
|
}
|
||||||
nbt.getTagList(Settings.namespace + "rs.bundledOutput").iterator[NBTTagIntArray].zipWithIndex.foreach {
|
nbt.getTagList(Settings.namespace + "rs.bundledOutput").iterator[NBTTagIntArray].zipWithIndex.foreach {
|
||||||
case (input, side) => input.intArray.copyToArray(_bundledOutput(side))
|
case (input, side) if side < _bundledOutput.length =>
|
||||||
|
val safeLength = input.intArray.length min _bundledOutput(side).length
|
||||||
|
input.intArray.copyToArray(_bundledOutput(side), 0, safeLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
nbt.getTagList(Settings.namespace + "rs.rednetInput").iterator[NBTTagIntArray].zipWithIndex.foreach {
|
nbt.getTagList(Settings.namespace + "rs.rednetInput").iterator[NBTTagIntArray].zipWithIndex.foreach {
|
||||||
case (input, side) => input.intArray.copyToArray(_rednetInput(side))
|
case (input, side) if side < _rednetInput.length =>
|
||||||
|
val safeLength = input.intArray.length min _rednetInput(side).length
|
||||||
|
input.intArray.copyToArray(_rednetInput(side), 0, safeLength)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class Case(var tier: Int, isRemote: Boolean) extends Computer(isRemote) {
|
|||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def readFromNBT(nbt: NBTTagCompound) {
|
override def readFromNBT(nbt: NBTTagCompound) {
|
||||||
tier = nbt.getByte(Settings.namespace + "tier")
|
tier = nbt.getByte(Settings.namespace + "tier") max 0 min 2
|
||||||
super.readFromNBT(nbt)
|
super.readFromNBT(nbt)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,6 +30,7 @@ class Case(var tier: Int, isRemote: Boolean) extends Computer(isRemote) {
|
|||||||
case 0 => 4
|
case 0 => 4
|
||||||
case 1 => 6
|
case 1 => 6
|
||||||
case 2 => 8
|
case 2 => 8
|
||||||
|
case _ => 0
|
||||||
}
|
}
|
||||||
|
|
||||||
override def isUseableByPlayer(player: EntityPlayer) =
|
override def isUseableByPlayer(player: EntityPlayer) =
|
||||||
@ -62,5 +63,6 @@ class Case(var tier: Int, isRemote: Boolean) extends Computer(isRemote) {
|
|||||||
case (7, Some(driver)) => driver.slot(stack) == Slot.Disk
|
case (7, Some(driver)) => driver.slot(stack) == Slot.Disk
|
||||||
case _ => false // Invalid slot.
|
case _ => false // Invalid slot.
|
||||||
}
|
}
|
||||||
|
case _ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,7 +55,7 @@ class Charger extends Environment with RedstoneAware with Analyzable {
|
|||||||
|
|
||||||
override def load(nbt: NBTTagCompound) {
|
override def load(nbt: NBTTagCompound) {
|
||||||
super.load(nbt)
|
super.load(nbt)
|
||||||
chargeSpeed = nbt.getDouble("chargeSpeed")
|
chargeSpeed = nbt.getDouble("chargeSpeed") max 0 min 1
|
||||||
invertSignal = nbt.getBoolean("invertSignal")
|
invertSignal = nbt.getBoolean("invertSignal")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,13 +61,17 @@ abstract class Environment extends net.minecraft.tileentity.TileEntity with Tile
|
|||||||
override def readFromNBT(nbt: NBTTagCompound) {
|
override def readFromNBT(nbt: NBTTagCompound) {
|
||||||
super.readFromNBT(nbt)
|
super.readFromNBT(nbt)
|
||||||
load(nbt)
|
load(nbt)
|
||||||
if (node != null && node.host == this) node.load(nbt.getCompoundTag(Settings.namespace + "node"))
|
if (node != null && node.host == this) {
|
||||||
|
node.load(nbt.getCompoundTag(Settings.namespace + "node"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def writeToNBT(nbt: NBTTagCompound) {
|
override def writeToNBT(nbt: NBTTagCompound) {
|
||||||
super.writeToNBT(nbt)
|
super.writeToNBT(nbt)
|
||||||
save(nbt)
|
save(nbt)
|
||||||
if (node != null && node.host == this) nbt.setNewCompoundTag(Settings.namespace + "node", node.save)
|
if (node != null && node.host == this) {
|
||||||
|
nbt.setNewCompoundTag(Settings.namespace + "node", node.save)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -109,7 +109,7 @@ trait Inventory extends TileEntity with IInventory with Persistable {
|
|||||||
nbt.getTagList(Settings.namespace + "items").foreach[NBTTagCompound](slotNbt => {
|
nbt.getTagList(Settings.namespace + "items").foreach[NBTTagCompound](slotNbt => {
|
||||||
val slot = slotNbt.getByte("slot")
|
val slot = slotNbt.getByte("slot")
|
||||||
if (slot >= 0 && slot < items.length) {
|
if (slot >= 0 && slot < items.length) {
|
||||||
items(slot) = Some(ItemStack.loadItemStackFromNBT(slotNbt.getCompoundTag("item")))
|
items(slot) = Option(ItemStack.loadItemStackFromNBT(slotNbt.getCompoundTag("item")))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import li.cil.oc.api.network
|
|||||||
import li.cil.oc.server.{PacketSender => ServerPacketSender}
|
import li.cil.oc.server.{PacketSender => ServerPacketSender}
|
||||||
import li.cil.oc.util.Persistable
|
import li.cil.oc.util.Persistable
|
||||||
import mods.immibis.redlogic.api.wiring._
|
import mods.immibis.redlogic.api.wiring._
|
||||||
|
import net.minecraft.block.Block
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import net.minecraftforge.common.ForgeDirection
|
import net.minecraftforge.common.ForgeDirection
|
||||||
|
|
||||||
@ -74,8 +75,10 @@ trait RedstoneAware extends RotationAware with network.Environment with Persista
|
|||||||
override def load(nbt: NBTTagCompound) = {
|
override def load(nbt: NBTTagCompound) = {
|
||||||
super.load(nbt)
|
super.load(nbt)
|
||||||
|
|
||||||
nbt.getIntArray(Settings.namespace + "rs.input").copyToArray(_input)
|
val input = nbt.getIntArray(Settings.namespace + "rs.input")
|
||||||
nbt.getIntArray(Settings.namespace + "rs.output").copyToArray(_output)
|
input.copyToArray(_input, 0, input.length min _input.length)
|
||||||
|
val output = nbt.getIntArray(Settings.namespace + "rs.output")
|
||||||
|
output.copyToArray(_output, 0, output.length min _output.length)
|
||||||
}
|
}
|
||||||
|
|
||||||
override def save(nbt: NBTTagCompound) = {
|
override def save(nbt: NBTTagCompound) = {
|
||||||
@ -101,16 +104,12 @@ trait RedstoneAware extends RotationAware with network.Environment with Persista
|
|||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
protected def computeInput(side: ForgeDirection) = {
|
protected def computeInput(side: ForgeDirection) = {
|
||||||
val vanilla = world.getIndirectPowerLevelTo(
|
val (sx, sy, sz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
|
||||||
x + side.offsetX,
|
// See BlockRedstoneLogic.getInputStrength() for reference.
|
||||||
y + side.offsetY,
|
val vanilla = math.max(world.getIndirectPowerLevelTo(sx, sy, sz, side.ordinal()),
|
||||||
z + side.offsetZ,
|
if (world.getBlockId(sx, sy, sz) == Block.redstoneWire.blockID) world.getBlockMetadata(sx, sy, sz) else 0)
|
||||||
side.ordinal())
|
|
||||||
val redLogic = if (Loader.isModLoaded("RedLogic")) {
|
val redLogic = if (Loader.isModLoaded("RedLogic")) {
|
||||||
world.getBlockTileEntity(
|
world.getBlockTileEntity(sx, sy, sz) match {
|
||||||
x + side.offsetX,
|
|
||||||
y + side.offsetY,
|
|
||||||
z + side.offsetZ) match {
|
|
||||||
case emitter: IRedstoneEmitter =>
|
case emitter: IRedstoneEmitter =>
|
||||||
var strength = 0
|
var strength = 0
|
||||||
for (i <- -1 to 5) {
|
for (i <- -1 to 5) {
|
||||||
|
@ -157,7 +157,6 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
|||||||
val moveTicks = math.max((Settings.get.moveDelay * 20).toInt, 1)
|
val moveTicks = math.max((Settings.get.moveDelay * 20).toInt, 1)
|
||||||
setAnimateMove(ox, oy, oz, moveTicks)
|
setAnimateMove(ox, oy, oz, moveTicks)
|
||||||
if (isServer) {
|
if (isServer) {
|
||||||
world.scheduleBlockUpdate(ox, oy, oz, Blocks.robotAfterimage.parent.blockID, moveTicks - 1)
|
|
||||||
ServerPacketSender.sendRobotMove(this, ox, oy, oz, direction)
|
ServerPacketSender.sendRobotMove(this, ox, oy, oz, direction)
|
||||||
checkRedstoneInputChanged()
|
checkRedstoneInputChanged()
|
||||||
}
|
}
|
||||||
@ -313,9 +312,9 @@ class Robot(isRemote: Boolean) extends Computer(isRemote) with ISidedInventory w
|
|||||||
if (nbt.hasKey(Settings.namespace + "owner")) {
|
if (nbt.hasKey(Settings.namespace + "owner")) {
|
||||||
owner = nbt.getString(Settings.namespace + "owner")
|
owner = nbt.getString(Settings.namespace + "owner")
|
||||||
}
|
}
|
||||||
xp = nbt.getDouble(Settings.namespace + "xp")
|
xp = nbt.getDouble(Settings.namespace + "xp") max 0
|
||||||
updateXpInfo()
|
updateXpInfo()
|
||||||
selectedSlot = nbt.getInteger(Settings.namespace + "selectedSlot")
|
selectedSlot = nbt.getInteger(Settings.namespace + "selectedSlot") max actualSlot(0) min (getSizeInventory - 1)
|
||||||
animationTicksTotal = nbt.getInteger(Settings.namespace + "animationTicksTotal")
|
animationTicksTotal = nbt.getInteger(Settings.namespace + "animationTicksTotal")
|
||||||
animationTicksLeft = nbt.getInteger(Settings.namespace + "animationTicksLeft")
|
animationTicksLeft = nbt.getInteger(Settings.namespace + "animationTicksLeft")
|
||||||
if (animationTicksLeft > 0) {
|
if (animationTicksLeft > 0) {
|
||||||
|
@ -165,7 +165,9 @@ trait Rotatable extends RotationAware with Persistable {
|
|||||||
override def load(nbt: NBTTagCompound) = {
|
override def load(nbt: NBTTagCompound) = {
|
||||||
super.load(nbt)
|
super.load(nbt)
|
||||||
_pitch = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "pitch"))
|
_pitch = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "pitch"))
|
||||||
|
if (_pitch == ForgeDirection.UNKNOWN) _pitch = ForgeDirection.NORTH
|
||||||
_yaw = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "yaw"))
|
_yaw = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "yaw"))
|
||||||
|
if (_yaw == ForgeDirection.UNKNOWN) _yaw = ForgeDirection.SOUTH
|
||||||
updateTranslation()
|
updateTranslation()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ class Screen(var tier: Int) extends Buffer with SidedEnvironment with Rotatable
|
|||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def readFromNBT(nbt: NBTTagCompound) {
|
override def readFromNBT(nbt: NBTTagCompound) {
|
||||||
tier = nbt.getByte(Settings.namespace + "tier")
|
tier = nbt.getByte(Settings.namespace + "tier") max 0 min 2
|
||||||
super.readFromNBT(nbt)
|
super.readFromNBT(nbt)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,16 @@ class PacketHandler extends CommonPacketHandler {
|
|||||||
case Some(t) => p.player match {
|
case Some(t) => p.player match {
|
||||||
case player: EntityPlayer if t.computer.canInteract(player.getCommandSenderName) =>
|
case player: EntityPlayer if t.computer.canInteract(player.getCommandSenderName) =>
|
||||||
if (p.readBoolean()) {
|
if (p.readBoolean()) {
|
||||||
if (!t.computer.isPaused) t.computer.start()
|
if (!t.computer.isPaused) {
|
||||||
|
t.computer.start()
|
||||||
|
t.computer.lastError match {
|
||||||
|
case Some(message) => p.player match {
|
||||||
|
case player: EntityPlayer => player.addChatMessage(message)
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else t.computer.stop()
|
else t.computer.stop()
|
||||||
case _ =>
|
case _ =>
|
||||||
|
@ -107,11 +107,25 @@ class Computer(val owner: tileentity.Computer) extends ManagedComponent with Con
|
|||||||
def isPaused = state.synchronized(state.top == Computer.State.Paused && remainingPause > 0)
|
def isPaused = state.synchronized(state.top == Computer.State.Paused && remainingPause > 0)
|
||||||
|
|
||||||
def start() = state.synchronized(state.top match {
|
def start() = state.synchronized(state.top match {
|
||||||
case Computer.State.Stopped if owner.installedMemory > 0 && init() =>
|
case Computer.State.Stopped =>
|
||||||
switchTo(Computer.State.Starting)
|
if (owner.installedMemory > 0) {
|
||||||
timeStarted = owner.world.getWorldTime
|
if (Settings.get.ignorePower || node.globalBuffer > cost) {
|
||||||
node.sendToReachable("computer.started")
|
init() && {
|
||||||
true
|
switchTo(Computer.State.Starting)
|
||||||
|
timeStarted = owner.world.getWorldTime
|
||||||
|
node.sendToReachable("computer.started")
|
||||||
|
true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message = Some("not enough energy")
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message = Some("no memory installed")
|
||||||
|
false
|
||||||
|
}
|
||||||
case Computer.State.Paused if remainingPause > 0 =>
|
case Computer.State.Paused if remainingPause > 0 =>
|
||||||
remainingPause = 0
|
remainingPause = 0
|
||||||
true
|
true
|
||||||
@ -687,6 +701,7 @@ class Computer(val owner: tileentity.Computer) extends ManagedComponent with Con
|
|||||||
LuaStateFactory.createState() match {
|
LuaStateFactory.createState() match {
|
||||||
case None =>
|
case None =>
|
||||||
lua = null
|
lua = null
|
||||||
|
message = Some("native libraries not available")
|
||||||
return false
|
return false
|
||||||
case Some(value) => lua = value
|
case Some(value) => lua = value
|
||||||
}
|
}
|
||||||
@ -1336,7 +1351,7 @@ class Computer(val owner: tileentity.Computer) extends ManagedComponent with Con
|
|||||||
catch {
|
catch {
|
||||||
case e: LuaRuntimeException =>
|
case e: LuaRuntimeException =>
|
||||||
OpenComputers.log.warning("Kernel crashed. This is a bug!\n" + e.toString + "\tat " + e.getLuaStackTrace.mkString("\n\tat "))
|
OpenComputers.log.warning("Kernel crashed. This is a bug!\n" + e.toString + "\tat " + e.getLuaStackTrace.mkString("\n\tat "))
|
||||||
crash("kernel panic")
|
crash("kernel panic: this is a bug, check your log file and report it")
|
||||||
case e: LuaGcMetamethodException =>
|
case e: LuaGcMetamethodException =>
|
||||||
if (e.getMessage != null) crash("kernel panic:\n" + e.getMessage)
|
if (e.getMessage != null) crash("kernel panic:\n" + e.getMessage)
|
||||||
else crash("kernel panic:\nerror in garbage collection metamethod")
|
else crash("kernel panic:\nerror in garbage collection metamethod")
|
||||||
@ -1346,7 +1361,7 @@ class Computer(val owner: tileentity.Computer) extends ManagedComponent with Con
|
|||||||
crash("not enough memory")
|
crash("not enough memory")
|
||||||
case e: Throwable =>
|
case e: Throwable =>
|
||||||
OpenComputers.log.log(Level.WARNING, "Unexpected error in kernel. This is a bug!\n", e)
|
OpenComputers.log.log(Level.WARNING, "Unexpected error in kernel. This is a bug!\n", e)
|
||||||
crash("kernel panic")
|
crash("kernel panic: this is a bug, check your log file and report it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,10 @@ abstract class GraphicsCard extends ManagedComponent {
|
|||||||
super.load(nbt)
|
super.load(nbt)
|
||||||
|
|
||||||
if (nbt.hasKey("screen")) {
|
if (nbt.hasKey("screen")) {
|
||||||
screenAddress = Some(nbt.getString("screen"))
|
nbt.getString("screen") match {
|
||||||
|
case screen: String if !screen.isEmpty => screenAddress = Some(screen)
|
||||||
|
case _ => screenAddress = None
|
||||||
|
}
|
||||||
screenInstance = None
|
screenInstance = None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,21 +482,28 @@ class Robot(val robot: tileentity.Robot) extends Computer(robot) with RobotConte
|
|||||||
@LuaCallback("move")
|
@LuaCallback("move")
|
||||||
def move(context: Context, args: Arguments): Array[AnyRef] = {
|
def move(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
val direction = checkSideForMovement(args, 0)
|
val direction = checkSideForMovement(args, 0)
|
||||||
val (something, what) = blockContent(direction)
|
if (robot.isAnimatingMove) {
|
||||||
if (something) {
|
// This shouldn't really happen due to delays being enforced, but just to
|
||||||
result(false, what)
|
// be on the safe side...
|
||||||
|
result(false, "already moving")
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!robot.computer.node.tryChangeBuffer(-Settings.get.robotMoveCost)) {
|
val (something, what) = blockContent(direction)
|
||||||
result(false, "not enough energy")
|
if (something) {
|
||||||
}
|
result(false, what)
|
||||||
else if (robot.move(direction)) {
|
|
||||||
context.pause(Settings.get.moveDelay)
|
|
||||||
result(true)
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
robot.computer.node.changeBuffer(Settings.get.robotMoveCost)
|
if (!robot.computer.node.tryChangeBuffer(-Settings.get.robotMoveCost)) {
|
||||||
result(false, "impossible move")
|
result(false, "not enough energy")
|
||||||
|
}
|
||||||
|
else if (robot.move(direction)) {
|
||||||
|
context.pause(Settings.get.moveDelay)
|
||||||
|
result(true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
robot.computer.node.changeBuffer(Settings.get.robotMoveCost)
|
||||||
|
result(false, "impossible move")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard {
|
|||||||
|
|
||||||
override def load(nbt: NBTTagCompound) {
|
override def load(nbt: NBTTagCompound) {
|
||||||
super.load(nbt)
|
super.load(nbt)
|
||||||
strength = nbt.getDouble("strength")
|
strength = nbt.getDouble("strength") max 0 min Settings.get.maxWirelessRange
|
||||||
}
|
}
|
||||||
|
|
||||||
override def save(nbt: NBTTagCompound) {
|
override def save(nbt: NBTTagCompound) {
|
||||||
|
@ -78,7 +78,9 @@ object ExtendedNBT {
|
|||||||
|
|
||||||
def append(values: NBTBase*): Unit = append(values)
|
def append(values: NBTBase*): Unit = append(values)
|
||||||
|
|
||||||
def iterator[Tag <: NBTBase] = (0 until nbt.tagCount).map(nbt.tagAt).map(_.asInstanceOf[Tag])
|
def iterator[Tag <: NBTBase] = (0 until nbt.tagCount).map(nbt.tagAt).collect {
|
||||||
|
case tag: Tag => tag
|
||||||
|
}
|
||||||
|
|
||||||
def foreach[Tag <: NBTBase](f: (Tag) => Unit) = iterator[Tag].foreach(f)
|
def foreach[Tag <: NBTBase](f: (Tag) => Unit) = iterator[Tag].foreach(f)
|
||||||
|
|
||||||
|
@ -5,12 +5,14 @@ import com.naef.jnlua.{LuaState, NativeSupport}
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileOutputStream
|
import java.io.FileOutputStream
|
||||||
import java.nio.channels.Channels
|
import java.nio.channels.Channels
|
||||||
|
import java.util.logging.Level
|
||||||
import li.cil.oc.server.component.Computer
|
import li.cil.oc.server.component.Computer
|
||||||
import li.cil.oc.util.ExtendedLuaState._
|
import li.cil.oc.util.ExtendedLuaState._
|
||||||
import li.cil.oc.{OpenComputers, Settings}
|
import li.cil.oc.{OpenComputers, Settings}
|
||||||
import org.lwjgl.LWJGLUtil
|
import org.lwjgl.LWJGLUtil
|
||||||
import scala.util.Random
|
import scala.util.Random
|
||||||
import scala.util.control.Breaks._
|
import scala.util.control.Breaks._
|
||||||
|
import org.apache.commons.lang3.SystemUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory singleton used to spawn new LuaState instances.
|
* Factory singleton used to spawn new LuaState instances.
|
||||||
@ -27,6 +29,8 @@ object LuaStateFactory {
|
|||||||
/** Set to true in initialization code below if available. */
|
/** Set to true in initialization code below if available. */
|
||||||
private var haveNativeLibrary = false
|
private var haveNativeLibrary = false
|
||||||
|
|
||||||
|
private var isWindows = false
|
||||||
|
|
||||||
private var _is64Bit = false
|
private var _is64Bit = false
|
||||||
|
|
||||||
def is64Bit = _is64Bit
|
def is64Bit = _is64Bit
|
||||||
@ -76,8 +80,14 @@ object LuaStateFactory {
|
|||||||
break()
|
break()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
isWindows = extension == ".dll"
|
||||||
val libPath = "/assets/" + Settings.resourceDomain + "/lib/"
|
val libPath = "/assets/" + Settings.resourceDomain + "/lib/"
|
||||||
|
|
||||||
|
if (isWindows && SystemUtils.IS_OS_WINDOWS_XP) {
|
||||||
|
OpenComputers.log.warning("Sorry, but Windows XP isn't supported. I very much recommend upgrading your Windows, anyway, since Microsoft will stop supporting it in April 2014.")
|
||||||
|
break()
|
||||||
|
}
|
||||||
|
|
||||||
val tmpPath = {
|
val tmpPath = {
|
||||||
val path = System.getProperty("java.io.tmpdir")
|
val path = System.getProperty("java.io.tmpdir")
|
||||||
if (path.endsWith("/") || path.endsWith("\\")) path
|
if (path.endsWith("/") || path.endsWith("\\")) path
|
||||||
@ -92,7 +102,7 @@ object LuaStateFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Found file with proper extension. Create a temporary file.
|
// Found file with proper extension. Create a temporary file.
|
||||||
val file = new File(tmpPath + library)
|
val file = new File(tmpPath + "OpenComputersMod-" + library)
|
||||||
// Try to delete an old instance of the library, in case we have an update
|
// Try to delete an old instance of the library, in case we have an update
|
||||||
// and deleteOnExit fails (which it regularly does on Windows it seems).
|
// and deleteOnExit fails (which it regularly does on Windows it seems).
|
||||||
try {
|
try {
|
||||||
@ -145,145 +155,160 @@ object LuaStateFactory {
|
|||||||
def createState(): Option[LuaState] = {
|
def createState(): Option[LuaState] = {
|
||||||
if (!haveNativeLibrary) return None
|
if (!haveNativeLibrary) return None
|
||||||
|
|
||||||
val state = new LuaState(Int.MaxValue)
|
|
||||||
try {
|
try {
|
||||||
// Load all libraries.
|
val state = new LuaState(Int.MaxValue)
|
||||||
state.openLib(LuaState.Library.BASE)
|
try {
|
||||||
state.openLib(LuaState.Library.BIT32)
|
// Load all libraries.
|
||||||
state.openLib(LuaState.Library.COROUTINE)
|
state.openLib(LuaState.Library.BASE)
|
||||||
state.openLib(LuaState.Library.DEBUG)
|
state.openLib(LuaState.Library.BIT32)
|
||||||
state.openLib(LuaState.Library.ERIS)
|
state.openLib(LuaState.Library.COROUTINE)
|
||||||
state.openLib(LuaState.Library.MATH)
|
state.openLib(LuaState.Library.DEBUG)
|
||||||
state.openLib(LuaState.Library.STRING)
|
state.openLib(LuaState.Library.ERIS)
|
||||||
state.openLib(LuaState.Library.TABLE)
|
state.openLib(LuaState.Library.MATH)
|
||||||
state.pop(8)
|
state.openLib(LuaState.Library.STRING)
|
||||||
|
state.openLib(LuaState.Library.TABLE)
|
||||||
|
state.pop(8)
|
||||||
|
|
||||||
// Prepare table for os stuff.
|
// Prepare table for os stuff.
|
||||||
state.newTable()
|
state.newTable()
|
||||||
state.setGlobal("os")
|
state.setGlobal("os")
|
||||||
|
|
||||||
// Kill compat entries.
|
// Kill compat entries.
|
||||||
state.pushNil()
|
state.pushNil()
|
||||||
state.setGlobal("unpack")
|
state.setGlobal("unpack")
|
||||||
state.pushNil()
|
state.pushNil()
|
||||||
state.setGlobal("loadstring")
|
state.setGlobal("loadstring")
|
||||||
state.getGlobal("math")
|
state.getGlobal("math")
|
||||||
state.pushNil()
|
state.pushNil()
|
||||||
state.setField(-2, "log10")
|
state.setField(-2, "log10")
|
||||||
state.pop(1)
|
state.pop(1)
|
||||||
state.getGlobal("table")
|
state.getGlobal("table")
|
||||||
state.pushNil()
|
state.pushNil()
|
||||||
state.setField(-2, "maxn")
|
state.setField(-2, "maxn")
|
||||||
state.pop(1)
|
state.pop(1)
|
||||||
|
|
||||||
// Remove some other functions we don't need and are dangerous.
|
// Remove some other functions we don't need and are dangerous.
|
||||||
state.pushNil()
|
state.pushNil()
|
||||||
state.setGlobal("dofile")
|
state.setGlobal("dofile")
|
||||||
state.pushNil()
|
state.pushNil()
|
||||||
state.setGlobal("loadfile")
|
state.setGlobal("loadfile")
|
||||||
|
|
||||||
state.getGlobal("math")
|
state.getGlobal("math")
|
||||||
|
|
||||||
// We give each Lua state it's own randomizer, since otherwise they'd
|
// We give each Lua state it's own randomizer, since otherwise they'd
|
||||||
// use the good old rand() from C. Which can be terrible, and isn't
|
// use the good old rand() from C. Which can be terrible, and isn't
|
||||||
// necessarily thread-safe.
|
// necessarily thread-safe.
|
||||||
val random = new Random
|
val random = new Random
|
||||||
state.pushScalaFunction(lua => {
|
state.pushScalaFunction(lua => {
|
||||||
lua.getTop match {
|
lua.getTop match {
|
||||||
case 0 => lua.pushNumber(random.nextDouble())
|
case 0 => lua.pushNumber(random.nextDouble())
|
||||||
case 1 =>
|
case 1 =>
|
||||||
val u = lua.checkInteger(1)
|
val u = lua.checkInteger(1)
|
||||||
lua.checkArg(1, 1 < u, "interval is empty")
|
lua.checkArg(1, 1 < u, "interval is empty")
|
||||||
lua.pushInteger(1 + random.nextInt(u))
|
lua.pushInteger(1 + random.nextInt(u))
|
||||||
case 2 =>
|
case 2 =>
|
||||||
val l = lua.checkInteger(1)
|
val l = lua.checkInteger(1)
|
||||||
val u = lua.checkInteger(2)
|
val u = lua.checkInteger(2)
|
||||||
lua.checkArg(1, l < u, "interval is empty")
|
lua.checkArg(1, l < u, "interval is empty")
|
||||||
lua.pushInteger(l + random.nextInt(u - (l - 1)))
|
lua.pushInteger(l + random.nextInt(u - (l - 1)))
|
||||||
case _ => throw new IllegalArgumentException("wrong number of arguments")
|
case _ => throw new IllegalArgumentException("wrong number of arguments")
|
||||||
}
|
}
|
||||||
1
|
1
|
||||||
})
|
|
||||||
state.setField(-2, "random")
|
|
||||||
|
|
||||||
state.pushScalaFunction(lua => {
|
|
||||||
random.setSeed(lua.checkInteger(1))
|
|
||||||
0
|
|
||||||
})
|
|
||||||
state.setField(-2, "randomseed")
|
|
||||||
|
|
||||||
// Pop the math table.
|
|
||||||
state.pop(1)
|
|
||||||
|
|
||||||
// Provide some better Unicode support.
|
|
||||||
state.newTable()
|
|
||||||
|
|
||||||
// TODO find (probably not necessary?)
|
|
||||||
|
|
||||||
// TODO format (probably not necessary?)
|
|
||||||
|
|
||||||
// TODO gmatch (probably not necessary?)
|
|
||||||
|
|
||||||
// TODO gsub (probably not necessary?)
|
|
||||||
|
|
||||||
// TODO match (probably not necessary?)
|
|
||||||
|
|
||||||
state.pushScalaFunction(lua => {
|
|
||||||
lua.pushString(lua.checkString(1).toLowerCase)
|
|
||||||
1
|
|
||||||
})
|
|
||||||
state.setField(-2, "lower")
|
|
||||||
|
|
||||||
state.pushScalaFunction(lua => {
|
|
||||||
lua.pushString(lua.checkString(1).toUpperCase)
|
|
||||||
1
|
|
||||||
})
|
|
||||||
state.setField(-2, "upper")
|
|
||||||
|
|
||||||
state.pushScalaFunction(lua => {
|
|
||||||
lua.pushString(String.valueOf((1 to lua.getTop).map(lua.checkInteger).map(_.toChar).toArray))
|
|
||||||
1
|
|
||||||
})
|
|
||||||
state.setField(-2, "char")
|
|
||||||
|
|
||||||
state.pushScalaFunction(lua => {
|
|
||||||
lua.pushInteger(lua.checkString(1).length)
|
|
||||||
1
|
|
||||||
})
|
|
||||||
state.setField(-2, "len")
|
|
||||||
|
|
||||||
state.pushScalaFunction(lua => {
|
|
||||||
lua.pushString(lua.checkString(1).reverse)
|
|
||||||
1
|
|
||||||
})
|
|
||||||
state.setField(-2, "reverse")
|
|
||||||
|
|
||||||
state.pushScalaFunction(lua => {
|
|
||||||
val string = lua.checkString(1)
|
|
||||||
val start = math.max(0, lua.checkInteger(2) match {
|
|
||||||
case i if i < 0 => string.length + i
|
|
||||||
case i => i - 1
|
|
||||||
})
|
})
|
||||||
val end =
|
state.setField(-2, "random")
|
||||||
if (lua.getTop > 2) math.min(string.length, lua.checkInteger(3) match {
|
|
||||||
case i if i < 0 => string.length + i + 1
|
state.pushScalaFunction(lua => {
|
||||||
case i => i
|
random.setSeed(lua.checkInteger(1))
|
||||||
|
0
|
||||||
|
})
|
||||||
|
state.setField(-2, "randomseed")
|
||||||
|
|
||||||
|
// Pop the math table.
|
||||||
|
state.pop(1)
|
||||||
|
|
||||||
|
// Provide some better Unicode support.
|
||||||
|
state.newTable()
|
||||||
|
|
||||||
|
// TODO find (probably not necessary?)
|
||||||
|
|
||||||
|
// TODO format (probably not necessary?)
|
||||||
|
|
||||||
|
// TODO gmatch (probably not necessary?)
|
||||||
|
|
||||||
|
// TODO gsub (probably not necessary?)
|
||||||
|
|
||||||
|
// TODO match (probably not necessary?)
|
||||||
|
|
||||||
|
state.pushScalaFunction(lua => {
|
||||||
|
lua.pushString(lua.checkString(1).toLowerCase)
|
||||||
|
1
|
||||||
|
})
|
||||||
|
state.setField(-2, "lower")
|
||||||
|
|
||||||
|
state.pushScalaFunction(lua => {
|
||||||
|
lua.pushString(lua.checkString(1).toUpperCase)
|
||||||
|
1
|
||||||
|
})
|
||||||
|
state.setField(-2, "upper")
|
||||||
|
|
||||||
|
state.pushScalaFunction(lua => {
|
||||||
|
lua.pushString(String.valueOf((1 to lua.getTop).map(lua.checkInteger).map(_.toChar).toArray))
|
||||||
|
1
|
||||||
|
})
|
||||||
|
state.setField(-2, "char")
|
||||||
|
|
||||||
|
state.pushScalaFunction(lua => {
|
||||||
|
lua.pushInteger(lua.checkString(1).length)
|
||||||
|
1
|
||||||
|
})
|
||||||
|
state.setField(-2, "len")
|
||||||
|
|
||||||
|
state.pushScalaFunction(lua => {
|
||||||
|
lua.pushString(lua.checkString(1).reverse)
|
||||||
|
1
|
||||||
|
})
|
||||||
|
state.setField(-2, "reverse")
|
||||||
|
|
||||||
|
state.pushScalaFunction(lua => {
|
||||||
|
val string = lua.checkString(1)
|
||||||
|
val start = math.max(0, lua.checkInteger(2) match {
|
||||||
|
case i if i < 0 => string.length + i
|
||||||
|
case i => i - 1
|
||||||
})
|
})
|
||||||
else string.length
|
val end =
|
||||||
if (end <= start) lua.pushString("")
|
if (lua.getTop > 2) math.min(string.length, lua.checkInteger(3) match {
|
||||||
else lua.pushString(string.substring(start, end))
|
case i if i < 0 => string.length + i + 1
|
||||||
1
|
case i => i
|
||||||
})
|
})
|
||||||
state.setField(-2, "sub")
|
else string.length
|
||||||
|
if (end <= start) lua.pushString("")
|
||||||
|
else lua.pushString(string.substring(start, end))
|
||||||
|
1
|
||||||
|
})
|
||||||
|
state.setField(-2, "sub")
|
||||||
|
|
||||||
state.setGlobal("unicode")
|
state.setGlobal("unicode")
|
||||||
|
|
||||||
Some(state)
|
return Some(state)
|
||||||
} catch {
|
}
|
||||||
case ex: Throwable =>
|
catch {
|
||||||
ex.printStackTrace()
|
case t: Throwable =>
|
||||||
state.close()
|
OpenComputers.log.log(Level.WARNING, "Failed creating Lua state.", t)
|
||||||
return None
|
state.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
case _: UnsatisfiedLinkError =>
|
||||||
|
OpenComputers.log.severe("Failed loading the native libraries.")
|
||||||
|
if (isWindows) {
|
||||||
|
OpenComputers.log.severe(
|
||||||
|
"Please ensure you have the Visual C++ 2012 Runtime installed " +
|
||||||
|
"(when on 64 Bit, both the 32 bit and 64 bit version of the " +
|
||||||
|
"runtime).")
|
||||||
|
}
|
||||||
|
case t: Throwable =>
|
||||||
|
OpenComputers.log.log(Level.WARNING, "Failed creating Lua state.", t)
|
||||||
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package li.cil.oc.util
|
package li.cil.oc.util
|
||||||
|
|
||||||
|
import li.cil.oc.Settings
|
||||||
import net.minecraft.nbt._
|
import net.minecraft.nbt._
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,7 +138,7 @@ class TextBuffer(var width: Int, var height: Int, initialDepth: PackedColor.Dept
|
|||||||
case dx if tx > 0 => dx
|
case dx if tx > 0 => dx
|
||||||
case dx => dx.swap
|
case dx => dx.swap
|
||||||
}
|
}
|
||||||
val (dy0, dy1) = (math.max(row + ty + h - 1, math.min(0, height - 1)), math.max(row + ty, math.min(0, height))) match {
|
val (dy0, dy1) = (math.max(row + ty + h - 1, math.min(0, height - 1)), math.max(row + ty, math.min(0, height))) match {
|
||||||
case dy if ty > 0 => dy
|
case dy if ty > 0 => dy
|
||||||
case dy => dy.swap
|
case dy => dy.swap
|
||||||
}
|
}
|
||||||
@ -165,17 +166,19 @@ class TextBuffer(var width: Int, var height: Int, initialDepth: PackedColor.Dept
|
|||||||
}
|
}
|
||||||
|
|
||||||
override def load(nbt: NBTTagCompound): Unit = {
|
override def load(nbt: NBTTagCompound): Unit = {
|
||||||
val w = nbt.getInteger("width")
|
val w = nbt.getInteger("width") max 1 min Settings.screenResolutionsByTier(2)._1
|
||||||
val h = nbt.getInteger("height")
|
val h = nbt.getInteger("height") max 1 min Settings.screenResolutionsByTier(2)._2
|
||||||
size = (w, h)
|
size = (w, h)
|
||||||
|
|
||||||
val b = nbt.getTagList("buffer")
|
val b = nbt.getTagList("buffer")
|
||||||
for (i <- 0 until math.min(h, b.tagCount)) {
|
for (i <- 0 until math.min(h, b.tagCount)) {
|
||||||
val line = b.tagAt(i).asInstanceOf[NBTTagString].data
|
b.tagAt(i) match {
|
||||||
set(0, i, line)
|
case tag: NBTTagString => set(0, i, tag.data)
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_depth = PackedColor.Depth(nbt.getInteger("depth"))
|
_depth = PackedColor.Depth(nbt.getInteger("depth") max 0 min PackedColor.Depth.maxId)
|
||||||
foreground = nbt.getInteger("foreground")
|
foreground = nbt.getInteger("foreground")
|
||||||
background = nbt.getInteger("background")
|
background = nbt.getInteger("background")
|
||||||
|
|
||||||
@ -183,7 +186,13 @@ class TextBuffer(var width: Int, var height: Int, initialDepth: PackedColor.Dept
|
|||||||
for (i <- 0 until h) {
|
for (i <- 0 until h) {
|
||||||
val rowColor = color(i)
|
val rowColor = color(i)
|
||||||
for (j <- 0 until w) {
|
for (j <- 0 until w) {
|
||||||
rowColor(j) = c.tagAt(j + i * w).asInstanceOf[NBTTagShort].data
|
val index = j + i * w
|
||||||
|
if (index < c.tagCount) {
|
||||||
|
c.tagAt(index) match {
|
||||||
|
case tag: NBTTagShort => rowColor(j) = tag.data
|
||||||
|
case _ =>
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
{
|
{
|
||||||
"modid": "OpenComputers",
|
"modid": "OpenComputers",
|
||||||
"name": "OpenComputers",
|
"name": "OpenComputers",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5a",
|
||||||
"credits" : "Inspired by a couple of other mods, most notably ComputerCraft.",
|
"credits" : "Inspired by a couple of other mods, most notably ComputerCraft.",
|
||||||
"authors": ["Florian 'Sangar' Nücke", "Johannes 'Lord Joda' Lohrer"],
|
"authors": ["Florian 'Sangar' Nücke", "Johannes 'Lord Joda' Lohrer"],
|
||||||
"description": "This mod adds modular computers and robots that can be programmed in Lua.",
|
"description": "This mod adds modular computers and robots that can be programmed in Lua.",
|
||||||
|
@ -43,6 +43,10 @@ opencomputers {
|
|||||||
# anymore (for example for box drawing characters. Look it up on
|
# anymore (for example for box drawing characters. Look it up on
|
||||||
# Wikipedia.)
|
# Wikipedia.)
|
||||||
textLinearFiltering: false
|
textLinearFiltering: false
|
||||||
|
|
||||||
|
# If you prefer the text on the screens to be aliased (you know, *not*
|
||||||
|
# anti-aliased / smoothed) turn this option off.
|
||||||
|
textAntiAlias: true
|
||||||
}
|
}
|
||||||
|
|
||||||
# Computer related settings, concerns server performance and security.
|
# Computer related settings, concerns server performance and security.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user