diff --git a/com/naef/jnlua/console/LuaConsole.java b/com/naef/jnlua/console/LuaConsole.java deleted file mode 100644 index b55ba6760..000000000 --- a/com/naef/jnlua/console/LuaConsole.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * $Id: LuaConsole.java 79 2012-01-08 11:08:32Z andre@naef.com $ - * See LICENSE.txt for license terms. - */ - -package com.naef.jnlua.console; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; - -import com.naef.jnlua.LuaException; -import com.naef.jnlua.LuaRuntimeException; -import com.naef.jnlua.LuaState; - -/** - * A simple Lua console. - * - *
- * The console collects input until a line with the sole content of the word
- * go is encountered. At that point, the collected input is run as a Lua
- * chunk. If the Lua chunk loads and runs successfully, the console displays the
- * returned values of the chunk as well as the execution time based on a
- * System.nanoTime()
measurement. Otherwise, the console shows the
- * error that has occurred.
- *
- * Expressions can be printed by prepending = to the expression at the
- * beginning of a chunk. The console translates = into
- * return
followed by a space and executes the chunk immediately.
- * No separate go is required. Therefore, expressions printed this way
- * must be entered on a single line.
- *
argv
global variable.
- *
- * @param args
- */
- public LuaConsole(String[] args) {
- luaState = new LuaState();
-
- // Process arguments
- luaState.newTable(args.length, 0);
- for (int i = 0; i < args.length; i++) {
- luaState.pushString(args[i]);
- luaState.rawSet(-2, i + 1);
- }
- luaState.setGlobal("argv");
-
- // Open standard libraries
- luaState.openLibs();
-
- // Set buffer mode
- luaState.load("io.stdout:setvbuf(\"no\")", "=consoleInitStdout");
- luaState.call(0, 0);
- luaState.load("io.stderr:setvbuf(\"no\")", "=consoleInitStderr");
- luaState.call(0, 0);
- }
-
- // -- Properties
- /**
- * Returns the Lua state of this console.
- *
- * @return the Lua state
- */
- public LuaState getLuaState() {
- return luaState;
- }
-
- // -- Operations
- /**
- * Runs the console.
- */
- public void run() {
- // Banner
- System.out.println(String.format("JNLua %s Console using Lua %s.",
- LuaState.VERSION, LuaState.LUA_VERSION));
- System.out.print("Type 'go' on an empty line to evaluate a chunk. ");
- System.out.println("Type =Provides the JNLua console.
- - diff --git a/com/naef/jnlua/script/CompiledLuaScript.java b/com/naef/jnlua/script/CompiledLuaScript.java deleted file mode 100644 index c83d4ec7f..000000000 --- a/com/naef/jnlua/script/CompiledLuaScript.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * $Id: CompiledLuaScript.java 38 2012-01-04 22:44:15Z andre@naef.com $ - * See LICENSE.txt for license terms. - */ - -package com.naef.jnlua.script; - -import java.io.ByteArrayInputStream; - -import javax.script.CompiledScript; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptException; - -/** - * Compiled script implementation conforming to JSR 223: Scripting for the Java - * Platform. - */ -class CompiledLuaScript extends CompiledScript { - // -- State - private LuaScriptEngine engine; - private byte[] script; - - // -- Construction - /** - * Creates a new instance. - */ - public CompiledLuaScript(LuaScriptEngine engine, byte[] script) { - this.engine = engine; - this.script = script; - } - - // -- CompiledScript methods - @Override - public Object eval(ScriptContext context) throws ScriptException { - synchronized (engine.getLuaState()) { - engine.loadChunk(new ByteArrayInputStream(script), context, "b"); - return engine.callChunk(context); - } - } - - @Override - public ScriptEngine getEngine() { - return engine; - } -} diff --git a/com/naef/jnlua/script/LuaBindings.java b/com/naef/jnlua/script/LuaBindings.java deleted file mode 100644 index 6a15869c3..000000000 --- a/com/naef/jnlua/script/LuaBindings.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * $Id: LuaBindings.java 38 2012-01-04 22:44:15Z andre@naef.com $ - * See LICENSE.txt for license terms. - */ - -package com.naef.jnlua.script; - -import javax.script.Bindings; - -import com.naef.jnlua.LuaState; -import com.naef.jnlua.util.AbstractTableMap; - -/** - * Lua bindings implementation conforming to JSR 223: Scripting for the Java - * Platform. - */ -class LuaBindings extends AbstractTableMapProvides the JNLua provider for JSR 223: Scripting for the Java platform.
- - diff --git a/dan200/turtle/api/ITurtleAccess.java b/dan200/turtle/api/ITurtleAccess.java deleted file mode 100644 index f996bf47e..000000000 --- a/dan200/turtle/api/ITurtleAccess.java +++ /dev/null @@ -1,158 +0,0 @@ -/** - * 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 ); -} diff --git a/dan200/turtle/api/ITurtleCommandHandler.java b/dan200/turtle/api/ITurtleCommandHandler.java deleted file mode 100644 index 255d28e22..000000000 --- a/dan200/turtle/api/ITurtleCommandHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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 ); -} diff --git a/dan200/turtle/api/ITurtleUpgrade.java b/dan200/turtle/api/ITurtleUpgrade.java deleted file mode 100644 index 3af5127b6..000000000 --- a/dan200/turtle/api/ITurtleUpgrade.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * 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 ); -} diff --git a/dan200/turtle/api/TurtleAPI.java b/dan200/turtle/api/TurtleAPI.java deleted file mode 100644 index 3e3c5c1f2..000000000 --- a/dan200/turtle/api/TurtleAPI.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * 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; -} diff --git a/dan200/turtle/api/TurtleSide.java b/dan200/turtle/api/TurtleSide.java deleted file mode 100644 index 3459d7772..000000000 --- a/dan200/turtle/api/TurtleSide.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * 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, -} diff --git a/dan200/turtle/api/TurtleUpgradeType.java b/dan200/turtle/api/TurtleUpgradeType.java deleted file mode 100644 index a65fed8ac..000000000 --- a/dan200/turtle/api/TurtleUpgradeType.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * 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, -} diff --git a/dan200/turtle/api/TurtleVerb.java b/dan200/turtle/api/TurtleVerb.java deleted file mode 100644 index a1b2531af..000000000 --- a/dan200/turtle/api/TurtleVerb.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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, -}