dan200.computer.api
Class ComputerCraftAPI

java.lang.Object
  extended by dan200.computer.api.ComputerCraftAPI

public class ComputerCraftAPI
extends java.lang.Object

The static entry point to the ComputerCraft API. Members in this class must be called after mod_ComputerCraft has been initialised, but may be called before it is fully loaded.


Constructor Summary
ComputerCraftAPI()
           
 
Method Summary
static IMount createResourceMount(java.lang.Class modClass, java.lang.String domain, java.lang.String subPath)
          Creates a file system mount to a resource folder, and returns it.
Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a resource folder onto a computers file system.
The files in this mount will be a combination of files in the specified mod jar, and resource packs that contain resources with the same domain and path.
static IWritableMount createSaveDirMount(World world, java.lang.String subPath, long capacity)
          Creates a file system mount that maps to a subfolder of the save directory for a given world, and returns it.
Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a folder from the users save directory onto a computers file system.
static int createUniqueNumberedSaveDir(World world, java.lang.String parentSubPath)
          Creates a numbered directory in a subfolder of the save directory for a given world, and returns that number.
Use in conjuction with createSaveDirMount() to create a unique place for your peripherals or media items to store files.
static void registerExternalPeripheral(java.lang.Class<? extends net.minecraft.tileentity.TileEntity> clazz, IPeripheralHandler handler)
          Registers a peripheral handler for a TileEntity that you do not have access to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComputerCraftAPI

public ComputerCraftAPI()
Method Detail

createUniqueNumberedSaveDir

public static int createUniqueNumberedSaveDir(World world,
                                              java.lang.String parentSubPath)
Creates a numbered directory in a subfolder of the save directory for a given world, and returns that number.
Use in conjuction with createSaveDirMount() to create a unique place for your peripherals or media items to store files.

Parameters:
world - The world for which the save dir should be created. This should be the serverside world object.
parentSubPath - The folder path within the save directory where the new directory should be created. eg: "computer/disk"
Returns:
The numerical value of the name of the new folder, or -1 if the folder could not be created for some reason.
eg: if createUniqueNumberedSaveDir( world, "computer/disk" ) was called returns 42, then "computer/disk/42" is now available for writing.
See Also:
#createSaveDirMount(World, String)

createSaveDirMount

public static IWritableMount createSaveDirMount(World world,
                                                java.lang.String subPath,
                                                long capacity)
Creates a file system mount that maps to a subfolder of the save directory for a given world, and returns it.
Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a folder from the users save directory onto a computers file system.

Parameters:
world - The world for which the save dir can be found. This should be the serverside world object.
subPath - The folder path within the save directory that the mount should map to. eg: "computer/disk/42".
Use createUniqueNumberedSaveDir() to create a new numbered folder to use.
capacity - The ammount of data that can be stored in the directory before it fills up, in bytes.
Returns:
The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable() to mount this on a Computers' file system.
See Also:
createUniqueNumberedSaveDir(World, String), IComputerAccess.mount(String, IMount), IComputerAccess.mountWritable(String, IWritableMount), IMount, IMountWritable

createResourceMount

public static IMount createResourceMount(java.lang.Class modClass,
                                         java.lang.String domain,
                                         java.lang.String subPath)
Creates a file system mount to a resource folder, and returns it.
Use in conjuction with IComputerAccess.mount() or IComputerAccess.mountWritable() to mount a resource folder onto a computers file system.
The files in this mount will be a combination of files in the specified mod jar, and resource packs that contain resources with the same domain and path.

Parameters:
class - A class in whose jar to look first for the resources to mount. Using your main mod class is recommended. eg: MyMod.class
domain - The domain under which to look for resources. eg: "mymod"
subPath - The domain under which to look for resources. eg: "mymod/lua/myfiles"
Returns:
The mount, or null if it could be created for some reason. Use IComputerAccess.mount() or IComputerAccess.mountWritable() to mount this on a Computers' file system.
See Also:
IComputerAccess.mount(String, IMount), IComputerAccess#mountWritable(String, IMountWritable), IMount

registerExternalPeripheral

public static void registerExternalPeripheral(java.lang.Class<? extends net.minecraft.tileentity.TileEntity> clazz,
                                              IPeripheralHandler handler)
Registers a peripheral handler for a TileEntity that you do not have access to. Only use this if you want to expose IPeripheral on a TileEntity from another mod. For your own mod, just implement IPeripheral on the TileEntity directly.

See Also:
IPeripheral, IPeripheralHandler