mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-24 04:50:30 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8.9
# Conflicts: # src/main/java/li/cil/oc/api/driver/MethodWhitelist.java # src/main/java/li/cil/oc/api/driver/NamedBlock.java # src/main/scala/li/cil/oc/common/tileentity/Adapter.scala
This commit is contained in:
commit
3b64c413cf
@ -15,7 +15,7 @@ package li.cil.oc.api.driver;
|
||||
* suppress inventory functionality if your TileEntity implements IInventory.
|
||||
* <p/>
|
||||
* To do so, implement this interface in the <em>environment</em> that you
|
||||
* return from your driver's {@link Block#createEnvironment(net.minecraft.world.World, net.minecraft.util.BlockPos)}
|
||||
* return from your driver's {@link SidedBlock#createEnvironment(net.minecraft.world.World, net.minecraft.util.BlockPos, net.minecraft.util.EnumFacing)}
|
||||
* method, and provide the names of the allowed methods from {@link #whitelistedMethods()}.
|
||||
* <p/>
|
||||
* <em>Important</em>: if multiple drivers apply to a single block that each
|
||||
|
@ -7,7 +7,7 @@ package li.cil.oc.api.driver;
|
||||
* <p/>
|
||||
* This was previously to be implemented on the driver itself, but that has been
|
||||
* deprecated. Implement it in the environment returned from the block driver's
|
||||
* {@link Block#createEnvironment(net.minecraft.world.World, net.minecraft.util.BlockPos)}
|
||||
* {@link SidedBlock#createEnvironment(net.minecraft.world.World, net.minecraft.util.BlockPos, net.minecraft.util.EnumFacing)}
|
||||
* method instead.
|
||||
*/
|
||||
public interface NamedBlock {
|
||||
|
@ -19,7 +19,7 @@ import scala.collection.mutable
|
||||
class Adapter extends traits.Environment with traits.ComponentInventory with Analyzable with internal.Adapter {
|
||||
val node = api.Network.newNode(this, Visibility.Network).create()
|
||||
|
||||
private val blocks = Array.fill[Option[(ManagedEnvironment, api.driver.Block)]](6)(None)
|
||||
private val blocks = Array.fill[Option[(ManagedEnvironment, api.driver.SidedBlock)]](6)(None)
|
||||
|
||||
private val updatingBlocks = mutable.ArrayBuffer.empty[ManagedEnvironment]
|
||||
|
||||
@ -55,7 +55,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
|
||||
// but the only 'downside' is that it can't be used to manipulate
|
||||
// inventories, which I actually consider a plus :P
|
||||
case _ =>
|
||||
Option(api.Driver.driverFor(world, blockPos)) match {
|
||||
Option(api.Driver.driverFor(world, blockPos, d)) match {
|
||||
case Some(newDriver) => blocks(d.ordinal()) match {
|
||||
case Some((oldEnvironment, driver)) =>
|
||||
if (newDriver != driver) {
|
||||
@ -66,7 +66,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
|
||||
node.disconnect(oldEnvironment.node)
|
||||
|
||||
// Then rebuild - if we have something.
|
||||
val environment = newDriver.createEnvironment(world, blockPos)
|
||||
val environment = newDriver.createEnvironment(world, blockPos, d)
|
||||
if (environment != null) {
|
||||
blocks(d.ordinal()) = Some((environment, newDriver))
|
||||
if (environment.canUpdate) {
|
||||
@ -78,7 +78,7 @@ class Adapter extends traits.Environment with traits.ComponentInventory with Ana
|
||||
} // else: the more things change, the more they stay the same.
|
||||
case _ =>
|
||||
// A challenger appears. Maybe.
|
||||
val environment = newDriver.createEnvironment(world, blockPos)
|
||||
val environment = newDriver.createEnvironment(world, blockPos, d)
|
||||
if (environment != null) {
|
||||
blocks(d.ordinal()) = Some((environment, newDriver))
|
||||
if (environment.canUpdate) {
|
||||
|
@ -298,35 +298,36 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
||||
}
|
||||
}
|
||||
|
||||
override def signal(name: String, args: AnyRef*) = state.synchronized(state.top match {
|
||||
case Machine.State.Stopped | Machine.State.Stopping => false
|
||||
case _ => signals.synchronized {
|
||||
if (signals.size >= 256) false
|
||||
else if (args == null) {
|
||||
signals.enqueue(new Machine.Signal(name, Array.empty))
|
||||
if (architecture != null) architecture.onSignal()
|
||||
true
|
||||
override def signal(name: String, args: AnyRef*): Boolean = {
|
||||
state.synchronized(state.top match {
|
||||
case Machine.State.Stopped | Machine.State.Stopping => return false
|
||||
case _ => signals.synchronized {
|
||||
if (signals.size >= 256) return false
|
||||
else if (args == null) {
|
||||
signals.enqueue(new Machine.Signal(name, Array.empty))
|
||||
}
|
||||
else {
|
||||
signals.enqueue(new Machine.Signal(name, args.map {
|
||||
case null | Unit | None => null
|
||||
case arg: java.lang.Boolean => arg
|
||||
case arg: java.lang.Character => Double.box(arg.toDouble)
|
||||
case arg: java.lang.Long => arg
|
||||
case arg: java.lang.Number => Double.box(arg.doubleValue)
|
||||
case arg: java.lang.String => arg
|
||||
case arg: Array[Byte] => arg
|
||||
case arg: Map[_, _] if arg.isEmpty || arg.head._1.isInstanceOf[String] && arg.head._2.isInstanceOf[String] => arg
|
||||
case arg: NBTTagCompound => arg
|
||||
case arg =>
|
||||
OpenComputers.log.warn("Trying to push signal with an unsupported argument of type " + arg.getClass.getName)
|
||||
null
|
||||
}.toArray[AnyRef]))
|
||||
}
|
||||
}
|
||||
else {
|
||||
signals.enqueue(new Machine.Signal(name, args.map {
|
||||
case null | Unit | None => null
|
||||
case arg: java.lang.Boolean => arg
|
||||
case arg: java.lang.Character => Double.box(arg.toDouble)
|
||||
case arg: java.lang.Long => arg
|
||||
case arg: java.lang.Number => Double.box(arg.doubleValue)
|
||||
case arg: java.lang.String => arg
|
||||
case arg: Array[Byte] => arg
|
||||
case arg: Map[_, _] if arg.isEmpty || arg.head._1.isInstanceOf[String] && arg.head._2.isInstanceOf[String] => arg
|
||||
case arg: NBTTagCompound => arg
|
||||
case arg =>
|
||||
OpenComputers.log.warn("Trying to push signal with an unsupported argument of type " + arg.getClass.getName)
|
||||
null
|
||||
}.toArray[AnyRef]))
|
||||
if (architecture != null) architecture.onSignal()
|
||||
true
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
if (architecture != null) architecture.onSignal()
|
||||
true
|
||||
}
|
||||
|
||||
override def popSignal(): Machine.Signal = signals.synchronized(if (signals.isEmpty) null else signals.dequeue().convert())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user