Update to UE 9.1

Need to test still since it looks like my forge it out data i can't test
just yet
This commit is contained in:
Rseifert 2012-10-10 21:48:55 -04:00
parent 8de1486509
commit fccf7d2f29
9 changed files with 249 additions and 13 deletions

View file

@ -180,13 +180,13 @@ public int presureOutput(Liquid type, ForgeDirection side) {
@Override
public void handlePacketData(NetworkManager network,
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
ByteArrayDataInput data) {
try
{
this.type = Liquid.getLiquid(dataStream.readInt());
this.LStored = dataStream.readInt();
this.type = Liquid.getLiquid(data.readInt());
this.LStored = data.readInt();
}catch(Exception e)
{
e.printStackTrace();

View file

@ -245,7 +245,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
@Override
public void handlePacketData(NetworkManager network,
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput data) {
try

View file

@ -112,12 +112,12 @@ public class TileEntityRod extends TileEntity implements IPacketReceiver,IMechan
}
@Override
public void handlePacketData(NetworkManager network,
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
ByteArrayDataInput data) {
try
{
this.force = dataStream.readInt();
this.force = data.readInt();
}catch(Exception e)
{
e.printStackTrace();

View file

@ -0,0 +1,131 @@
package dan200.computer.api;
/**
* 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
{
/**
* Creates a new numbered directory in a subPath of the users game save, and return that number. To be used with mountSaveDir.<br>
* For example: n = createNewSaveDir( "computer/cdrom" ), will create a new
* numbered folder in the "computer/cdrom" subdirectory of the users save file, and return that number.
* mountSaveDir( "computer/rom", n ) could then be used to mount that folder onto the computers directory
* structure, and the value n could be saved out and used again in future to give the peripheral
* persistant storage.
* @param subPath A relative file path from the users world save, where the directory should be located.
* @return The numeric represenation of the name of the folder created. Will be positive.
* @see #mountSaveDir(String, String, int, boolean, long)
*/
public int createNewSaveDir( String subPath );
/**
* Equivalent to mountSaveDir( String desiredLocation, String subPath, int id, boolean readOnly, long spaceLimit ) with no space limit.
* Mounts created with this method will have unlimited capacity.
* @see #mountSaveDir(String, String, int, boolean, long)
*/
public String mountSaveDir( String desiredLocation, String subPath, int id, boolean readOnly );
/**
* Mounts a directory into the computers file system, from a real directory a subPath of the users game save,
* with a numerical name. To be used with createNewSaveDir.<br>
* For example: n = createNewSaveDir( "computer/cdrom" ), will create a new
* numbered folder in the "computer/cdrom" subdirectory of the users save file, and return that number.
* mountSaveDir( "computer/rom", n ) could then be used to mount that folder onto the computers directory
* structure, and the value n can be saved out by the peripheral and used again, to give the peripheral
* persistant storage.<br>
* When a directory is mounted, it will appear in the computers file system, and the user will be
* able to use file operation to read from and write to the directory (unless readOnly, then only writes will be allowed).
* @param desiredLocation The desired location in the computers file system where you would like the directory to appear.
* If this location already exists, a number will be appended until a free name is found, and the
* actual location will be returned. eg: "cdrom" can become "cdrom2" if two peripherals attempt to
* mount "cdrom", or a "cdrom" folder already exists.
* @param subPath The real relative file path from the users world save, where the directory to mount can be located.
* @param id The numerical name of the folder to mount from the subPath: ex: mountSaveDir( "cdrom", "computer/cdrom", 7 )
* will mount the directory "computer/cdrom/7". Use createNewSaveDir to obtain a unique directory id.
* @param readOnly Whether the computer will be disallowed from making changes to the mounted directory and modifing or creating files therin.
* @param spaceLimit The size limit of the mount, in bytes.
* @return The location in the computers file system where the directory was mounted. This may differ from "desiredLocation", so the
* return value should be kept track of so the folder can be unmounted later.
* @see #createNewSaveDir(String)
* @see #mountFixedDir(String, String, boolean, long)
* @see #unmount(String)
*/
public String mountSaveDir( String desiredLocation, String subPath, int id, boolean readOnly, long spaceLimit );
/**
* Equivalent to mountFixedDir( String desiredLocation, String path, boolean readOnly, long spaceLimit ) with no space limit.
* Mounts created with this method will have unlimited capacity.
* @see #mountFixedDir(String, String, boolean, long)
*/
public String mountFixedDir( String desiredLocation, String path, boolean readOnly );
/**
* Mounts a directory into the computers file system, from a real directory in the Minecraft install folder.<br>
* For example: mountFixedDir( "stuff", "mods/mymod/lua/stuff", true ), will mount the "lua/stuff" folder from
* your mod's directory into the computers filesystem at the location "stuff", with readonly permission, giving the
* computer access to those files.<br>
* When a directory is mounted, it will appear in the computers file system, and the user will be
* able to use file operation to read from and write to the directory (unless readOnly, then only writes will be allowed).<br>
* mountFixedDir can also be used to mount files, for example: mountFixedDir( "rom/apis/myapi", "mods/mymod/lua/myapi.lua", true ) can
* be used to have the peripheral install an API onto the computer it attaches to.
* @param desiredLocation The desired location in the computers file system where you would like the directory to appear.
* If this location already exists, a number will be appended until a free name is found, and the
* actual location will be returned. eg: "cdrom" can become "cdrom2" if two peripherals attempt to
* mount "cdrom", or a "cdrom" folder already exists.
* @param subPath The real relative file path from the minecraft install root, where the directory to mount can be located.
* @param readOnly Whether the computer will be disallowed from making changes to the mounted directory and modifing or creating files therin.
* @param spaceLimit The size limit of the mount, in bytes.
* @return The location in the computers file system where the directory was mounted. This may differ from "desiredLocation", so the
* return value should be kept track of so the folder can be unmounted later.
* @see #mountSaveDir(String, String, int, boolean, long)
* @see #unmount(String)
*/
public String mountFixedDir( String desiredLocation, String path, boolean readOnly, long spaceLimit );
/**
* Unmounts a directory previously mounted onto the computers file system by mountSaveDir or mountFixedDir.<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 mountFixedDir or mountSaveDir 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 mountFixedDir() or mountSaveDir(), as
* indicated by their return value.
* @see #mountSaveDir(String, String, int, boolean, long)
* @see #mountFixedDir(String, String, boolean, long)
*/
public void unmount( String location );
/**
* Returns the numerical ID of this computer.<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();
/**
* Equivalent to queueEvent( String event, Object[] arguments ) with an empty arguments array.
* @see #queueEvent(String, Object[])
*/
public void queueEvent( String event );
/**
* Causes an event to be raised on this computer, which the computer can respond to by calling
* os.pullEvent(). This can be used to notify the computer 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 IPeripheral#callMethod
*/
public void queueEvent( String event, Object[] arguments );
}

View file

@ -0,0 +1,103 @@
package dan200.computer.api;
/**
* The interface that defines a peripheral. This should be implemented by the
* TileEntity of any block that you wish to be interacted with by
* computer 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 computer 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 computer that is making the call. Remember that multiple
* computers can be attached to a peripheral at once.
* @param method An integer identifying which of the methods from getMethodNames() the computer
* 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, int method, Object[] arguments ) throws Exception;
/**
* Is called before the computer attempts to attach to the peripheral, and should return whether to allow
* the attachment. Use this to restrict the number of computers that can attach, or to limit attachments to
* certain world directions.<br>
* If true is returned, attach() will be called shortly afterwards, and the computer will be able to make method calls.
* If false is returned, attach() will not be called, and the peripheral will be invisible to the computer.
* @param side The world direction (0=bottom, 1=top, etc) that the computer lies relative to the peripheral.
* @return Whether to allow the attachment, as a boolean.
* @see #attach
*/
public boolean canAttachToSide( int side );
/**
* Is called when canAttachToSide has returned true, and a computer is attaching to the peripheral.
* This will occur when a peripheral is placed next to an active computer, when a computer 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 computer 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 computer that is being attached. Remember that multiple
* computers can be attached to a peripheral at once.
* @param computerSide A string indicating which "side" of the computer the peripheral is attaching,
* relative to the computers orientation. This value will be one of "top", "bottom",
* "left", "right", "front" or "back". This can be used to uniquely identify the
* peripheral when raising events or returning values to the computer.
* @see #canAttachToSide
* @see #detach
*/
public void attach( IComputerAccess computer, String computerSide );
/**
* Is called when a computer is detaching from the peripheral.
* This will occur when a computer 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 computer that is being detached. Remember that multiple
* computers can be attached to a peripheral at once.
* @see #canAttachToSide
* @see #detach
*/
public void detach( IComputerAccess computer );
}

View file

@ -64,7 +64,7 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
}
@Override
public void handlePacketData(NetworkManager network,
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
try

View file

@ -191,7 +191,7 @@ public class TileEntityFireBox extends TileEntityMachine implements IPacketRecei
}
@Override
public void handlePacketData(NetworkManager network,
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
try

View file

@ -99,9 +99,9 @@ public class TileEntityGen extends TileEntityMachine implements IPacketReceiver,
super.updateEntity();
}
@Override
public void handlePacketData(NetworkManager network,
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
ByteArrayDataInput data) {
// TODO Auto-generated method stub
}

View file

@ -276,7 +276,9 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
return false;
}
@Override
public void handlePacketData(NetworkManager network,Packet250CustomPayload packet, EntityPlayer player,ByteArrayDataInput dataStream) {
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
try
{
this.steam = dataStream.readInt();