mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-28 15:30:08 -04:00
Merge branch 'master' of https://github.com/MightyPirates/OpenComputers into MC1.7
Conflicts: src/main/scala/li/cil/oc/server/component/machine/Machine.scala
This commit is contained in:
commit
55b9eb3f2b
@ -26,11 +26,14 @@ file "build.properties" withReader {
|
|||||||
|
|
||||||
version = "${config.oc.version}"
|
version = "${config.oc.version}"
|
||||||
group = "li.cil.oc"
|
group = "li.cil.oc"
|
||||||
archivesBaseName = "OpenComputers-MC${config.minecraft.version}"
|
archivesBaseName = "OpenComputers"
|
||||||
|
|
||||||
if (System.getenv("BUILD_NUMBER") != null)
|
if (System.getenv("BUILD_NUMBER") != null)
|
||||||
version += ".${System.getenv("BUILD_NUMBER")}"
|
version += ".${System.getenv("BUILD_NUMBER")}"
|
||||||
|
|
||||||
|
ext.simpleVersion = version
|
||||||
|
version = "MC${config.minecraft.version}-${project.version}"
|
||||||
|
|
||||||
apply from: 'gradle/forge.gradle'
|
apply from: 'gradle/forge.gradle'
|
||||||
apply from: 'gradle/artifact.gradle'
|
apply from: 'gradle/artifact.gradle'
|
||||||
apply from: 'gradle/release.gradle'
|
apply from: 'gradle/release.gradle'
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
jar {
|
jar {
|
||||||
classifier = 'universal'
|
classifier = 'universal'
|
||||||
manifest {
|
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) {
|
task deobfJar(type: Jar) {
|
||||||
from sourceSets.main.output
|
from sourceSets.main.output
|
||||||
classifier = 'deobf'
|
classifier = 'deobf'
|
||||||
|
manifest {
|
||||||
|
attributes FMLCorePlugin: "li.cil.oc.common.launch.TransformerLoader"
|
||||||
|
attributes FMLCorePluginContainsFMLMod: "true"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task apiJar(type: Jar) {
|
task apiJar(type: Jar) {
|
||||||
|
@ -20,7 +20,7 @@ minecraft {
|
|||||||
processResources {
|
processResources {
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
include 'mcmod/info'
|
include 'mcmod/info'
|
||||||
expand 'version':project.version, 'mcversion':config.minecraft.version
|
expand 'version': project.simpleVersion, 'mcversion': config.minecraft.version
|
||||||
}
|
}
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
exclude 'mcmod.info'
|
exclude 'mcmod.info'
|
||||||
|
@ -3,7 +3,6 @@ apply plugin: 'maven-publish'
|
|||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
mavenJava(MavenPublication) {
|
mavenJava(MavenPublication) {
|
||||||
version "MC${minecraft.version}-${project.version}"
|
|
||||||
artifact apiJar
|
artifact apiJar
|
||||||
artifact deobfJar
|
artifact deobfJar
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,9 @@ class ClassTransformer extends IClassTransformer {
|
|||||||
val tileEntityName = FMLDeobfuscatingRemapper.INSTANCE.map("net.minecraft.tileentity.TileEntity").replace('.', '/')
|
val tileEntityName = FMLDeobfuscatingRemapper.INSTANCE.map("net.minecraft.tileentity.TileEntity").replace('.', '/')
|
||||||
|
|
||||||
def isTileEntity(classNode: ClassNode): Boolean = {
|
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('/', '.')))
|
def classNodeFor(name: String) = newClassNode(loader.getClassBytes(name.replace('/', '.')))
|
||||||
|
@ -1,28 +1,30 @@
|
|||||||
package li.cil.oc.server.component.machine
|
package li.cil.oc.server.component.machine
|
||||||
|
|
||||||
|
import java.io
|
||||||
import java.lang.reflect.Constructor
|
import java.lang.reflect.Constructor
|
||||||
|
import java.util.concurrent.Callable
|
||||||
import java.util.logging.Level
|
import java.util.logging.Level
|
||||||
import li.cil.oc.api.detail.MachineAPI
|
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.machine.{LimitReachedException, Architecture, Owner, ExecutionResult}
|
||||||
import li.cil.oc.api.network._
|
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.common.tileentity
|
||||||
import li.cil.oc.server
|
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.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.ExtendedNBT._
|
||||||
import li.cil.oc.util.ThreadPoolFactory
|
import li.cil.oc.util.ThreadPoolFactory
|
||||||
import li.cil.oc.{OpenComputers, Settings}
|
import li.cil.oc.{OpenComputers, Settings}
|
||||||
import net.minecraft.client.Minecraft
|
import net.minecraft.client.Minecraft
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.nbt._
|
import net.minecraft.nbt._
|
||||||
import net.minecraft.server.MinecraftServer
|
|
||||||
import net.minecraft.server.integrated.IntegratedServer
|
import net.minecraft.server.integrated.IntegratedServer
|
||||||
|
import net.minecraft.server.MinecraftServer
|
||||||
|
import net.minecraftforge.common.DimensionManager
|
||||||
import net.minecraftforge.common.util.Constants.NBT
|
import net.minecraftforge.common.util.Constants.NBT
|
||||||
import scala.Array.canBuildFrom
|
import scala.Array.canBuildFrom
|
||||||
import scala.collection.mutable
|
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 {
|
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).
|
val node = Network.newNode(this, Visibility.Network).
|
||||||
@ -806,9 +808,24 @@ object Machine extends MachineAPI {
|
|||||||
|
|
||||||
override def create(owner: Owner, architecture: Class[_ <: Architecture]) = {
|
override def create(owner: Owner, architecture: Class[_ <: Architecture]) = {
|
||||||
add(architecture)
|
add(architecture)
|
||||||
new Machine(owner,
|
val rom = new CompositeReadOnlyFileSystem(roms(architecture))
|
||||||
Option(FileSystem.asManagedEnvironment(new CompositeReadOnlyFileSystem(roms(architecture)), "rom")),
|
val instance = new Machine(owner,
|
||||||
|
Option(FileSystem.asManagedEnvironment(rom, "rom")),
|
||||||
architecture.getConstructor(classOf[machine.Machine]))
|
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. */
|
/** Possible states of the computer, and in particular its executor. */
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package li.cil.oc.server.fs
|
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
|
||||||
import li.cil.oc.api.fs.Mode
|
import li.cil.oc.api.fs.Mode
|
||||||
import li.cil.oc.util.ExtendedNBT._
|
import li.cil.oc.util.ExtendedNBT._
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import scala.collection.mutable
|
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 {
|
class CompositeReadOnlyFileSystem(factories: mutable.LinkedHashMap[String, Callable[api.fs.FileSystem]]) extends api.fs.FileSystem {
|
||||||
var parts = mutable.LinkedHashMap.empty[String, 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 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
|
||||||
|
})
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user