mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-27 15:33:06 +00:00
Implemented ComputerCraft Bundled Cable support to Insulated Redstone Conduits
This commit is contained in:
1 parent
4822a2f678
commit
063fecf313
35 files changed
+1436
-26
No files matched your search
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import dan200.computercraft.api.filesystem.IMount;
|
||||
import dan200.computercraft.api.filesystem.IWritableMount;
|
||||
|
||||
/**
|
||||
* The interface passed to peripherals by computers or turtles, providing methods
|
||||
* that they can call. This should not be implemented by your classes. Do not interact
|
||||
* with computers except via this interface.
|
||||
*/
|
||||
public interface IComputerAccess
|
||||
{
|
||||
/**
|
||||
* Mount a mount onto the computers' file system in a read only mode.<br>
|
||||
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
|
||||
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount(), ComputerCraftAPI.createResourceMount() or by creating your own objects that implement the IMount interface.
|
||||
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
|
||||
* @see #mountWritable(String, dan200.computercraft.api.filesystem.IWritableMount)
|
||||
* @see #unmount(String)
|
||||
* @see dan200.computercraft.api.filesystem.IMount
|
||||
*/
|
||||
public String mount( String desiredLocation, IMount mount );
|
||||
|
||||
/**
|
||||
* TODO: Document me
|
||||
*/
|
||||
public String mount( String desiredLocation, IMount mount, String driveName );
|
||||
|
||||
/**
|
||||
* Mount a mount onto the computers' file system in a writable mode.<br>
|
||||
* @param desiredLocation The location on the computercraft's file system where you would like the mount to be mounted.
|
||||
* @param mount The mount object to mount on the computercraft. These can be obtained by calling ComputerCraftAPI.createSaveDirMount() or by creating your own objects that implement the IWritableMount interface.
|
||||
* @return The location on the computercraft's file system where you the mount mounted, or null if there was already a file in the desired location. Store this value if you wish to unmount the mount later.
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#createSaveDirMount(World, String)
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#createResourceMount(Class, String, String)
|
||||
* @see #mount(String, IMount)
|
||||
* @see #unmount(String)
|
||||
* @see IMount
|
||||
*/
|
||||
public String mountWritable( String desiredLocation, IWritableMount mount );
|
||||
|
||||
/**
|
||||
* TODO: Document me
|
||||
*/
|
||||
public String mountWritable( String desiredLocation, IWritableMount mount, String driveName );
|
||||
|
||||
/**
|
||||
* Unmounts a directory previously mounted onto the computers file system by mount() or mountWritable().<br>
|
||||
* When a directory is unmounted, it will disappear from the computers file system, and the user will no longer be able to
|
||||
* access it. All directories mounted by a mount or mountWritable are automatically unmounted when the peripheral
|
||||
* is attached if they have not been explicitly unmounted.
|
||||
* @param location The desired location in the computers file system of the directory to unmount.
|
||||
* This must be the location of a directory previously mounted by mount() or mountWritable(), as
|
||||
* indicated by their return value.
|
||||
* @see #mount(String, IMount)
|
||||
* @see #mountWritable(String, IWritableMount)
|
||||
*/
|
||||
public void unmount( String location );
|
||||
|
||||
/**
|
||||
* Returns the numerical ID of this computercraft.<br>
|
||||
* This is the same number obtained by calling os.getComputerID() or running the "id" program from lua,
|
||||
* and is guarunteed unique. This number will be positive.
|
||||
* @return The identifier.
|
||||
*/
|
||||
public int getID();
|
||||
|
||||
/**
|
||||
* Causes an event to be raised on this computercraft, which the computercraft can respond to by calling
|
||||
* os.pullEvent(). This can be used to notify the computercraft when things happen in the world or to
|
||||
* this peripheral.
|
||||
* @param event A string identifying the type of event that has occurred, this will be
|
||||
* returned as the first value from os.pullEvent(). It is recommended that you
|
||||
* you choose a name that is unique, and recognisable as originating from your
|
||||
* peripheral. eg: If your peripheral type is "button", a suitable event would be
|
||||
* "button_pressed".
|
||||
* @param arguments In addition to a name, you may pass an array of extra arguments to the event, that will
|
||||
* be supplied as extra return values to os.pullEvent(). Objects in the array will be converted
|
||||
* to lua data types in the same fashion as the return values of IPeripheral.callMethod().<br>
|
||||
* You may supply null to indicate that no arguments are to be supplied.
|
||||
* @see dan200.computercraft.api.peripheral.IPeripheral#callMethod
|
||||
*/
|
||||
public void queueEvent( String event, Object[] arguments );
|
||||
|
||||
/**
|
||||
* Get a string, unique to the computercraft, by which the computercraft refers to this peripheral.
|
||||
* For directly attached peripherals this will be "left","right","front","back",etc, but
|
||||
* for peripherals attached remotely it will be different. It is good practice to supply
|
||||
* this string when raising events to the computercraft, so that the computercraft knows from
|
||||
* which peripheral the event came.
|
||||
* @return A string unique to the computercraft, but not globally.
|
||||
*/
|
||||
public String getAttachmentName();
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import dan200.computercraft.api.lua.ILuaContext;
|
||||
import dan200.computercraft.api.lua.LuaException;
|
||||
|
||||
/**
|
||||
* The interface that defines a peripheral. This should be implemented by the
|
||||
* TileEntity of any common that you wish to be interacted with by
|
||||
* computercraft or turtle.
|
||||
*/
|
||||
public interface IPeripheral
|
||||
{
|
||||
/**
|
||||
* Should return a string that uniquely identifies this type of peripheral.
|
||||
* This can be queried from lua by calling peripheral.getType()
|
||||
* @return A string identifying the type of peripheral.
|
||||
*/
|
||||
public String getType();
|
||||
|
||||
/**
|
||||
* Should return an array of strings that identify the methods that this
|
||||
* peripheral exposes to Lua. This will be called once before each attachment,
|
||||
* and should not change when called multiple times.
|
||||
* @return An array of strings representing method names.
|
||||
* @see #callMethod
|
||||
*/
|
||||
public String[] getMethodNames();
|
||||
|
||||
/**
|
||||
* This is called when a lua program on an attached computercraft calls peripheral.call() with
|
||||
* one of the methods exposed by getMethodNames().<br>
|
||||
* <br>
|
||||
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
|
||||
* when interacting with minecraft objects.
|
||||
* @param computer The interface to the computercraft that is making the call. Remember that multiple
|
||||
* computers can be attached to a peripheral at once.
|
||||
* @param context The context of the currently running lua thread. This can be used to wait for events
|
||||
* or otherwise yield.
|
||||
* @param method An integer identifying which of the methods from getMethodNames() the computercraft
|
||||
* wishes to call. The integer indicates the index into the getMethodNames() table
|
||||
* that corresponds to the string passed into peripheral.call()
|
||||
* @param arguments An array of objects, representing the arguments passed into peripheral.call().<br>
|
||||
* Lua values of type "string" will be represented by Object type String.<br>
|
||||
* Lua values of type "number" will be represented by Object type Double.<br>
|
||||
* Lua values of type "boolean" will be represented by Object type Boolean.<br>
|
||||
* Lua values of any other type will be represented by a null object.<br>
|
||||
* This array will be empty if no arguments are passed.
|
||||
* @return An array of objects, representing values you wish to return to the lua program.<br>
|
||||
* Integers, Doubles, Floats, Strings, Booleans and null be converted to their corresponding lua type.<br>
|
||||
* All other types will be converted to nil.<br>
|
||||
* You may return null to indicate no values should be returned.
|
||||
* @throws Exception If you throw any exception from this function, a lua error will be raised with the
|
||||
* same message as your exception. Use this to throw appropriate errors if the wrong
|
||||
* arguments are supplied to your method.
|
||||
* @see #getMethodNames
|
||||
*/
|
||||
public Object[] callMethod( IComputerAccess computer, ILuaContext context, int method, Object[] arguments ) throws LuaException, InterruptedException;
|
||||
|
||||
/**
|
||||
* Is called when canAttachToSide has returned true, and a computercraft is attaching to the peripheral.
|
||||
* This will occur when a peripheral is placed next to an active computercraft, when a computercraft is turned on next to a peripheral,
|
||||
* or when a turtle travels into a square next to a peripheral.
|
||||
* Between calls to attach() and detach(), the attached computercraft can make method calls on the peripheral using peripheral.call().
|
||||
* This method can be used to keep track of which computers are attached to the peripheral, or to take action when attachment
|
||||
* occurs.<br>
|
||||
* <br>
|
||||
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
|
||||
* when interacting with minecraft objects.
|
||||
* @param computer The interface to the computercraft that is being attached. Remember that multiple
|
||||
* computers can be attached to a peripheral at once.
|
||||
* @see #detach
|
||||
*/
|
||||
public void attach( IComputerAccess computer );
|
||||
|
||||
/**
|
||||
* Is called when a computercraft is detaching from the peripheral.
|
||||
* This will occur when a computercraft shuts down, when the peripheral is removed while attached to computers,
|
||||
* or when a turtle moves away from a square attached to a peripheral.
|
||||
* This method can be used to keep track of which computers are attached to the peripheral, or to take action when detachment
|
||||
* occurs.<br>
|
||||
* <br>
|
||||
* Be aware that this will be called from the ComputerCraft Lua thread, and must be thread-safe
|
||||
* when interacting with minecraft objects.
|
||||
* @param computer The interface to the computercraft that is being detached. Remember that multiple
|
||||
* computers can be attached to a peripheral at once.
|
||||
* @see #detach
|
||||
*/
|
||||
public void detach( IComputerAccess computer );
|
||||
|
||||
/**
|
||||
* TODO: Document me
|
||||
*/
|
||||
public boolean equals( IPeripheral other );
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
/**
|
||||
* This interface is used to create peripheral implementations for blocks
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
|
||||
*/
|
||||
public interface IPeripheralProvider
|
||||
{
|
||||
/**
|
||||
* Produce an peripheral implementation from a block location.
|
||||
* @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider)
|
||||
* @return a peripheral, or null if there is not a peripheral here you'd like to handle.
|
||||
*/
|
||||
public IPeripheral getPeripheral( World world, int x, int y, int z, int side );
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* This file is part of the public ComputerCraft API - http://www.computercraft.info
|
||||
* Copyright Daniel Ratcliffe, 2011-2014. This API may be redistributed unmodified and in full only.
|
||||
* For help using the API, and posting your mods, visit the forums at computercraft.info.
|
||||
*/
|
||||
|
||||
@API( owner="ComputerCraft", provides="ComputerCraft|API|Peripheral", apiVersion="1.65" )
|
||||
package dan200.computercraft.api.peripheral;
|
||||
|
||||
import cpw.mods.fml.common.API;
|
||||
Reference in new issue
Block a user