mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8
This commit is contained in:
commit
db7e23c03e
@ -12,7 +12,7 @@ import li.cil.oc.api.detail.*;
|
|||||||
*/
|
*/
|
||||||
public class API {
|
public class API {
|
||||||
public static final String ID_OWNER = "OpenComputers|Core";
|
public static final String ID_OWNER = "OpenComputers|Core";
|
||||||
public static final String VERSION = "5.5.1";
|
public static final String VERSION = "5.5.2";
|
||||||
|
|
||||||
public static DriverAPI driver = null;
|
public static DriverAPI driver = null;
|
||||||
public static FileSystemAPI fileSystem = null;
|
public static FileSystemAPI fileSystem = null;
|
||||||
|
@ -34,6 +34,16 @@ public interface Database {
|
|||||||
*/
|
*/
|
||||||
ItemStack getStackInSlot(int slot);
|
ItemStack getStackInSlot(int slot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the contents of a slot in the database upgrade.
|
||||||
|
* <p/>
|
||||||
|
* Use this to change the configuration of a database upgrade.
|
||||||
|
*
|
||||||
|
* @param slot the slot to configure.
|
||||||
|
* @param stack the stack to configure the slot to, <tt>null</tt> to clear.
|
||||||
|
*/
|
||||||
|
void setStackInSlot(int slot, ItemStack stack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an item stack with the specified hash stored in this database.
|
* Get an item stack with the specified hash stored in this database.
|
||||||
* <p/>
|
* <p/>
|
||||||
|
@ -5,8 +5,11 @@ import li.cil.oc.OpenComputers
|
|||||||
import li.cil.oc.api.machine.Arguments
|
import li.cil.oc.api.machine.Arguments
|
||||||
import li.cil.oc.api.machine.Callback
|
import li.cil.oc.api.machine.Callback
|
||||||
import li.cil.oc.api.machine.Context
|
import li.cil.oc.api.machine.Context
|
||||||
|
import li.cil.oc.api.network.Node
|
||||||
import li.cil.oc.api.prefab.AbstractValue
|
import li.cil.oc.api.prefab.AbstractValue
|
||||||
import li.cil.oc.common.EventHandler
|
import li.cil.oc.common.EventHandler
|
||||||
|
import li.cil.oc.util.DatabaseAccess
|
||||||
|
import li.cil.oc.util.ExtendedArguments._
|
||||||
import li.cil.oc.util.ExtendedNBT._
|
import li.cil.oc.util.ExtendedNBT._
|
||||||
import li.cil.oc.util.ResultWrapper._
|
import li.cil.oc.util.ResultWrapper._
|
||||||
import net.minecraft.item.Item
|
import net.minecraft.item.Item
|
||||||
@ -25,6 +28,8 @@ import scala.language.existentials
|
|||||||
trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActionHost] {
|
trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActionHost] {
|
||||||
def tile: AETile
|
def tile: AETile
|
||||||
|
|
||||||
|
def node: Node
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Get a list of tables representing the available CPUs in the network.")
|
@Callback(doc = "function():table -- Get a list of tables representing the available CPUs in the network.")
|
||||||
def getCpus(context: Context, args: Arguments): Array[AnyRef] =
|
def getCpus(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
result(tile.getProxy.getCrafting.getCpus.map(cpu => Map(
|
result(tile.getProxy.getCrafting.getCpus.map(cpu => Map(
|
||||||
@ -57,6 +62,27 @@ trait NetworkControl[AETile >: Null <: TileEntity with IGridProxyable with IActi
|
|||||||
result(tile.getProxy.getStorage.getItemInventory.getStorageList.filter(stack => matches(stack, filter)).map(_.getItemStack).toArray)
|
result(tile.getProxy.getStorage.getItemInventory.getStorageList.filter(stack => matches(stack, filter)).map(_.getItemStack).toArray)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Callback(doc = "function(filter:table, dbAddress:string[, startSlot:number[, count:number]]): Boolean -- Store items in the network matching the specified filter in the database with the specified address.")
|
||||||
|
def store(context: Context, args: Arguments): Array[AnyRef] = {
|
||||||
|
val filter = args.checkTable(0).collect {
|
||||||
|
case (key: String, value: AnyRef) => (key, value)
|
||||||
|
}
|
||||||
|
DatabaseAccess.withDatabase(node, args.checkString(1), database => {
|
||||||
|
val stacks = tile.getProxy.getStorage.getItemInventory.getStorageList.filter(stack => matches(stack, filter)).map(_.getItemStack).filter(_ != null).toArray
|
||||||
|
val offset = args.optSlot(database.data, 2, 0)
|
||||||
|
val count = args.optInteger(3, Int.MaxValue) min (database.size - offset) min stacks.length
|
||||||
|
var slot = offset
|
||||||
|
for (i <- 0 until count) {
|
||||||
|
val stack = Option(stacks(i)).map(_.copy()).orNull
|
||||||
|
while (database.getStackInSlot(slot) != null && slot < database.size) slot += 1
|
||||||
|
if (database.getStackInSlot(slot) == null) {
|
||||||
|
database.setStackInSlot(slot, stack)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@Callback(doc = "function():table -- Get a list of the stored fluids in the network.")
|
@Callback(doc = "function():table -- Get a list of the stored fluids in the network.")
|
||||||
def getFluidsInNetwork(context: Context, args: Arguments): Array[AnyRef] =
|
def getFluidsInNetwork(context: Context, args: Arguments): Array[AnyRef] =
|
||||||
result(tile.getProxy.getStorage.getFluidInventory.getStorageList.map(_.getFluidStack).toArray)
|
result(tile.getProxy.getStorage.getFluidInventory.getStorageList.map(_.getFluidStack).toArray)
|
||||||
|
@ -93,8 +93,8 @@ class Geolyzer(val host: EnvironmentHost) extends prefab.ManagedEnvironment {
|
|||||||
val stack = new ItemStack(item, 1, damage)
|
val stack = new ItemStack(item, 1, damage)
|
||||||
DatabaseAccess.withDatabase(node, args.checkString(1), database => {
|
DatabaseAccess.withDatabase(node, args.checkString(1), database => {
|
||||||
val toSlot = args.checkSlot(database.data, 2)
|
val toSlot = args.checkSlot(database.data, 2)
|
||||||
val nonEmpty = database.data.getStackInSlot(toSlot) != null
|
val nonEmpty = database.getStackInSlot(toSlot) != null
|
||||||
database.data.setInventorySlotContents(toSlot, stack)
|
database.setStackInSlot(toSlot, stack)
|
||||||
result(nonEmpty)
|
result(nonEmpty)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ class UpgradeDatabase(val data: IInventory) extends prefab.ManagedEnvironment wi
|
|||||||
|
|
||||||
override def getStackInSlot(slot: Int) = Option(data.getStackInSlot(slot)).map(_.copy()).orNull
|
override def getStackInSlot(slot: Int) = Option(data.getStackInSlot(slot)).map(_.copy()).orNull
|
||||||
|
|
||||||
|
override def setStackInSlot(slot: Int, stack: ItemStack) = data.setInventorySlotContents(slot, stack)
|
||||||
|
|
||||||
override def findStackWithHash(needle: String) = indexOf(needle)
|
override def findStackWithHash(needle: String) = indexOf(needle)
|
||||||
|
|
||||||
@Callback(doc = "function(slot:number):table -- Get the representation of the item stack stored in the specified slot.")
|
@Callback(doc = "function(slot:number):table -- Get the representation of the item stack stored in the specified slot.")
|
||||||
|
@ -23,8 +23,8 @@ trait InventoryAnalytics extends InventoryAware with NetworkAware {
|
|||||||
val localStack = inventory.getStackInSlot(localSlot)
|
val localStack = inventory.getStackInSlot(localSlot)
|
||||||
DatabaseAccess.withDatabase(node, dbAddress, database => {
|
DatabaseAccess.withDatabase(node, dbAddress, database => {
|
||||||
val dbSlot = args.checkSlot(database.data, 2)
|
val dbSlot = args.checkSlot(database.data, 2)
|
||||||
val nonEmpty = database.data.getStackInSlot(dbSlot) != null
|
val nonEmpty = database.getStackInSlot(dbSlot) != null
|
||||||
database.data.setInventorySlotContents(dbSlot, localStack.copy())
|
database.setStackInSlot(dbSlot, localStack.copy())
|
||||||
result(nonEmpty)
|
result(nonEmpty)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ trait InventoryAnalytics extends InventoryAware with NetworkAware {
|
|||||||
val localStack = inventory.getStackInSlot(localSlot)
|
val localStack = inventory.getStackInSlot(localSlot)
|
||||||
DatabaseAccess.withDatabase(node, dbAddress, database => {
|
DatabaseAccess.withDatabase(node, dbAddress, database => {
|
||||||
val dbSlot = args.checkSlot(database.data, 2)
|
val dbSlot = args.checkSlot(database.data, 2)
|
||||||
val dbStack = database.data.getStackInSlot(dbSlot)
|
val dbStack = database.getStackInSlot(dbSlot)
|
||||||
result(haveSameItemType(localStack, dbStack))
|
result(haveSameItemType(localStack, dbStack))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,8 @@ trait WorldInventoryAnalytics extends WorldAware with SideRestricted with Networ
|
|||||||
val dbAddress = args.checkString(2)
|
val dbAddress = args.checkString(2)
|
||||||
def store(stack: ItemStack) = DatabaseAccess.withDatabase(node, dbAddress, database => {
|
def store(stack: ItemStack) = DatabaseAccess.withDatabase(node, dbAddress, database => {
|
||||||
val dbSlot = args.checkSlot(database.data, 3)
|
val dbSlot = args.checkSlot(database.data, 3)
|
||||||
val nonEmpty = database.data.getStackInSlot(dbSlot) != null
|
val nonEmpty = database.getStackInSlot(dbSlot) != null
|
||||||
database.data.setInventorySlotContents(dbSlot, stack.copy())
|
database.setStackInSlot(dbSlot, stack.copy())
|
||||||
result(nonEmpty)
|
result(nonEmpty)
|
||||||
})
|
})
|
||||||
withInventory(facing, inventory => store(inventory.getStackInSlot(args.checkSlot(inventory, 1))))
|
withInventory(facing, inventory => store(inventory.getStackInSlot(args.checkSlot(inventory, 1))))
|
||||||
|
@ -22,7 +22,8 @@ object UpdateCheck {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private def initialize(): Option[Release] = {
|
private def initialize(): Option[Release] = {
|
||||||
if (Settings.get.updateCheck && OpenComputers.Version != "@VERSION@") {
|
// Keep the version template split up so it's not replaced with the actual version...
|
||||||
|
if (Settings.get.updateCheck && OpenComputers.Version != ("@" + "VERSION" + "@")) {
|
||||||
try {
|
try {
|
||||||
OpenComputers.log.info("Starting OpenComputers version check.")
|
OpenComputers.log.info("Starting OpenComputers version check.")
|
||||||
val reader = new JsonReader(new InputStreamReader(releasesUrl.openStream()))
|
val reader = new JsonReader(new InputStreamReader(releasesUrl.openStream()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user