Conflicts:
	src/main/scala/li/cil/oc/server/component/machine/Machine.scala
This commit is contained in:
Florian Nücke 2014-03-09 12:34:12 +01:00
commit 55b9eb3f2b
7 changed files with 50 additions and 15 deletions

View File

@ -26,11 +26,14 @@ file "build.properties" withReader {
version = "${config.oc.version}"
group = "li.cil.oc"
archivesBaseName = "OpenComputers-MC${config.minecraft.version}"
archivesBaseName = "OpenComputers"
if (System.getenv("BUILD_NUMBER") != null)
version += ".${System.getenv("BUILD_NUMBER")}"
ext.simpleVersion = version
version = "MC${config.minecraft.version}-${project.version}"
apply from: 'gradle/forge.gradle'
apply from: 'gradle/artifact.gradle'
apply from: 'gradle/release.gradle'

View File

@ -1,7 +1,8 @@
jar {
classifier = 'universal'
manifest {
attributes FMLCorePlugin: "li.cil.oc.common.launch.TransformerLoader", FMLCorePluginContainsFMLMod: "true"
attributes FMLCorePlugin: "li.cil.oc.common.launch.TransformerLoader"
attributes FMLCorePluginContainsFMLMod: "true"
}
}
@ -9,6 +10,10 @@ jar {
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
manifest {
attributes FMLCorePlugin: "li.cil.oc.common.launch.TransformerLoader"
attributes FMLCorePluginContainsFMLMod: "true"
}
}
task apiJar(type: Jar) {

View File

@ -20,7 +20,7 @@ minecraft {
processResources {
from(sourceSets.main.resources.srcDirs) {
include 'mcmod/info'
expand 'version':project.version, 'mcversion':config.minecraft.version
expand 'version': project.simpleVersion, 'mcversion': config.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'

View File

@ -3,7 +3,6 @@ apply plugin: 'maven-publish'
publishing {
publications {
mavenJava(MavenPublication) {
version "MC${minecraft.version}-${project.version}"
artifact apiJar
artifact deobfJar
}

View File

@ -134,7 +134,9 @@ class ClassTransformer extends IClassTransformer {
val tileEntityName = FMLDeobfuscatingRemapper.INSTANCE.map("net.minecraft.tileentity.TileEntity").replace('.', '/')
def isTileEntity(classNode: ClassNode): Boolean = {
classNode.name != "java/lang/Object" && (classNode.name == tileEntityName || isTileEntity(classNodeFor(classNode.superName)))
classNode != null && classNode.name != "java/lang/Object" &&
(classNode.name == tileEntityName || classNode.superName == tileEntityName ||
isTileEntity(classNodeFor(classNode.superName)))
}
def classNodeFor(name: String) = newClassNode(loader.getClassBytes(name.replace('/', '.')))

View File

@ -1,28 +1,30 @@
package li.cil.oc.server.component.machine
import java.io
import java.lang.reflect.Constructor
import java.util.concurrent.Callable
import java.util.logging.Level
import li.cil.oc.api.detail.MachineAPI
import li.cil.oc.api.{fs, machine, FileSystem, Network}
import li.cil.oc.api.machine.{LimitReachedException, Architecture, Owner, ExecutionResult}
import li.cil.oc.api.network._
import li.cil.oc.api.{fs, machine, FileSystem, Network}
import li.cil.oc.common.tileentity
import li.cil.oc.server
import li.cil.oc.server.PacketSender
import li.cil.oc.server.fs.CompositeReadOnlyFileSystem
import li.cil.oc.server.component.ManagedComponent
import li.cil.oc.server.fs.CompositeReadOnlyFileSystem
import li.cil.oc.server.PacketSender
import li.cil.oc.util.ExtendedNBT._
import li.cil.oc.util.ThreadPoolFactory
import li.cil.oc.{OpenComputers, Settings}
import net.minecraft.client.Minecraft
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.nbt._
import net.minecraft.server.MinecraftServer
import net.minecraft.server.integrated.IntegratedServer
import net.minecraft.server.MinecraftServer
import net.minecraftforge.common.DimensionManager
import net.minecraftforge.common.util.Constants.NBT
import scala.Array.canBuildFrom
import scala.collection.mutable
import java.util.concurrent.Callable
class Machine(val owner: Owner, val rom: Option[ManagedEnvironment], constructor: Constructor[_ <: Architecture]) extends ManagedComponent with machine.Machine with Runnable {
val node = Network.newNode(this, Visibility.Network).
@ -806,9 +808,24 @@ object Machine extends MachineAPI {
override def create(owner: Owner, architecture: Class[_ <: Architecture]) = {
add(architecture)
new Machine(owner,
Option(FileSystem.asManagedEnvironment(new CompositeReadOnlyFileSystem(roms(architecture)), "rom")),
val rom = new CompositeReadOnlyFileSystem(roms(architecture))
val instance = new Machine(owner,
Option(FileSystem.asManagedEnvironment(rom, "rom")),
architecture.getConstructor(classOf[machine.Machine]))
val romPath = "rom/" + instance.architecture.name
try {
val path = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + romPath)
if ((path.exists || path.mkdirs()) && path.isDirectory && !rom.parts.contains(romPath)) {
rom.parts += romPath -> FileSystem.fromSaveDirectory(romPath, 0, false)
}
else {
OpenComputers.log.warning(s"Failed mounting user ROM override '$romPath'. It is either not a directory or another mod registered a ROM resource with that name.")
}
}
catch {
case t: Throwable => OpenComputers.log.log(Level.WARNING, s"Failed mounting user ROM override '$romPath'.", t)
}
instance
}
/** Possible states of the computer, and in particular its executor. */

View File

@ -1,12 +1,12 @@
package li.cil.oc.server.fs
import java.io.FileNotFoundException
import java.util.concurrent.Callable
import li.cil.oc.api
import li.cil.oc.api.fs.Mode
import li.cil.oc.util.ExtendedNBT._
import net.minecraft.nbt.NBTTagCompound
import scala.collection.mutable
import java.io.FileNotFoundException
import java.util.concurrent.Callable
class CompositeReadOnlyFileSystem(factories: mutable.LinkedHashMap[String, Callable[api.fs.FileSystem]]) extends api.fs.FileSystem {
var parts = mutable.LinkedHashMap.empty[String, api.fs.FileSystem]
@ -35,7 +35,16 @@ class CompositeReadOnlyFileSystem(factories: mutable.LinkedHashMap[String, Calla
override def lastModified(path: String) = findFileSystem(path).fold(0L)(_.lastModified(path))
override def list(path: String) = findFileSystem(path).fold(null: Array[String])(_.list(path))
override def list(path: String) = parts.values.foldLeft(Array.empty[String])((acc, fs) => {
if (fs.exists(path)) try {
val l = fs.list(path)
if (l != null) acc ++ l else acc
}
catch {
case _: Throwable => acc
}
else acc
})
// ----------------------------------------------------------------------- //