mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-09 15:25:56 -04:00
Instead of two separate methods, introduced Container interface that's passed to item drivers for environment creation.
Also used in the FileSystem.asManagedEnvironment methods now.
This commit is contained in:
parent
a81697cc22
commit
3fd5fb0944
@ -2,9 +2,9 @@ package li.cil.oc.api;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import li.cil.oc.api.detail.FileSystemAPI;
|
||||
import li.cil.oc.api.driver.Container;
|
||||
import li.cil.oc.api.fs.Label;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
/**
|
||||
* This class provides factory methods for creating file systems that are
|
||||
@ -183,28 +183,28 @@ public final class FileSystem {
|
||||
* @param container the tile entity containing the file system.
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final TileEntity container) {
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final Label label, final Container container) {
|
||||
if (instance != null)
|
||||
return instance.asManagedEnvironment(fileSystem, label, container);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, TileEntity)},
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, Container)},
|
||||
* but creates a read-only label initialized to the specified value.
|
||||
*
|
||||
* @param fileSystem the file system to wrap.
|
||||
* @param label the read-only label of the file system.
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final TileEntity container) {
|
||||
public static ManagedEnvironment asManagedEnvironment(final li.cil.oc.api.fs.FileSystem fileSystem, final String label, final Container container) {
|
||||
if (instance != null)
|
||||
return instance.asManagedEnvironment(fileSystem, label, container);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, TileEntity)},
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, Container)},
|
||||
* but does not provide a container.
|
||||
*
|
||||
* @param fileSystem the file system to wrap.
|
||||
|
@ -1,10 +1,10 @@
|
||||
package li.cil.oc.api.detail;
|
||||
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import li.cil.oc.api.driver.Container;
|
||||
import li.cil.oc.api.fs.FileSystem;
|
||||
import li.cil.oc.api.fs.Label;
|
||||
import li.cil.oc.api.network.ManagedEnvironment;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public interface FileSystemAPI {
|
||||
/**
|
||||
@ -126,20 +126,20 @@ public interface FileSystemAPI {
|
||||
* @param container the tile entity containing the file system.
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, TileEntity container);
|
||||
ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, Label label, Container container);
|
||||
|
||||
/**
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, TileEntity)},
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, Container)},
|
||||
* but creates a read-only label initialized to the specified value.
|
||||
*
|
||||
* @param fileSystem the file system to wrap.
|
||||
* @param label the read-only label of the file system.
|
||||
* @return the network node wrapping the file system.
|
||||
*/
|
||||
ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, String label, TileEntity container);
|
||||
ManagedEnvironment asManagedEnvironment(FileSystem fileSystem, String label, Container container);
|
||||
|
||||
/**
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, TileEntity)},
|
||||
* Like {@link #asManagedEnvironment(li.cil.oc.api.fs.FileSystem, Label, Container)},
|
||||
* but does not provide a container.
|
||||
*
|
||||
* @param fileSystem the file system to wrap.
|
||||
|
52
src/main/java/li/cil/oc/api/driver/Container.java
Normal file
52
src/main/java/li/cil/oc/api/driver/Container.java
Normal file
@ -0,0 +1,52 @@
|
||||
package li.cil.oc.api.driver;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* To be implemented by 'hosts' of components.
|
||||
* <p/>
|
||||
* This is what's passed to drivers as the host when creating an environment.
|
||||
* It is generally used to represent the components' location in the world.
|
||||
* <p/>
|
||||
* You will only need to implement this if you intend to host components, e.g.
|
||||
* by providing a custom computer case or such. In OpenComputers this interface
|
||||
* is usually implemented directly by the tile entities acting as the host, so
|
||||
* in most cases you should be able to cast this to <tt>TileEntity</tt> for
|
||||
* more options, if necessary.
|
||||
*/
|
||||
public interface Container {
|
||||
/**
|
||||
* The world the container lives in.
|
||||
*/
|
||||
World world();
|
||||
|
||||
/**
|
||||
* The container's X position in the world.
|
||||
* <p/>
|
||||
* For tile entities this is the <em>centered</em> position. For example,
|
||||
* if the tile entity is located at (0, 2, 3) this will be 0.5.
|
||||
*/
|
||||
double xPosition();
|
||||
|
||||
/**
|
||||
* The container's Y position in the world.
|
||||
* <p/>
|
||||
* For tile entities this is the <em>centered</em> position. For example,
|
||||
* if the tile entity is located at (0, 2, 3) this will be 2.5.
|
||||
*/
|
||||
double yPosition();
|
||||
|
||||
/**
|
||||
* The container's Z position in the world.
|
||||
* <p/>
|
||||
* For tile entities this is the <em>centered</em> position. For example,
|
||||
* if the tile entity is located at (0, 2, 3) this will be 3.5.
|
||||
*/
|
||||
double zPosition();
|
||||
|
||||
/**
|
||||
* Marks the container as "changed" so that it knows it has to be saved
|
||||
* again in the next world save.
|
||||
*/
|
||||
void markChanged();
|
||||
}
|
@ -47,39 +47,21 @@ public interface Item {
|
||||
* there's a built-in driver for that. You may still opt to not implement
|
||||
* this - i.e. it is safe to return <tt>null</tt> here.
|
||||
* <p/>
|
||||
* Keep in mind that the tile entity's location may change if the owner is
|
||||
* Keep in mind that the container's location may change if the owner is
|
||||
* a robot. This is important if you cache the location somewhere. For
|
||||
* example, the wireless network card checks in it's update whether its
|
||||
* owner's position has changed to update the index structure used for
|
||||
* example, the wireless network card checks in a robot movement event
|
||||
* handler for position changes to update the index structure used for
|
||||
* receiver look-up.
|
||||
* <p/>
|
||||
* This is expected to return a <em>new instance</em> each time it is
|
||||
* called. The created instance's life cycle is managed by the computer or
|
||||
* other container that caused its creation.
|
||||
* called. The created instance's life cycle is managed by the container
|
||||
* that caused its creation.
|
||||
*
|
||||
* @param stack the item stack for which to get the environment.
|
||||
* @param container the tile entity the environment will be managed by.
|
||||
* @param container the container the environment will be managed by.
|
||||
* @return the environment for that item.
|
||||
*/
|
||||
ManagedEnvironment createEnvironment(ItemStack stack, TileEntity container);
|
||||
|
||||
/**
|
||||
* Create a new managed environment interfacing the specified item.
|
||||
* <p/>
|
||||
* This is the same as {@link #createEnvironment(net.minecraft.item.ItemStack, net.minecraft.tileentity.TileEntity)},
|
||||
* except that it allows specifying entities, such as players, as the
|
||||
* container of the environment, specifying information such as the
|
||||
* position in the world that way.
|
||||
* <p/>
|
||||
* Not all components will support both types of environment. If you only
|
||||
* intend your component to be used from within computers, for example,
|
||||
* it is safe to simply return <tt>null</tt> here.
|
||||
*
|
||||
* @param stack the item stack for which to get the environment.
|
||||
* @param container the entity the environment will be managed by.
|
||||
* @return the environment for that item.
|
||||
*/
|
||||
ManagedEnvironment createEnvironment(ItemStack stack, Entity container);
|
||||
ManagedEnvironment createEnvironment(ItemStack stack, Container container);
|
||||
|
||||
/**
|
||||
* The slot type of the specified item this driver supports.
|
||||
|
@ -5,7 +5,6 @@ import cpw.mods.fml.common.network.PacketDispatcher
|
||||
import cpw.mods.fml.common.network.Player
|
||||
import java.io.{OutputStream, ByteArrayOutputStream, DataOutputStream}
|
||||
import java.util.zip.GZIPOutputStream
|
||||
import li.cil.oc.server.component.Container
|
||||
import net.minecraft.entity.player.EntityPlayerMP
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.{CompressedStreamTools, NBTTagCompound}
|
||||
@ -14,6 +13,7 @@ import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
import li.cil.oc.api.driver.Container
|
||||
|
||||
// Necessary to keep track of the GZIP stream.
|
||||
abstract class PacketBuilderBase[T <: OutputStream](protected val stream: T) extends DataOutputStream(stream) {
|
||||
@ -40,7 +40,7 @@ abstract class PacketBuilderBase[T <: OutputStream](protected val stream: T) ext
|
||||
|
||||
def sendToNearbyPlayers(t: TileEntity, range: Double = 1024): Unit = sendToNearbyPlayers(t.getWorldObj, t.xCoord + 0.5, t.yCoord + 0.5, t.zCoord + 0.5, range)
|
||||
|
||||
def sendToNearbyPlayers(c: Container): Unit = sendToNearbyPlayers(c.world, c.x, c.y, c.z, 1024)
|
||||
def sendToNearbyPlayers(c: Container): Unit = sendToNearbyPlayers(c.world, c.xPosition, c.yPosition, c.zPosition, 1024)
|
||||
|
||||
def sendToNearbyPlayers(world: World, x: Double, y: Double, z: Double, range: Double) {
|
||||
val dimension = world.provider.dimensionId
|
||||
|
@ -1,31 +1,31 @@
|
||||
package li.cil.oc.common
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import scala.collection.mutable
|
||||
import li.cil.oc.api.driver.Container
|
||||
|
||||
object Sound {
|
||||
val lastPlayed = mutable.WeakHashMap.empty[TileEntity, Long]
|
||||
val lastPlayed = mutable.WeakHashMap.empty[Container, Long]
|
||||
|
||||
def play(t: TileEntity, name: String) {
|
||||
t.getWorldObj.playSoundEffect(t.xCoord + 0.5, t.yCoord + 0.5, t.zCoord + 0.5, Settings.resourceDomain + ":" + name, 1, 1)
|
||||
def play(container: Container, name: String) {
|
||||
container.world.playSoundEffect(container.xPosition, container.yPosition, container.zPosition, Settings.resourceDomain + ":" + name, 1, 1)
|
||||
}
|
||||
|
||||
def playDiskInsert(t: TileEntity) {
|
||||
play(t, "floppy_insert")
|
||||
def playDiskInsert(container: Container) {
|
||||
play(container, "floppy_insert")
|
||||
}
|
||||
|
||||
def playDiskEject(t: TileEntity) {
|
||||
play(t, "floppy_eject")
|
||||
def playDiskEject(container: Container) {
|
||||
play(container, "floppy_eject")
|
||||
}
|
||||
|
||||
def playDiskActivity(t: TileEntity, isFloppy: Boolean) = this.synchronized {
|
||||
lastPlayed.get(t) match {
|
||||
def playDiskActivity(container: Container, isFloppy: Boolean) = this.synchronized {
|
||||
lastPlayed.get(container) match {
|
||||
case Some(time) if time > System.currentTimeMillis() => // Cooldown.
|
||||
case _ =>
|
||||
if (isFloppy) play(t, "floppy_access")
|
||||
else play(t, "hdd_access")
|
||||
lastPlayed += t -> (System.currentTimeMillis() + 500)
|
||||
if (isFloppy) play(container, "floppy_access")
|
||||
else play(container, "hdd_access")
|
||||
lastPlayed += container -> (System.currentTimeMillis() + 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,12 @@ import cpw.mods.fml.common.FMLCommonHandler
|
||||
import cpw.mods.fml.relauncher.{SideOnly, Side}
|
||||
import li.cil.oc.{api, Settings}
|
||||
import li.cil.oc.api.component.TextBuffer.ColorDepth
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.client.{PacketSender => ClientPacketSender, ComponentTracker => ClientComponentTracker}
|
||||
import li.cil.oc.client.renderer.{MonospaceFontRenderer, TextBufferRenderCache}
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.server.{PacketSender => ServerPacketSender, ComponentTracker => ServerComponentTracker, component}
|
||||
import li.cil.oc.server.{PacketSender => ServerPacketSender, ComponentTracker => ServerComponentTracker}
|
||||
import li.cil.oc.util
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import li.cil.oc.util.PackedColor
|
||||
@ -16,7 +17,7 @@ import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import scala.collection.convert.WrapAsScala._
|
||||
|
||||
class TextBuffer(val owner: component.Container) extends ManagedComponent with api.component.TextBuffer {
|
||||
class TextBuffer(val owner: Container) extends ManagedComponent with api.component.TextBuffer {
|
||||
val node = api.Network.newNode(this, Visibility.Network).
|
||||
withComponent("screen").
|
||||
withConnector().
|
||||
|
@ -49,7 +49,7 @@ object ChunkloaderUpgradeHandler extends LoadingCallback {
|
||||
}
|
||||
|
||||
def updateLoadedChunk(loader: UpgradeChunkloader) {
|
||||
val robotChunk = new ChunkCoordIntPair(loader.robot.xCoord / 16, loader.robot.zCoord / 16)
|
||||
val robotChunk = new ChunkCoordIntPair(loader.owner.xPosition.toInt / 16, loader.owner.zPosition.toInt / 16)
|
||||
loader.ticket.foreach(ticket => {
|
||||
ticket.getChunkList.collect {
|
||||
case chunk: ChunkCoordIntPair if chunk != robotChunk => ForgeChunkManager.unforceChunk(ticket, chunk)
|
||||
|
@ -3,7 +3,7 @@ package li.cil.oc.common.inventory
|
||||
import java.util.logging.Level
|
||||
import li.cil.oc.OpenComputers
|
||||
import li.cil.oc.api.Driver
|
||||
import li.cil.oc.api.driver.{Item => ItemDriver}
|
||||
import li.cil.oc.api.driver.{Item => ItemDriver, Container}
|
||||
import li.cil.oc.api.network
|
||||
import li.cil.oc.api.network.{Node, ManagedEnvironment}
|
||||
import li.cil.oc.server.driver.item.Item
|
||||
@ -19,7 +19,7 @@ trait ComponentInventory extends Inventory with network.Environment {
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
def componentContainer: TileEntity
|
||||
def componentContainer: Container
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
|
@ -11,6 +11,7 @@ import net.minecraft.item.{EnumRarity, ItemStack}
|
||||
import net.minecraft.util.{StatCollector, Icon}
|
||||
import net.minecraft.world.World
|
||||
import org.lwjgl.input
|
||||
import net.minecraft.entity.Entity
|
||||
|
||||
trait Delegate {
|
||||
val parent: Delegator
|
||||
@ -43,6 +44,8 @@ trait Delegate {
|
||||
stack
|
||||
}
|
||||
|
||||
def update(stack: ItemStack, world: World, player: Entity, slot: Int, selected: Boolean) {}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
def rarity = EnumRarity.common
|
||||
|
@ -12,6 +12,7 @@ import net.minecraft.util.{WeightedRandomChestContent, Icon}
|
||||
import net.minecraft.world.World
|
||||
import net.minecraftforge.common.ChestGenHooks
|
||||
import scala.collection.mutable
|
||||
import net.minecraft.entity.Entity
|
||||
|
||||
class Delegator(id: Int) extends Item(id) {
|
||||
setHasSubtypes(true)
|
||||
@ -130,6 +131,13 @@ class Delegator(id: Int) extends Item(id) {
|
||||
case _ => super.getMaxDamage(stack)
|
||||
}
|
||||
|
||||
|
||||
override def onUpdate(stack: ItemStack, world: World, player: Entity, slot: Int, selected: Boolean) =
|
||||
subItem(stack) match {
|
||||
case Some(subItem) => subItem.update(stack, world, player, slot, selected)
|
||||
case _ => super.onUpdate(stack, world, player, slot, selected)
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def getIcon(stack: ItemStack, pass: Int) =
|
||||
subItem(stack) match {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package li.cil.oc.common.tileentity.traits
|
||||
|
||||
import li.cil.oc.api.driver
|
||||
import li.cil.oc.api.network
|
||||
import li.cil.oc.api.network.{Connector, SidedEnvironment}
|
||||
import li.cil.oc.server.TickHandler
|
||||
@ -9,7 +10,17 @@ import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
import scala.math.ScalaNumber
|
||||
|
||||
trait Environment extends TileEntity with network.Environment {
|
||||
trait Environment extends TileEntity with network.Environment with driver.Container {
|
||||
override def xPosition = x + 0.5
|
||||
|
||||
override def yPosition = y + 0.5
|
||||
|
||||
override def zPosition = z + 0.5
|
||||
|
||||
override def markChanged() = onInventoryChanged()
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override protected def initialize() {
|
||||
super.initialize()
|
||||
if (isServer) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package li.cil.oc.server
|
||||
|
||||
import li.cil.oc.api.component.TextBuffer.ColorDepth
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.common.tileentity.traits._
|
||||
import li.cil.oc.common.{CompressedPacketBuilder, PacketBuilder, PacketType}
|
||||
@ -8,8 +10,6 @@ import net.minecraft.entity.player.EntityPlayerMP
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
import net.minecraft.world.World
|
||||
import li.cil.oc.api.component.TextBuffer.ColorDepth
|
||||
import li.cil.oc.server.component.Container
|
||||
|
||||
object PacketSender {
|
||||
def sendAbstractBusState(t: AbstractBusAware) {
|
||||
|
@ -1,51 +0,0 @@
|
||||
package li.cil.oc.server.component
|
||||
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.world.World
|
||||
|
||||
trait Container {
|
||||
def tileEntity: Option[TileEntity] = None
|
||||
|
||||
def entity: Option[Entity] = None
|
||||
|
||||
def world: World
|
||||
|
||||
def x: Double
|
||||
|
||||
def y: Double
|
||||
|
||||
def z: Double
|
||||
|
||||
def markChanged() {}
|
||||
}
|
||||
|
||||
object Container {
|
||||
|
||||
case class TileEntityContainer(container: TileEntity) extends Container {
|
||||
override def tileEntity = Option(container)
|
||||
|
||||
override def world = container.getWorldObj
|
||||
|
||||
override def x = container.xCoord + 0.5
|
||||
|
||||
override def y = container.yCoord + 0.5
|
||||
|
||||
override def z = container.zCoord + 0.5
|
||||
|
||||
override def markChanged() = container.onInventoryChanged()
|
||||
}
|
||||
|
||||
case class EntityContainer(container: Entity) extends Container {
|
||||
override def entity = Option(container)
|
||||
|
||||
override def world = container.worldObj
|
||||
|
||||
override def x = container.posX
|
||||
|
||||
override def y = container.posY
|
||||
|
||||
override def z = container.posZ
|
||||
}
|
||||
|
||||
}
|
@ -3,6 +3,7 @@ package li.cil.oc.server.component
|
||||
import java.io.{FileNotFoundException, IOException}
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.fs.{Label, Mode, FileSystem => IFileSystem}
|
||||
import li.cil.oc.api.Network
|
||||
import li.cil.oc.api.network._
|
||||
@ -12,12 +13,11 @@ import li.cil.oc.server.driver.item.{CC16Media, CC15Media}
|
||||
import li.cil.oc.server.driver.item.FileSystem.ItemLabel
|
||||
import li.cil.oc.util.ExtendedNBT._
|
||||
import li.cil.oc.util.mods.Mods
|
||||
import net.minecraft.nbt.{NBTTagInt, NBTTagList, NBTTagCompound}
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import scala.collection.mutable
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.{NBTTagInt, NBTTagList, NBTTagCompound}
|
||||
import scala.collection.mutable
|
||||
|
||||
class FileSystem(val fileSystem: IFileSystem, var label: Label, val container: Option[TileEntity] = None) extends ManagedComponent {
|
||||
class FileSystem(val fileSystem: IFileSystem, var label: Label, val container: Option[Container] = None) extends ManagedComponent {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("filesystem", Visibility.Neighbors).
|
||||
withConnector().
|
||||
@ -319,25 +319,25 @@ class FileSystem(val fileSystem: IFileSystem, var label: Label, val container: O
|
||||
private def isHardDisk(stack: ItemStack) = hdds contains api.Items.get(stack)
|
||||
|
||||
private def makeSomeNoise() {
|
||||
container.foreach(t =>
|
||||
container.foreach(c =>
|
||||
// Well, this is hacky as shit, but who cares.
|
||||
label match {
|
||||
case item: ItemLabel =>
|
||||
if (isFloppy(item.stack)) {
|
||||
Sound.playDiskActivity(t, isFloppy = true)
|
||||
Sound.playDiskActivity(c, isFloppy = true)
|
||||
}
|
||||
else if (isHardDisk(item.stack)) {
|
||||
Sound.playDiskActivity(t, isFloppy = false)
|
||||
Sound.playDiskActivity(c, isFloppy = false)
|
||||
}
|
||||
case _ =>
|
||||
if (Mods.ComputerCraft15.isAvailable) {
|
||||
if (label.isInstanceOf[CC15Media.ComputerCraftLabel]) {
|
||||
Sound.playDiskActivity(t, isFloppy = true)
|
||||
Sound.playDiskActivity(c, isFloppy = true)
|
||||
}
|
||||
}
|
||||
if (Mods.ComputerCraft16.isAvailable) {
|
||||
if (label.isInstanceOf[CC16Media.ComputerCraftLabel]) {
|
||||
Sound.playDiskActivity(t, isFloppy = true)
|
||||
Sound.playDiskActivity(c, isFloppy = true)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -5,18 +5,18 @@ import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.Network
|
||||
import li.cil.oc.api.component.Keyboard.UsabilityChecker
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.network.{Node, Visibility, Message}
|
||||
import li.cil.oc.common.component.ManagedComponent
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.event.{Event, ForgeSubscribe}
|
||||
import scala.collection.mutable
|
||||
import li.cil.oc.server.component
|
||||
|
||||
// TODO key up when screen is disconnected from which the key down came
|
||||
// TODO key up after load for anything that was pressed
|
||||
|
||||
class Keyboard(val owner: component.Container) extends ManagedComponent with api.component.Keyboard {
|
||||
class Keyboard(val owner: Container) extends ManagedComponent with api.component.Keyboard {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("keyboard").
|
||||
create()
|
||||
@ -102,7 +102,7 @@ class Keyboard(val owner: component.Container) extends ManagedComponent with api
|
||||
|
||||
def isUseableByPlayer(p: EntityPlayer) = usableOverride match {
|
||||
case Some(callback) => callback.isUsableByPlayer(this, p)
|
||||
case _ => p.getDistanceSq(owner.x + 0.5, owner.y + 0.5, owner.z + 0.5) <= 64
|
||||
case _ => p.getDistanceSq(owner.xPosition, owner.yPosition, owner.zPosition) <= 64
|
||||
}
|
||||
|
||||
protected def signal(args: AnyRef*) =
|
||||
|
@ -2,15 +2,14 @@ package li.cil.oc.server.component
|
||||
|
||||
import li.cil.oc.{Settings, OpenComputers}
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.machine.Robot
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.common.component.ManagedComponent
|
||||
import li.cil.oc.common.event.ChunkloaderUpgradeHandler
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.ForgeChunkManager
|
||||
import net.minecraftforge.common.ForgeChunkManager.Ticket
|
||||
import li.cil.oc.api.driver.Container
|
||||
|
||||
class UpgradeChunkloader(val robot: TileEntity with Robot) extends ManagedComponent {
|
||||
class UpgradeChunkloader(val owner: Container) extends ManagedComponent {
|
||||
val node = api.Network.newNode(this, Visibility.Network).
|
||||
withComponent("chunkloader").
|
||||
withConnector().
|
||||
@ -22,7 +21,7 @@ class UpgradeChunkloader(val robot: TileEntity with Robot) extends ManagedCompon
|
||||
|
||||
override def update() {
|
||||
super.update()
|
||||
if (robot.getWorldObj.getWorldTime % Settings.get.tickFrequency == 0 && ticket.isDefined) {
|
||||
if (owner.world.getWorldTime % Settings.get.tickFrequency == 0 && ticket.isDefined) {
|
||||
if (!node.tryChangeBuffer(-Settings.get.chunkloaderCost * Settings.get.tickFrequency)) {
|
||||
ticket.foreach(ForgeChunkManager.releaseTicket)
|
||||
ticket = None
|
||||
@ -37,7 +36,7 @@ class UpgradeChunkloader(val robot: TileEntity with Robot) extends ManagedCompon
|
||||
def setActive(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val enabled = args.checkBoolean(0)
|
||||
if (enabled && ticket.isEmpty) {
|
||||
ticket = Option(ForgeChunkManager.requestTicket(OpenComputers, robot.getWorldObj, ForgeChunkManager.Type.NORMAL))
|
||||
ticket = Option(ForgeChunkManager.requestTicket(OpenComputers, owner.world, ForgeChunkManager.Type.NORMAL))
|
||||
ChunkloaderUpgradeHandler.updateLoadedChunk(this)
|
||||
}
|
||||
else if (!enabled && ticket.isDefined) {
|
||||
@ -51,7 +50,7 @@ class UpgradeChunkloader(val robot: TileEntity with Robot) extends ManagedCompon
|
||||
super.onConnect(node)
|
||||
if (node == this.node) {
|
||||
ticket = ChunkloaderUpgradeHandler.restoredTickets.remove(node.address).
|
||||
orElse(Option(ForgeChunkManager.requestTicket(OpenComputers, robot.getWorldObj, ForgeChunkManager.Type.NORMAL)))
|
||||
orElse(Option(ForgeChunkManager.requestTicket(OpenComputers, owner.world, ForgeChunkManager.Type.NORMAL)))
|
||||
ChunkloaderUpgradeHandler.updateLoadedChunk(this)
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package li.cil.oc.server.component
|
||||
|
||||
import cpw.mods.fml.common.registry.GameRegistry
|
||||
import li.cil.oc.api.Network
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.machine.Robot
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.common.component.ManagedComponent
|
||||
@ -9,12 +10,11 @@ import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.inventory
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.item.crafting.CraftingManager
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.MinecraftForge
|
||||
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent
|
||||
import scala.collection.mutable
|
||||
|
||||
class UpgradeCrafting(val owner: TileEntity with Robot) extends ManagedComponent {
|
||||
class UpgradeCrafting(val owner: Container with Robot) extends ManagedComponent {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("crafting").
|
||||
create()
|
||||
@ -33,7 +33,7 @@ class UpgradeCrafting(val owner: TileEntity with Robot) extends ManagedComponent
|
||||
def craft(wantedCount: Int): Boolean = {
|
||||
load()
|
||||
val manager = CraftingManager.getInstance
|
||||
val result = manager.findMatchingRecipe(CraftingInventory, owner.getWorldObj)
|
||||
val result = manager.findMatchingRecipe(CraftingInventory, owner.world)
|
||||
if (result == null) return false
|
||||
val targetStackSize = if (result.isStackable) math.min(wantedCount, result.getMaxStackSize) else result.stackSize
|
||||
val timesCrafted = math.min(targetStackSize / result.stackSize, amountPossible)
|
||||
|
@ -9,9 +9,10 @@ import li.cil.oc.util.ExtendedNBT._
|
||||
import net.minecraft.entity.item.EntityItem
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.tileentity.{TileEntity, TileEntityFurnace}
|
||||
import net.minecraft.tileentity.TileEntityFurnace
|
||||
import li.cil.oc.api.driver.Container
|
||||
|
||||
class UpgradeGenerator(val owner: TileEntity with Robot) extends ManagedComponent {
|
||||
class UpgradeGenerator(val owner: Container with Robot) extends ManagedComponent {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("generator", Visibility.Neighbors).
|
||||
withConnector().
|
||||
@ -119,11 +120,8 @@ class UpgradeGenerator(val owner: TileEntity with Robot) extends ManagedComponen
|
||||
if (node == this.node) {
|
||||
inventory match {
|
||||
case Some(stack) =>
|
||||
val world = owner.getWorldObj
|
||||
val x = owner.xCoord
|
||||
val y = owner.yCoord
|
||||
val z = owner.zCoord
|
||||
val entity = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, stack.copy())
|
||||
val world = owner.world
|
||||
val entity = new EntityItem(world, owner.xPosition, owner.yPosition, owner.zPosition, stack.copy())
|
||||
entity.motionY = 0.04
|
||||
entity.delayBeforeCanPickup = 5
|
||||
world.spawnEntityInWorld(entity)
|
||||
|
@ -7,9 +7,9 @@ import li.cil.oc.api.network._
|
||||
import li.cil.oc.common.component.ManagedComponent
|
||||
import li.cil.oc.util.InventoryUtils
|
||||
import li.cil.oc.util.ExtendedArguments._
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import li.cil.oc.api.driver.Container
|
||||
|
||||
class UpgradeInventoryController(val owner: TileEntity with Robot) extends ManagedComponent {
|
||||
class UpgradeInventoryController(val owner: Container with Robot) extends ManagedComponent {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("inventory_controller", Visibility.Neighbors).
|
||||
withConnector().
|
||||
@ -20,7 +20,7 @@ class UpgradeInventoryController(val owner: TileEntity with Robot) extends Manag
|
||||
@Callback(doc = """function():number -- Get the number of slots in the inventory on the specified side of the robot.""")
|
||||
def getInventorySize(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val facing = checkSideForAction(args, 0)
|
||||
InventoryUtils.inventoryAt(owner.getWorldObj, owner.xCoord + facing.offsetX, owner.yCoord + facing.offsetY, owner.zCoord + facing.offsetZ) match {
|
||||
InventoryUtils.inventoryAt(owner.world, owner.xPosition.toInt + facing.offsetX, owner.yPosition.toInt + facing.offsetY, owner.zPosition.toInt + facing.offsetZ) match {
|
||||
case Some(inventory) => result(inventory.getSizeInventory)
|
||||
case _ => result(Unit, "no inventory")
|
||||
}
|
||||
@ -33,7 +33,7 @@ class UpgradeInventoryController(val owner: TileEntity with Robot) extends Manag
|
||||
val selectedSlot = owner.selectedSlot
|
||||
val stack = owner.getStackInSlot(selectedSlot)
|
||||
if (stack != null && stack.stackSize > 0) {
|
||||
InventoryUtils.inventoryAt(owner.getWorldObj, owner.xCoord + facing.offsetX, owner.yCoord + facing.offsetY, owner.zCoord + facing.offsetZ) match {
|
||||
InventoryUtils.inventoryAt(owner.world, owner.xPosition.toInt + facing.offsetX, owner.yPosition.toInt + facing.offsetY, owner.zPosition.toInt + facing.offsetZ) match {
|
||||
case Some(inventory) =>
|
||||
val slot = args.checkSlot(inventory, 1)
|
||||
if (!InventoryUtils.insertIntoInventorySlot(stack, inventory, facing.getOpposite, slot, count)) {
|
||||
@ -63,7 +63,7 @@ class UpgradeInventoryController(val owner: TileEntity with Robot) extends Manag
|
||||
val facing = checkSideForAction(args, 0)
|
||||
val count = args.optionalItemCount(2)
|
||||
|
||||
InventoryUtils.inventoryAt(owner.getWorldObj, owner.xCoord + facing.offsetX, owner.yCoord + facing.offsetY, owner.zCoord + facing.offsetZ) match {
|
||||
InventoryUtils.inventoryAt(owner.world, owner.xPosition.toInt + facing.offsetX, owner.yPosition.toInt + facing.offsetY, owner.zPosition.toInt + facing.offsetZ) match {
|
||||
case Some(inventory) =>
|
||||
val slot = args.checkSlot(inventory, 1)
|
||||
if (InventoryUtils.extractFromInventorySlot(owner.player.inventory.addItemStackToInventory, inventory, facing.getOpposite, slot, count)) {
|
||||
@ -88,7 +88,5 @@ class UpgradeInventoryController(val owner: TileEntity with Robot) extends Manag
|
||||
else result(false)
|
||||
}
|
||||
|
||||
private def checkSlot(args: Arguments, n: Int) = args.checkSlot(owner, n)
|
||||
|
||||
private def checkSideForAction(args: Arguments, n: Int) = owner.toGlobal(args.checkSideForAction(n))
|
||||
}
|
||||
|
@ -1,13 +1,13 @@
|
||||
package li.cil.oc.server.component
|
||||
|
||||
import li.cil.oc.api.{Rotatable, Network}
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.common.component.ManagedComponent
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import li.cil.oc.util.ItemUtils.NavigationUpgradeData
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
class UpgradeNavigation(val owner: TileEntity) extends ManagedComponent {
|
||||
class UpgradeNavigation(val owner: Container with Rotatable) extends ManagedComponent {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("navigation", Visibility.Neighbors).
|
||||
create()
|
||||
@ -18,31 +18,23 @@ class UpgradeNavigation(val owner: TileEntity) extends ManagedComponent {
|
||||
|
||||
@Callback(doc = """function():number, number, number -- Get the current relative position of the robot.""")
|
||||
def getPosition(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val info = data.mapData(owner.getWorldObj)
|
||||
val info = data.mapData(owner.world)
|
||||
val size = 128 * (1 << info.scale)
|
||||
val x = owner.xCoord
|
||||
val y = owner.yCoord
|
||||
val z = owner.zCoord
|
||||
val relativeX = x - info.xCenter
|
||||
val relativeZ = z - info.zCenter
|
||||
val relativeX = owner.xPosition - info.xCenter
|
||||
val relativeZ = owner.zPosition - info.zCenter
|
||||
|
||||
if (math.abs(relativeX) <= size / 2 && math.abs(relativeZ) <= size / 2)
|
||||
result(relativeX, y, relativeZ)
|
||||
result(relativeX, owner.yPosition, relativeZ)
|
||||
else
|
||||
result(Unit, "out of range")
|
||||
}
|
||||
|
||||
@Callback(doc = """function():number -- Get the current orientation of the robot.""")
|
||||
def getFacing(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
owner match {
|
||||
case rotatable: Rotatable => result(rotatable.facing.ordinal)
|
||||
case _ => throw new Exception("illegal state")
|
||||
}
|
||||
}
|
||||
def getFacing(context: Context, args: Arguments): Array[AnyRef] = result(owner.facing.ordinal)
|
||||
|
||||
@Callback(doc = """function():number -- Get the operational range of the navigation upgrade.""")
|
||||
def getRange(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val info = data.mapData(owner.getWorldObj)
|
||||
val info = data.mapData(owner.world)
|
||||
val size = 128 * (1 << info.scale)
|
||||
result(size / 2)
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package li.cil.oc.server.component
|
||||
|
||||
import li.cil.oc.api.{Rotatable, Network}
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.common.component.ManagedComponent
|
||||
import net.minecraft.tileentity.{TileEntity, TileEntitySign}
|
||||
import net.minecraft.tileentity.TileEntitySign
|
||||
|
||||
class UpgradeSign(val owner: TileEntity) extends ManagedComponent {
|
||||
class UpgradeSign(val owner: Container with Rotatable) extends ManagedComponent {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("sign", Visibility.Neighbors).
|
||||
withConnector().
|
||||
@ -15,11 +16,8 @@ class UpgradeSign(val owner: TileEntity) extends ManagedComponent {
|
||||
|
||||
@Callback(doc = """function():string -- Get the text on the sign in front of the robot.""")
|
||||
def getValue(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val facing = owner match {
|
||||
case rotatable: Rotatable => rotatable.facing
|
||||
case _ => throw new Exception("illegal state")
|
||||
}
|
||||
owner.getWorldObj.getBlockTileEntity(owner.xCoord + facing.offsetX, owner.yCoord + facing.offsetY, owner.zCoord + facing.offsetZ) match {
|
||||
val facing = owner.facing
|
||||
owner.world.getBlockTileEntity(owner.xPosition.toInt + facing.offsetX, owner.yPosition.toInt + facing.offsetY, owner.zPosition.toInt + facing.offsetZ) match {
|
||||
case sign: TileEntitySign => result(sign.signText.mkString("\n"))
|
||||
case _ => result(Unit, "no sign")
|
||||
}
|
||||
@ -28,15 +26,12 @@ class UpgradeSign(val owner: TileEntity) extends ManagedComponent {
|
||||
@Callback(doc = """function(value:string):string -- Set the text on the sign in front of the robot.""")
|
||||
def setValue(context: Context, args: Arguments): Array[AnyRef] = {
|
||||
val text = args.checkString(0).lines.padTo(4, "").map(line => if (line.length > 15) line.substring(0, 15) else line)
|
||||
val facing = owner match {
|
||||
case rotatable: Rotatable => rotatable.facing
|
||||
case _ => throw new Exception("illegal state")
|
||||
}
|
||||
val (sx, sy, sz) = (owner.xCoord + facing.offsetX, owner.yCoord + facing.offsetY, owner.zCoord + facing.offsetZ)
|
||||
owner.getWorldObj.getBlockTileEntity(sx, sy, sz) match {
|
||||
val facing = owner.facing
|
||||
val (sx, sy, sz) = (owner.xPosition.toInt + facing.offsetX, owner.yPosition.toInt + facing.offsetY, owner.zPosition.toInt + facing.offsetZ)
|
||||
owner.world.getBlockTileEntity(sx, sy, sz) match {
|
||||
case sign: TileEntitySign =>
|
||||
text.copyToArray(sign.signText)
|
||||
owner.getWorldObj.markBlockForUpdate(sx, sy, sz)
|
||||
owner.world.markBlockForUpdate(sx, sy, sz)
|
||||
result(sign.signText.mkString("\n"))
|
||||
case _ => result(Unit, "no sign")
|
||||
}
|
||||
|
@ -2,13 +2,13 @@ package li.cil.oc.server.component
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.Network
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.network.Visibility
|
||||
import li.cil.oc.common.component.ManagedComponent
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraft.world.World
|
||||
import net.minecraft.world.biome.BiomeGenDesert
|
||||
|
||||
class UpgradeSolarGenerator(val owner: TileEntity) extends ManagedComponent {
|
||||
class UpgradeSolarGenerator(val owner: Container) extends ManagedComponent {
|
||||
val node = Network.newNode(this, Visibility.Network).
|
||||
withConnector().
|
||||
create()
|
||||
@ -27,11 +27,7 @@ class UpgradeSolarGenerator(val owner: TileEntity) extends ManagedComponent {
|
||||
ticksUntilCheck -= 1
|
||||
if (ticksUntilCheck <= 0) {
|
||||
ticksUntilCheck = 100
|
||||
val world = owner.getWorldObj
|
||||
val x = owner.xCoord
|
||||
val y = owner.yCoord
|
||||
val z = owner.zCoord
|
||||
isSunShining = isSunVisible(world, x, y + 1, z)
|
||||
isSunShining = isSunVisible(owner.world, owner.xPosition.toInt, owner.yPosition.toInt + 1, owner.zPosition.toInt)
|
||||
}
|
||||
if (isSunShining) {
|
||||
node.changeBuffer(Settings.get.solarGeneratorEfficiency)
|
||||
|
@ -2,13 +2,13 @@ package li.cil.oc.server.component
|
||||
|
||||
import java.io._
|
||||
import li.cil.oc.api.Network
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.network._
|
||||
import li.cil.oc.{api, Settings}
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import scala.language.implicitConversions
|
||||
|
||||
class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard with WirelessEndpoint {
|
||||
class WirelessNetworkCard(val owner: Container) extends NetworkCard with WirelessEndpoint {
|
||||
override val node = Network.newNode(this, Visibility.Network).
|
||||
withComponent("modem", Visibility.Neighbors).
|
||||
withConnector().
|
||||
@ -18,13 +18,13 @@ class WirelessNetworkCard(val owner: TileEntity) extends NetworkCard with Wirele
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def x = owner.xCoord
|
||||
override def x = owner.xPosition.toInt
|
||||
|
||||
override def y = owner.yCoord
|
||||
override def y = owner.yPosition.toInt
|
||||
|
||||
override def z = owner.zCoord
|
||||
override def z = owner.zPosition.toInt
|
||||
|
||||
override def world = owner.getWorldObj
|
||||
override def world = owner.world
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.util.mods.Mods
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -10,7 +10,7 @@ import stargatetech2.api.bus.IBusDevice
|
||||
object AbstractBusCard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("abstractBusCard"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = if (Mods.StargateTech2.isAvailable) container match {
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = if (Mods.StargateTech2.isAvailable) container match {
|
||||
case device: IBusDevice => new component.AbstractBus(device)
|
||||
case _ => null
|
||||
}
|
||||
|
@ -2,21 +2,20 @@ package li.cil.oc.server.driver.item
|
||||
|
||||
import dan200.computer.api.IMedia
|
||||
import li.cil.oc
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.api.fs.Label
|
||||
import li.cil.oc.util.mods.{ComputerCraft15, Mods}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import li.cil.oc.server.component
|
||||
|
||||
object CC15Media extends Item {
|
||||
override def slot(stack: ItemStack) = Slot.Disk
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
if (Mods.ComputerCraft15.isAvailable && ComputerCraft15.isDisk(stack) && container != null) {
|
||||
val address = addressFromTag(dataTag(stack))
|
||||
val mount = ComputerCraft15.createDiskMount(stack, container.world)
|
||||
Option(oc.api.FileSystem.asManagedEnvironment(mount, new ComputerCraftLabel(stack), container.tileEntity.orNull)) match {
|
||||
Option(oc.api.FileSystem.asManagedEnvironment(mount, new ComputerCraftLabel(stack), container)) match {
|
||||
case Some(environment) =>
|
||||
environment.node.asInstanceOf[oc.server.network.Node].address = address
|
||||
environment
|
||||
|
@ -1,22 +1,21 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import net.minecraft.item.ItemStack
|
||||
import li.cil.oc.util.mods.{ComputerCraft16, Mods}
|
||||
import li.cil.oc
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.api.fs.Label
|
||||
import li.cil.oc.util.mods.{ComputerCraft16, Mods}
|
||||
import dan200.computercraft.api.media.IMedia
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.server.component
|
||||
|
||||
object CC16Media extends Item {
|
||||
override def slot(stack: ItemStack) = Slot.Disk
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
if (Mods.ComputerCraft16.isAvailable && ComputerCraft16.isDisk(stack) && container != null) {
|
||||
val address = addressFromTag(dataTag(stack))
|
||||
val mount = ComputerCraft16.createDiskMount(stack, container.world)
|
||||
Option(oc.api.FileSystem.asManagedEnvironment(mount, new ComputerCraftLabel(stack), container.tileEntity.orNull)) match {
|
||||
Option(oc.api.FileSystem.asManagedEnvironment(mount, new ComputerCraftLabel(stack), container)) match {
|
||||
case Some(environment) =>
|
||||
environment.node.asInstanceOf[oc.server.network.Node].address = address
|
||||
environment
|
||||
|
@ -1,19 +1,18 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.api.fs.Label
|
||||
import li.cil.oc.common.item.{FloppyDisk, HardDiskDrive}
|
||||
import li.cil.oc.{api, Settings, Items}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import li.cil.oc.server.component
|
||||
|
||||
object FileSystem extends Item {
|
||||
override def worksWith(stack: ItemStack) =
|
||||
isOneOf(stack, api.Items.get("hdd1"), api.Items.get("hdd2"), api.Items.get("hdd3"), api.Items.get("floppy"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
Items.multi.subItem(stack) match {
|
||||
case Some(hdd: HardDiskDrive) => createEnvironment(stack, hdd.kiloBytes * 1024, container)
|
||||
case Some(disk: FloppyDisk) => createEnvironment(stack, Settings.get.floppySize * 1024, container)
|
||||
@ -33,13 +32,13 @@ object FileSystem extends Item {
|
||||
case _ => 0
|
||||
}
|
||||
|
||||
private def createEnvironment(stack: ItemStack, capacity: Int, container: component.Container) = {
|
||||
private def createEnvironment(stack: ItemStack, capacity: Int, container: Container) = {
|
||||
// We have a bit of a chicken-egg problem here, because we want to use the
|
||||
// node's address as the folder name... so we generate the address here,
|
||||
// if necessary. No one will know, right? Right!?
|
||||
val address = addressFromTag(dataTag(stack))
|
||||
val fs = oc.api.FileSystem.fromSaveDirectory(address, capacity, Settings.get.bufferChanges)
|
||||
val environment = oc.api.FileSystem.asManagedEnvironment(fs, new ItemLabel(stack), container.tileEntity.orNull)
|
||||
val environment = oc.api.FileSystem.asManagedEnvironment(fs, new ItemLabel(stack), container)
|
||||
if (environment != null && environment.node != null) {
|
||||
environment.node.asInstanceOf[oc.server.network.Node].address = address
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.{api, Items, common}
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object GraphicsCard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("graphicsCard1"), api.Items.get("graphicsCard2"), api.Items.get("graphicsCard3"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
Items.multi.subItem(stack) match {
|
||||
case Some(gpu: common.item.GraphicsCard) => gpu.tier match {
|
||||
case 0 => new component.GraphicsCard.Tier1()
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack
|
||||
object InternetCard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("internetCard"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = new component.InternetCard()
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.InternetCard()
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Card
|
||||
|
||||
|
@ -3,14 +3,9 @@ package li.cil.oc.server.driver.item
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver
|
||||
import li.cil.oc.api.network.ManagedEnvironment
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component.Container
|
||||
import li.cil.oc.server.component.Container.{EntityContainer, TileEntityContainer}
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
|
||||
trait Item extends driver.Item {
|
||||
override def tier(stack: ItemStack) = Tier.One
|
||||
@ -18,12 +13,6 @@ trait Item extends driver.Item {
|
||||
override def dataTag(stack: ItemStack) = Item.dataTag(stack)
|
||||
|
||||
protected def isOneOf(stack: ItemStack, items: api.detail.ItemInfo*) = items.contains(api.Items.get(stack))
|
||||
|
||||
final override def createEnvironment(stack: ItemStack, container: TileEntity) = createEnvironment(stack, TileEntityContainer(container))
|
||||
|
||||
final override def createEnvironment(stack: ItemStack, container: Entity) = createEnvironment(stack, EntityContainer(container))
|
||||
|
||||
protected def createEnvironment(stack: ItemStack, container: Container): ManagedEnvironment
|
||||
}
|
||||
|
||||
object Item {
|
||||
|
@ -1,14 +1,14 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object Keyboard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("keyboard"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = new component.Keyboard(container)
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.Keyboard(container)
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Upgrade
|
||||
}
|
||||
|
@ -1,15 +1,15 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
|
||||
object LinkedCard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("linkedCard"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = new component.LinkedCard()
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.LinkedCard()
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Card
|
||||
|
||||
|
@ -2,20 +2,14 @@ package li.cil.oc.server.driver.item
|
||||
|
||||
import java.io
|
||||
import li.cil.oc.{api, OpenComputers, Settings}
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraftforge.common.DimensionManager
|
||||
|
||||
object Loot extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("lootDisk"), api.Items.get("openOS"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
createEnvironment(stack, 0, container)
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Disk
|
||||
|
||||
private def createEnvironment(stack: ItemStack, capacity: Int, container: component.Container) = {
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
if (stack.hasTagCompound) {
|
||||
val lootPath = "loot/" + stack.getTagCompound.getString(Settings.namespace + "lootPath")
|
||||
val savePath = new io.File(DimensionManager.getCurrentSaveRootDirectory, Settings.savePath + lootPath)
|
||||
@ -31,8 +25,9 @@ object Loot extends Item {
|
||||
dataTag(stack).getString(Settings.namespace + "fs.label")
|
||||
}
|
||||
else null
|
||||
api.FileSystem.asManagedEnvironment(fs, label, container.tileEntity.orNull)
|
||||
api.FileSystem.asManagedEnvironment(fs, label, container)
|
||||
}
|
||||
else null
|
||||
}
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Disk
|
||||
}
|
@ -2,9 +2,8 @@ package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.{api, Items}
|
||||
import li.cil.oc.api.driver
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.item
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object Memory extends Item with driver.Memory {
|
||||
@ -15,7 +14,7 @@ object Memory extends Item with driver.Memory {
|
||||
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("ram1"), api.Items.get("ram2"), api.Items.get("ram3"), api.Items.get("ram4"), api.Items.get("ram5"), api.Items.get("ram6"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = null
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = null
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Memory
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object NetworkCard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("lanCard"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = new component.NetworkCard()
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.NetworkCard()
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Card
|
||||
}
|
||||
|
@ -2,15 +2,14 @@ package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.{api, Settings, Items}
|
||||
import li.cil.oc.api.driver
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.item
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object Processor extends Item with driver.Processor {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("cpu1"), api.Items.get("cpu2"), api.Items.get("cpu3"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = null
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = null
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Processor
|
||||
|
||||
|
@ -1,19 +1,19 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.tileentity.traits.{RedstoneAware, BundledRedstoneAware}
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.util.mods.BundledRedstone
|
||||
import net.minecraft.item.ItemStack
|
||||
import li.cil.oc.common.tileentity.traits.{RedstoneAware, BundledRedstoneAware}
|
||||
|
||||
object RedstoneCard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("redstoneCard"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(redstone: BundledRedstoneAware) if BundledRedstone.isAvailable => new component.BundledRedstone(redstone)
|
||||
case Some(redstone: RedstoneAware) => new component.Redstone(redstone)
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
container match {
|
||||
case redstone: BundledRedstoneAware if BundledRedstone.isAvailable => new component.BundledRedstone(redstone)
|
||||
case redstone: RedstoneAware => new component.Redstone(redstone)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.component
|
||||
import li.cil.oc.server.component.Container
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object Screen extends Item {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -9,7 +9,7 @@ import net.minecraft.item.ItemStack
|
||||
object UpgradeAngel extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("angelUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = new component.UpgradeAngel()
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.UpgradeAngel()
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Upgrade
|
||||
|
||||
|
@ -1,9 +1,8 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.server.component.Container
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object UpgradeCapacitor extends Item {
|
||||
|
@ -1,20 +1,15 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.machine.Robot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
|
||||
object UpgradeChunkloader extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("chunkloaderUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = container.tileEntity match {
|
||||
case Some(tileEntity: TileEntity with Robot) => new component.UpgradeChunkloader(tileEntity)
|
||||
case _ => null
|
||||
}
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.UpgradeChunkloader(container)
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Upgrade
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.{Items, api}
|
||||
import li.cil.oc.api.driver.{UpgradeContainer, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
import li.cil.oc.api.driver.{Container, UpgradeContainer, Slot}
|
||||
import li.cil.oc.common.item
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object UpgradeContainerCard extends Item with UpgradeContainer {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("cardContainer1"), api.Items.get("cardContainer2"), api.Items.get("cardContainer3"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = null
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = null
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.UpgradeContainer
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.{UpgradeContainer, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.api.driver.{Container, UpgradeContainer, Slot}
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object UpgradeContainerFloppy extends Item with UpgradeContainer {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("diskDrive"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = null
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = null
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.UpgradeContainer
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.{Items, api}
|
||||
import li.cil.oc.api.driver.{UpgradeContainer, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
import li.cil.oc.api.driver.{Container, UpgradeContainer, Slot}
|
||||
import li.cil.oc.common.item
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object UpgradeContainerUpgrade extends Item with UpgradeContainer {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("upgradeContainer1"), api.Items.get("upgradeContainer2"), api.Items.get("upgradeContainer3"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = null
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = null
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.UpgradeContainer
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.api.machine.Robot
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
@ -10,9 +10,9 @@ import net.minecraft.item.ItemStack
|
||||
object UpgradeCrafting extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("craftingUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(robot: Robot) => new component.UpgradeCrafting(robot)
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
container match {
|
||||
case robot: Container with Robot => new component.UpgradeCrafting(robot)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.machine.Robot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -10,11 +9,7 @@ import net.minecraft.item.ItemStack
|
||||
object UpgradeExperience extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("experienceUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(robot: Robot) => new component.UpgradeExperience()
|
||||
case _ => null
|
||||
}
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.UpgradeExperience()
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Upgrade
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.api.machine.Robot
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
@ -10,9 +10,9 @@ import net.minecraft.item.ItemStack
|
||||
object UpgradeGenerator extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("generatorUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(robot: Robot) => new component.UpgradeGenerator(robot)
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
container match {
|
||||
case robot: Robot => new component.UpgradeGenerator(robot)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.{Inventory, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.api.driver.{Container, Inventory, Slot}
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object UpgradeInventory extends Item with Inventory {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("inventoryUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = null
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = null
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Upgrade
|
||||
|
||||
|
@ -1,18 +1,17 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.api.machine.Robot
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
|
||||
object UpgradeInventoryController extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("inventoryControllerUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) = container.tileEntity match {
|
||||
case Some(robot: TileEntity with Robot) => new component.UpgradeInventoryController(robot)
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = container match {
|
||||
case robot: Container with Robot => new component.UpgradeInventoryController(robot)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.Rotatable
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -9,9 +10,9 @@ import net.minecraft.item.ItemStack
|
||||
object UpgradeNavigation extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("navigationUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(tileEntity) => new component.UpgradeNavigation(tileEntity)
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
container match {
|
||||
case rotatable: Container with Rotatable => new component.UpgradeNavigation(rotatable)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
|
@ -1,16 +1,17 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.Rotatable
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object UpgradeSign extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("signUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(tileEntity) => new component.UpgradeSign(tileEntity)
|
||||
override def createEnvironment(stack: ItemStack, container: Container) =
|
||||
container match {
|
||||
case rotatable: Container with Rotatable => new component.UpgradeSign(rotatable)
|
||||
case _ => null
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -9,11 +9,7 @@ import net.minecraft.item.ItemStack
|
||||
object UpgradeSolarGenerator extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("solarGeneratorUpgrade"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(tileEntity) => new component.UpgradeSolarGenerator(tileEntity)
|
||||
case _ => null
|
||||
}
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.UpgradeSolarGenerator(container)
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Upgrade
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package li.cil.oc.server.driver.item
|
||||
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.driver.Slot
|
||||
import li.cil.oc.api.driver.{Container, Slot}
|
||||
import li.cil.oc.common.InventorySlots.Tier
|
||||
import li.cil.oc.server.component
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -9,11 +9,7 @@ import net.minecraft.item.ItemStack
|
||||
object WirelessNetworkCard extends Item {
|
||||
override def worksWith(stack: ItemStack) = isOneOf(stack, api.Items.get("wlanCard"))
|
||||
|
||||
override def createEnvironment(stack: ItemStack, container: component.Container) =
|
||||
container.tileEntity match {
|
||||
case Some(tileEntity) => new component.WirelessNetworkCard(tileEntity)
|
||||
case _ => null
|
||||
}
|
||||
override def createEnvironment(stack: ItemStack, container: Container) = new component.WirelessNetworkCard(container)
|
||||
|
||||
override def slot(stack: ItemStack) = Slot.Card
|
||||
|
||||
|
@ -3,6 +3,7 @@ package li.cil.oc.server.fs
|
||||
import cpw.mods.fml.common.Optional
|
||||
import java.io
|
||||
import java.net.URL
|
||||
import li.cil.oc.api.driver.Container
|
||||
import li.cil.oc.api.fs.Label
|
||||
import li.cil.oc.server.component
|
||||
import li.cil.oc.{Settings, api}
|
||||
@ -77,10 +78,10 @@ object FileSystem extends api.detail.FileSystemAPI {
|
||||
@Optional.Method(modid = "ComputerCraft")
|
||||
def fromComputerCraft(mount: dan200.computercraft.api.filesystem.IWritableMount) = new CC16WritableFileSystem(mount)
|
||||
|
||||
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, container: net.minecraft.tileentity.TileEntity) =
|
||||
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label, container: Container) =
|
||||
Option(fileSystem).flatMap(fs => Some(new component.FileSystem(fs, label, Option(container)))).orNull
|
||||
|
||||
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String, container: net.minecraft.tileentity.TileEntity) =
|
||||
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: String, container: Container) =
|
||||
asManagedEnvironment(fileSystem, new ReadOnlyLabel(label), container)
|
||||
|
||||
def asManagedEnvironment(fileSystem: api.fs.FileSystem, label: Label) =
|
||||
|
Loading…
x
Reference in New Issue
Block a user