dan200.computercraft.api

## Class ComputerCraftAPI

- java.lang.Object
- - dan200.computercraft.api.ComputerCraftAPI

    public final 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

Constructors
Constructor and Description
`ComputerCraftAPI()`

### Method Summary

Methods

`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 java.lang.String` `getAPIVersion()`
`static int` `getBundledRedstoneOutput(World world, int x, int y, int z, int side)` If there is a Computer or Turtle at a certain position in the world, get it's bundled redstone output.
`static java.lang.String` `getInstalledVersion()`
`static boolean` `isInstalled()`
`static void` `registerBundledRedstoneProvider(IBundledRedstoneProvider handler)` Registers a bundled redstone handler to provide bundled redstone output for blocks
`static void` `registerMediaProvider(IMediaProvider handler)` Registers a media handler to provide IMedia implementations for Items
`static void` `registerPeripheralProvider(IPeripheralProvider handler)` Registers a peripheral handler to convert blocks into IPeripheral implementations.
`static void` `registerPermissionProvider(ITurtlePermissionProvider handler)` Registers a permission handler to restrict where turtles can move or build
`static void` `registerTurtleUpgrade(ITurtleUpgrade upgrade)` Registers a new turtle turtle for use in ComputerCraft.

### 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

#### isInstalled

    public static boolean isInstalled()

#### getInstalledVersion

    public static java.lang.String getInstalledVersion()

#### getAPIVersion

    public static java.lang.String getAPIVersion()

#### 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: "computercraft/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, long)`

#### 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, dan200.computercraft.api.filesystem.IMount)`, `IComputerAccess.mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)`, `IMount`, `IWritableMount`

#### 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:
  `modClass` - 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, dan200.computercraft.api.filesystem.IMount)`, `IComputerAccess.mountWritable(String, IWritableMount)`, `IMount`

#### registerPeripheralProvider

    public static void registerPeripheralProvider(IPeripheralProvider handler)

Registers a peripheral handler to convert blocks into IPeripheral implementations.

See Also:
  `IPeripheral`, `IPeripheralProvider`

#### registerTurtleUpgrade

    public static void registerTurtleUpgrade(ITurtleUpgrade upgrade)

Registers a new turtle turtle for use in ComputerCraft. After calling this, users should be able to craft Turtles with your new turtle. It is recommended to call this during the load() method of your mod.

See Also:
  `ITurtleUpgrade`

#### registerBundledRedstoneProvider

    public static void registerBundledRedstoneProvider(IBundledRedstoneProvider handler)

Registers a bundled redstone handler to provide bundled redstone output for blocks

See Also:
  `IBundledRedstoneProvider`

#### getBundledRedstoneOutput

    public static int getBundledRedstoneOutput(World world,
                               int x,
                               int y,
                               int z,
                               int side)

If there is a Computer or Turtle at a certain position in the world, get it's bundled redstone output.

Returns:
  If there is a block capable of emitting bundled redstone at the location, it's signal (0-65535) will be returned. If there is no block capable of emitting bundled redstone at the location, -1 will be returned.
See Also:
  `IBundledRedstoneProvider`

#### registerMediaProvider

    public static void registerMediaProvider(IMediaProvider handler)

Registers a media handler to provide IMedia implementations for Items

See Also:
  `IMediaProvider`

#### registerPermissionProvider

    public static void registerPermissionProvider(ITurtlePermissionProvider handler)

Registers a permission handler to restrict where turtles can move or build

See Also:
  `ITurtlePermissionProvider`