Updated CC api

need to just no include this in the repo but rather have the ant script
just download it each build
This commit is contained in:
Rseifert 2013-04-10 06:24:16 -04:00
parent 5dea05a1d5
commit f8263c9b2b
25 changed files with 624 additions and 36 deletions

View file

@ -4,7 +4,6 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import assemblyline.client.gui.GuiEncoder;
import assemblyline.client.gui.GuiImprinter;
@ -17,7 +16,6 @@ import assemblyline.client.render.RenderCrate;
import assemblyline.client.render.RenderDetector;
import assemblyline.client.render.RenderManipulator;
import assemblyline.client.render.RenderRejector;
import assemblyline.common.AssemblyLine;
import assemblyline.common.CommonProxy;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.TileEntityManipulator;

View file

@ -2,7 +2,6 @@ package assemblyline.client.model;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
public class ModelCraneArmMount extends ModelBase
{

View file

@ -8,10 +8,8 @@ import static org.lwjgl.opengl.GL11.glPopMatrix;
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glTranslated;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.ForgeHooksClient;
import universalelectricity.core.vector.Vector3;
import assemblyline.client.model.ModelHelper;
import assemblyline.common.AssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

View file

@ -1,7 +1,5 @@
package assemblyline.common;
import ic2.api.Items;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -11,7 +9,6 @@ import java.util.zip.ZipInputStream;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.prefab.implement.IToolConfigurator;
import universalelectricity.prefab.multiblock.TileEntityMulti;
import assemblyline.common.block.TileEntityCrate;
import assemblyline.common.machine.TileEntityManipulator;

View file

@ -1,6 +1,5 @@
package assemblyline.common.block;
import ic2.api.Items;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;

View file

@ -2,9 +2,6 @@ package assemblyline.common.block;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
@ -21,6 +18,8 @@ import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.implement.IRotatable;
import assemblyline.common.AssemblyLine;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockTurntable extends BlockALMachine
{

View file

@ -9,7 +9,6 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory;
import universalelectricity.core.vector.Vector3;

View file

@ -5,7 +5,6 @@ import java.util.Random;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.core.vector.Vector3;

View file

@ -2,8 +2,6 @@ package assemblyline.common.machine.command;
import java.util.List;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.player.EntityPlayer;
@ -12,6 +10,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import universalelectricity.core.vector.Vector3;
import assemblyline.common.machine.belt.TileEntityConveyorBelt;
/**
* Used by arms to search for entities in a region

View file

@ -3,9 +3,6 @@ package assemblyline.common.machine.encoder;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
@ -14,6 +11,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import assemblyline.common.AssemblyLine;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemDisk extends Item
{

View file

@ -12,7 +12,6 @@ import net.minecraft.world.World;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import assemblyline.api.IFilterable;
import assemblyline.common.block.BlockALMachine;
import cpw.mods.fml.common.FMLCommonHandler;
/**
* Extend this block class if a filter is allowed to be placed inside of this block.

View file

@ -3,9 +3,6 @@ package assemblyline.common.machine.imprinter;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityList;
@ -17,6 +14,8 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import assemblyline.common.AssemblyLine;
import assemblyline.common.TabAssemblyLine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class ItemImprinter extends Item
{

View file

@ -0,0 +1,91 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.computer.api;
import java.lang.reflect.Method;
/**
* 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.
*/
public class ComputerCraftAPI
{
/**
* Get the creative mode tab that ComputerCraft items can be found on.
* Use this to add your peripherals to ComputerCraft's tab.
*/
public static net.minecraft.creativetab.CreativeTabs getCreativeTab()
{
findCC();
if (computerCraft_getCreativeTab != null)
{
try {
return (net.minecraft.creativetab.CreativeTabs)( computerCraft_getCreativeTab.invoke(null) );
} catch (Exception e){
// It failed
}
}
return null;
}
/**
* 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 IPeripheral
* @see IPeripheralHandler
*/
public static void registerExternalPeripheral( Class <? extends net.minecraft.tileentity.TileEntity> clazz, IPeripheralHandler handler )
{
findCC();
if (computerCraft_registerExternalPeripheral != null)
{
try {
computerCraft_registerExternalPeripheral.invoke(null, clazz, handler);
} catch (Exception e){
// It failed
}
}
}
// The functions below here are private, and are used to interface with the non-API ComputerCraft classes.
// Reflection is used here so you can develop your mod in MCP without decompiling ComputerCraft and including
// it in your solution.
private static void findCC()
{
if( !ccSearched ) {
try {
computerCraft = Class.forName( "dan200.ComputerCraft" );
computerCraft_getCreativeTab = findCCMethod( "getCreativeTab", new Class[] { } );
computerCraft_registerExternalPeripheral = findCCMethod( "registerExternalPeripheral", new Class[] {
Class.class, IPeripheralHandler.class
} );
} catch( Exception e ) {
System.out.println("ComputerCraftAPI: ComputerCraft not found.");
} finally {
ccSearched = true;
}
}
}
private static Method findCCMethod( String name, Class[] args )
{
try {
return computerCraft.getMethod( name, args );
} catch( NoSuchMethodException e ) {
System.out.println("ComputerCraftAPI: ComputerCraft method " + name + " not found.");
return null;
}
}
private static boolean ccSearched = false;
private static Class computerCraft = null;
private static Method computerCraft_registerExternalPeripheral = null;
private static Method computerCraft_getCreativeTab = null;
}

View file

@ -1,3 +1,8 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.computer.api;
@ -92,12 +97,6 @@ public interface IComputerAccess
*/
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
@ -116,12 +115,12 @@ public interface IComputerAccess
public void queueEvent( String event, Object[] arguments );
/**
* Get a string indicating which "side" of the computer the IComputerAccess this peripheral
* has been created for is attached to, relative to the computers orientation. This can be used to
* uniquely identify the peripheral when raising events or returning values to the computer.
* The value returned by this function will be different for the IComputerAccess for each of
* the peripherals attached to the computer.
* @return One of "top", "bottom", "left", "right", "front" or "back"
* Get a string, unique to the computer, by which the computer 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 computer, so that the computer knows from
* which peripheral the event came.
* @return A string unique to the computer, but not globally.
*/
public String getAttachmentSide();
public String getAttachmentName();
}

View file

@ -0,0 +1,44 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.computer.api;
import dan200.computer.api.IPeripheral;
/**
* A subclass of IPeripheral specifically for peripherals
* created by ITurtleUpgrade's of type Peripheral. When an
* IHostedPeripheral is created, its IPeripheral methods will be called
* just as if the peripheral was a seperate adjacent block in the world,
* and update() will be called once per tick.
* @see ITurtleUpgrade
*/
public interface IHostedPeripheral extends IPeripheral
{
/**
* A method called on each hosted peripheral once per tick, on the main thread
* over the lifetime of the turtle or block. May be used to update the state
* of the peripheral, and may interact with IComputerAccess or ITurtleAccess
* however it likes at this time.
*/
public void update();
/**
* A method called whenever data is read from the Turtle's NBTTag,
* over the lifetime of the turtle. You should only use this for
* reading data you want to stay with the peripheral.
* @param nbttagcompound The peripheral's NBTTag
*/
public void readFromNBT( net.minecraft.nbt.NBTTagCompound nbttagcompound );
/**
* A method called whenever data is written to the Turtle's NBTTag,
* over the lifetime of the turtle. You should only use this for
* writing data you want to stay with the peripheral.
* @param nbttagcompound The peripheral's NBTTag.
* @param ID The turtle's ID.
*/
public void writeToNBT( net.minecraft.nbt.NBTTagCompound nbttagcompound );
}

View file

@ -0,0 +1,21 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.computer.api;
/**
* TODO: Document me
*/
public interface IMedia
{
public String getLabel( net.minecraft.item.ItemStack stack );
public boolean setLabel( net.minecraft.item.ItemStack stack, String label );
public String getAudioTitle( net.minecraft.item.ItemStack stack );
public String getAudioRecordName( net.minecraft.item.ItemStack stack );
public String mountData( net.minecraft.item.ItemStack stack, IComputerAccess computer );
}

View file

@ -1,3 +1,8 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.computer.api;

View file

@ -0,0 +1,15 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.computer.api;
/**
* TODO: Document me
*/
public interface IPeripheralHandler
{
public IHostedPeripheral getPeripheral( net.minecraft.tileentity.TileEntity tile );
}

View file

@ -0,0 +1,158 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.turtle.api;
import dan200.computer.api.*;
/**
* The interface passed to upgrades by turtles, providing methods that they can call.
* This should not be implemented by your classes. Do not interact with turtles except via this interface and ITurtleUpgrade.
*/
public interface ITurtleAccess
{
/**
* Returns the world in which the turtle resides.
* @return the world in which the turtle resides.
*/
public net.minecraft.world.World getWorld();
/**
* Returns a vector containing the integer block co-ordinates at which the turtle resides.
* @return a vector containing the integer block co-ordinates at which the turtle resides.
*/
public net.minecraft.util.Vec3 getPosition();
/**
* Returns a vector containing the co-ordinates at which the turtle is rendered.
* This will shift when the turtle is moving.
* @param f The subframe fraction
* @return a vector containing the integer block co-ordinates at which the turtle resides.
*/
public net.minecraft.util.Vec3 getVisualPosition( float f );
/**
* Returns the world direction the turtle is currently facing.
* @return the world direction the turtle is currently facing.
*/
public int getFacingDir();
/**
* Returns the size of the turtles inventory, in number of slots. This will currently always be 16.
* @return the size of the turtles inventory, in number of slots. This will currently always be 16.
*/
public int getInventorySize();
/**
* Returns which slot the turtle currently has selected in its inventory using turtle.select().
* Unlike the 1-based lua representation, this will be between 0 and getInventorySize() - 1.
* @return which slot the turtle currently has selected in its inventory
*/
public int getSelectedSlot();
/**
* Returns the item stack that the turtle has in one of its inventory slots.
* @param index which inventory slot to retreive, should be between 0 and getInventorySize() - 1
* @return the item stack that the turtle has in one of its inventory slots. May be null.
*/
public net.minecraft.item.ItemStack getSlotContents( int index );
/**
* Changes the item stack that the turtle has in one of its inventory slots.
* @param index which inventory slot to change, should be between 0 and getInventorySize() - 1
* @param stack an item stack to put in the slot. May be null.
*/
public void setSlotContents( int index, net.minecraft.item.ItemStack stack );
/**
* Tries to store an item stack into the turtles current inventory, starting from the turtles
* currently selected inventory slot.
* @param stack The item stack to try and store.
* @return true if the stack was completely stored in the inventory, false if
* it was only partially stored, or could not fit at all. If false is returned
* and the stack was partially stored, the ItemStack passed into "stack" will now
* represent the stack of items that is left over.
*/
public boolean storeItemStack( net.minecraft.item.ItemStack stack );
/**
* Drops an item stack from the turtle onto the floor, or into an inventory is there is one
* adjacent to the turtle in the direction specified.
* @param stack The item stack to drop.
* @param dir The world direction to drop the item
* @return true if the stack was dropped, or completely stored in the adjacent inventory, false if
* it was only partially stored in the adjacent inventory, or could not fit at all. If false is returned
* and the stack was partially stored, the ItemStack passed into "stack" will now
* represent the stack of items that is left over.
*/
public boolean dropItemStack( net.minecraft.item.ItemStack stack, int dir );
/**
* "Deploys" an item stack in the direction specified. This simulates a player right clicking, and calls onItemUse() on the Item class.
* Will return true if some kind of deployment happened, and may modify the item stack. For block item types, this can be
* used to place blocks. Some kinds of items (such as shears when facing a sheep) may modify the turtles inventory during this call.
* @param stack The item stack to deploy
* @param dir The world direction to deploy the item
* @return true if the stack was deployed, false if it was not.
*/
public boolean deployWithItemStack( net.minecraft.item.ItemStack stack, int dir );
/**
* Tries to "attack" entities with an item stack in the direction specified. This simulates a player left clicking, but will
* not affect blocks. If an entity is attacked and killed during this call, its dropped items will end up in the turtles
* inventory.
* @param stack The item stack to attack with
* @param dir The world direction to attack with the item
* @return true if something was attacked, false if it was not
*/
public boolean attackWithItemStack( net.minecraft.item.ItemStack stack, int dir, float damageMultiplier );
/**
* Returns the current fuel level of the turtle, this is the same integer returned by turtle.getFuelLevel(),
* that decreases by 1 every time the turtle moves. Can be used to have your tool or peripheral require or supply
* fuel to the turtle.
* @return the fuel level
*/
public int getFuelLevel();
/**
* Tries to increase the fuel level of a turtle by burning an item stack. If the item passed in is a fuel source, fuel
* will increase and true will be returned. Otherwise, nothing will happen and false will be returned.
* @param stack The stack to try to refuel with
* @return Whether the turtle was refueled
*/
public boolean refuelWithItemStack( net.minecraft.item.ItemStack stack );
/**
* Removes some fuel from the turtles fuel supply. Negative numbers can be passed in to INCREASE the fuel level of the turtle.
* @return Whether the turtle was able to consume the ammount of fuel specified. Will return false if you supply a number
* greater than the current fuel level of the turtle.
*/
public boolean consumeFuel( int fuel );
/**
* Adds a custom command to the turtles command queue. Unlike peripheral methods, these custom commands will be executed
* on the main thread, so are guaranteed to be able to access Minecraft objects safely, and will be queued up
* with the turtles standard movement and tool commands. An issued command will return an unique integer, which will
* be supplied as a parameter to a "turtle_response" event issued to the turtle after the command has completed. Look at the
* lua source code for "rom/apis/turtle" for how to build a lua wrapper around this functionality.
* @param handler an object which will execute the custom command when its point in the queue is reached
* @return the unique command identifier described above
* @see ITurtleCommandHandler
*/
public int issueCommand( ITurtleCommandHandler handler );
/**
* Returns the upgrade on the specified side of the turtle, if there is one.
* @return the upgrade on the specified side of the turtle, if there is one.
*/
public ITurtleUpgrade getUpgrade( TurtleSide side );
/**
* Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.
* @return the peripheral created by the upgrade on the specified side of the turtle, if there is one.
*/
public IHostedPeripheral getPeripheral( TurtleSide side );
}

View file

@ -0,0 +1,25 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.turtle.api;
/**
* An interface for objects executing custom turtle commands, used with ITurtleAccess.issueCommand
* @see ITurtleAccess#issueCommand( ITurtleCommandHandler )
*/
public interface ITurtleCommandHandler
{
/**
* Will be called by the turtle on the main thread when it is time to execute the custom command.
* The handler should either perform the work of the command, and return true for success, or return
* false to indicate failure if the command cannot be executed at this time.
* @param turtle access to the turtle for whom the command was issued
* @return true for success, false for failure. If true is returned, the turtle will wait 0.4 seconds
* before executing the next command in its queue, as it does for the standard turtle commands.
* @see ITurtleAccess#issueCommand( ITurtleCommandHandler )
*/
public boolean handleCommand( ITurtleAccess turtle );
}

View file

@ -0,0 +1,92 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.turtle.api;
import net.minecraft.util.Icon;
import dan200.computer.api.*;
/**
* The primary interface for defining an upgrade for Turtles. A turtle upgrade
* can either be a new tool, or a new peripheral.
* @see TurtleAPI#registerUpgrade( ITurtleUpgrade )
*/
public interface ITurtleUpgrade
{
/**
* Gets a unique numerical identifier representing this type of turtle upgrade.
* Like Minecraft block and item IDs, you should strive to make this number unique
* among all turtle upgrades that have been released for ComputerCraft.
* The ID must be in the range 64 to 255, as the ID is stored as an 8-bit value,
* and 0-64 is reserved for future use by ComputerCraft. The upgrade will
* fail registration if an already used ID is specified.
* @see TurtleAPI#registerUpgrade( ITurtleUpgrade )
*/
public int getUpgradeID();
/**
* Return a String to describe this type of upgrade in turtle item names.
* Examples of built-in adjectives are "Wireless", "Mining" and "Crafty".
*/
public String getAdjective();
/**
* Return whether this upgrade adds a tool or a peripheral to the turtle.
* Currently, turtle crafting is restricted to one tool & one peripheral per turtle.
* @see TurtleUpgradeType for the differences between the two.
*/
public TurtleUpgradeType getType();
/**
* Return an item stack representing the type of item that a turtle must be crafted
* with to create a turtle which holds this upgrade.
* Currently, turtle crafting is restricted to one tool & one peripheral per turtle.
*/
public net.minecraft.item.ItemStack getCraftingItem();
/**
* Return whether this turtle upgrade is an easter egg, and should be attempted to be hidden
* from the creative mode inventory and recipe book plugins.
*/
public boolean isSecret();
/**
* Will only be called for Peripheral upgrades. Creates a peripheral for a turtle
* being placed using this upgrade. The peripheral created will be stored
* for the lifetime of the turtle, will have update() called once-per-tick, and will be
* attach'd detach'd and have methods called in the same manner as a Computer peripheral.
* @param turtle Access to the turtle that the peripheral is being created for.
* @param side Which side of the turtle (left or right) that the upgrade resides on.
* @returns The newly created peripheral. You may return null if this upgrade is a Tool
* and this method is not expected to be called.
*/
public IHostedPeripheral createPeripheral( ITurtleAccess turtle, TurtleSide side );
/**
* Will only be called for Tool upgrades. Called when turtle.dig() or turtle.attack() is called
* by the turtle, and the tool is required to do some work.
* @param turtle Access to the turtle that the tool resides on.
* @param side Which side of the turtle (left or right) the tool resides on.
* @param verb Which action (dig or attack) the turtle is being called on to perform.
* @param direction Which world direction the action should be performed in, relative to the turtles
* position. This will either be up, down, or the direction the turtle is facing, depending on
* whether dig, digUp or digDown was called.
* @return Whether the turtle was able to perform the action, and hence whether the turtle.dig()
* or turtle.attack() lua method should return true. If true is returned, the tool will perform
* a swinging animation. You may return false if this upgrade is a Peripheral
* and this method is not expected to be called.
*/
public boolean useTool( ITurtleAccess turtle, TurtleSide side, TurtleVerb verb, int direction );
/**
* Called to obtain the Icon to be used when rendering a turtle peripheral. Needs to be a "block"
* type Icon for now, as there is no way to determine which texture sheet an Icon is from by the
* Icon itself.
* @param turtle Access to the turtle that the peripheral resides on.
* @param side Which side of the turtle (left or right) the peripheral resides on.
* @return The Icon that you wish to be used to render your turtle peripheral.
*/
public Icon getIcon( ITurtleAccess turtle, TurtleSide side );
}

View file

@ -0,0 +1,78 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.turtle.api;
import java.lang.reflect.Method;
/**
* The static entry point to the ComputerCraft Turtle Upgrade API.
* Members in this class must be called after mod_CCTurtle has been initialised,
* but may be called before it is fully loaded.
*/
public class TurtleAPI
{
/**
* Registers a new turtle upgrade for use in ComputerCraft. After calling this,
* users should be able to craft Turtles with your new upgrade. It is recommended to call
* this during the load() method of your mod.
* @throws Exception if you try to register an upgrade with an already used or reserved upgradeID
* @see ITurtleUpgrade
*/
public static void registerUpgrade( ITurtleUpgrade upgrade )
{
if( upgrade != null )
{
findCCTurtle();
if( ccTurtle_registerTurtleUpgrade != null )
{
try {
ccTurtle_registerTurtleUpgrade.invoke( null, new Object[]{ upgrade } );
} catch( Exception e ) {
// It failed
}
}
}
}
// The functions below here are private, and are used to interface with the non-API ComputerCraft classes.
// Reflection is used here so you can develop your mod in MCP without decompiling ComputerCraft and including
// it in your solution.
private static void findCCTurtle()
{
if( !ccTurtleSearched ) {
// Search for CCTurtle
try {
ccTurtle = Class.forName( "dan200.CCTurtle" );
ccTurtle_registerTurtleUpgrade = findCCTurtleMethod( "registerTurtleUpgrade", new Class[] {
ITurtleUpgrade.class
} );
} catch( ClassNotFoundException e ) {
System.out.println("ComputerCraftAPI: CCTurtle not found.");
} finally {
ccTurtleSearched = true;
}
}
}
private static Method findCCTurtleMethod( String name, Class[] args )
{
try {
return ccTurtle.getMethod( name, args );
} catch( NoSuchMethodException e ) {
System.out.println("ComputerCraftAPI: CCTurtle method " + name + " not found.");
return null;
}
}
private static boolean ccTurtleSearched = false;
private static Class ccTurtle = null;
private static Method ccTurtle_registerTurtleUpgrade = null;
}

View file

@ -0,0 +1,23 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.turtle.api;
/**
* An enum representing the two sides of the turtle that a turtle upgrade might reside.
*/
public enum TurtleSide
{
/**
* The turtles left side (where the pickaxe usually is on a Wireless Mining Turtle)
*/
Left,
/**
* The turtles right side (where the modem usually is on a Wireless Mining Turtle)
*/
Right,
}

View file

@ -0,0 +1,27 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.turtle.api;
/**
* An enum representing the two different types of upgrades that an ITurtleUpgrade
* implementation can add to a turtle.
* @see ITurtleUpgrade
*/
public enum TurtleUpgradeType
{
/**
* A tool is rendered as an item on the side of the turtle, and responds to the turtle.dig()
* and turtle.attack() methods (Such as pickaxe or sword on Mining and Melee turtles).
*/
Tool,
/**
* A peripheral adds a special peripheral which is attached to the side of the turtle,
* and can be interacted with the peripheral API (Such as the modem on Wireless Turtles).
*/
Peripheral,
}

View file

@ -0,0 +1,26 @@
/**
* This file is part of the public ComputerCraft API - http://www.computercraft.info
* Copyright Daniel Ratcliffe, 2011-2013. 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.turtle.api;
/**
* An enum representing the two different actions that an ITurtleUpgrade of type
* Tool may be called on to perform by a turtle.
* @see ITurtleUpgrade
* @see ITurtleUpgrade#useTool
*/
public enum TurtleVerb
{
/**
* The turtle called turtle.dig(), turtle.digUp() or turtle.digDown()
*/
Dig,
/**
* The turtle called turtle.attack(), turtle.attackUp() or turtle.attackDown()
*/
Attack,
}