mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 10:51:55 -04:00
Added driver for IDeepStorageUnit
. Closes #871.
Using separate "mod" based on interface presence so it also works for mods using and shipping the interface when MFR isn't present (such as JABBA).
This commit is contained in:
parent
89b8dbeb05
commit
ecf6ee76d4
@ -32,6 +32,7 @@ object Mods {
|
||||
val CoFHTransport = new SimpleMod(IDs.CoFHTransport)
|
||||
val ComputerCraft = new SimpleMod(IDs.ComputerCraft)
|
||||
val CraftingCosts = new SimpleMod(IDs.CraftingCosts)
|
||||
val DeepStorageUnit = new ClassBasedMod(IDs.DeepStorageUnit, "powercrystals.minefactoryreloaded.api.IDeepStorageUnit")()
|
||||
val ElectricalAge = new SimpleMod(IDs.ElectricalAge)
|
||||
val EnderIO = new SimpleMod(IDs.EnderIO)
|
||||
val EnderStorage = new SimpleMod(IDs.EnderStorage)
|
||||
@ -82,6 +83,7 @@ object Mods {
|
||||
integration.cofh.tileentity.ModCoFHTileEntity,
|
||||
integration.cofh.transport.ModCoFHTransport,
|
||||
integration.enderstorage.ModEnderStorage,
|
||||
integration.dsu.ModDeepStorageUnit,
|
||||
integration.forestry.ModForestry,
|
||||
integration.fmp.ModForgeMultipart,
|
||||
integration.gc.ModGalacticraft,
|
||||
@ -151,6 +153,7 @@ object Mods {
|
||||
final val Factorization = "factorization"
|
||||
final val Forestry = "Forestry"
|
||||
final val ForgeMultipart = "ForgeMultipart"
|
||||
final val DeepStorageUnit = "MineFactoryReloaded|DeepStorageUnit" // Doesn't really exist.
|
||||
final val Galacticraft = "Galacticraft API"
|
||||
final val GregTech = "gregtech"
|
||||
final val IndustrialCraft2 = "IC2"
|
||||
@ -207,7 +210,7 @@ object Mods {
|
||||
}
|
||||
}
|
||||
|
||||
class ClassBasedMod(val id: String, val classNames: String*)(override val providesPower: Boolean) extends ModBase {
|
||||
class ClassBasedMod(val id: String, val classNames: String*)(override val providesPower: Boolean = false) extends ModBase {
|
||||
override protected lazy val isModAvailable = classNames.forall(className => try Class.forName(className) != null catch {
|
||||
case _: Throwable => false
|
||||
})
|
||||
|
@ -0,0 +1,38 @@
|
||||
package li.cil.oc.integration.dsu
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.driver.EnvironmentAware
|
||||
import li.cil.oc.api.machine.Arguments
|
||||
import li.cil.oc.api.machine.Callback
|
||||
import li.cil.oc.api.machine.Context
|
||||
import li.cil.oc.api.network.ManagedEnvironment
|
||||
import li.cil.oc.api.prefab.DriverTileEntity
|
||||
import li.cil.oc.integration.ManagedTileEntityEnvironment
|
||||
import li.cil.oc.util.ResultWrapper._
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit
|
||||
|
||||
object DriverDeepStorageUnit extends DriverTileEntity with EnvironmentAware {
|
||||
override def getTileEntityClass: Class[_] = classOf[IDeepStorageUnit]
|
||||
|
||||
override def providedEnvironment(stack: ItemStack): Class[_ <: Environment] = classOf[Environment]
|
||||
|
||||
override def createEnvironment(world: World, x: Int, y: Int, z: Int): ManagedEnvironment =
|
||||
new Environment(world.getTileEntity(x, y, z).asInstanceOf[IDeepStorageUnit])
|
||||
|
||||
class Environment(tileEntity: IDeepStorageUnit) extends ManagedTileEntityEnvironment[IDeepStorageUnit](tileEntity, "deep_storage_unit") {
|
||||
@Callback(doc = "function():int -- Get the maximum number of stored items.")
|
||||
def getMaxStoredCount(context: Context, args: Arguments): Array[AnyRef] = result(tileEntity.getMaxStoredCount)
|
||||
|
||||
@Callback(doc = "function():int -- Get the maximum number of stored items.")
|
||||
def getStoredCount(context: Context, args: Arguments): Array[AnyRef] = result(Option(tileEntity.getStoredItemType).fold(0)(_.stackSize))
|
||||
|
||||
@Callback(doc = "function():int -- Get the maximum number of stored items.")
|
||||
def getStoredItemType(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
if (Settings.get.allowItemStackInspection) result(tileEntity.getStoredItemType)
|
||||
else result(null, "not enabled in config")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package li.cil.oc.integration.dsu
|
||||
|
||||
import li.cil.oc.api.Driver
|
||||
import li.cil.oc.integration.ModProxy
|
||||
import li.cil.oc.integration.Mods
|
||||
|
||||
// This is it's own "mod" instead of part of MFR, because some mods like JABBA
|
||||
// use this interface, too, and ship that part of the MFR API.
|
||||
object ModDeepStorageUnit extends ModProxy {
|
||||
override def getMod = Mods.DeepStorageUnit
|
||||
|
||||
override def initialize() {
|
||||
Driver.add(DriverDeepStorageUnit)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user