Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## dan200.turtle.api
Interface ITurtleAccess

    public interface ITurtleAccess

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.

Method Summary
`boolean` | `attackWithItemStack(net.minecraft.item.ItemStack stack, int dir, float damageMultiplier)` Tries to "attack" entities with an item stack in the direction specified.
`boolean` | `consumeFuel(int fuel)` Removes some fuel from the turtles fuel supply.
`boolean` | `deployWithItemStack(net.minecraft.item.ItemStack stack, int dir)` "Deploys" an item stack in the direction specified.
`boolean` | `dropItemStack(net.minecraft.item.ItemStack stack, int dir)` 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.
`int` | `getFacingDir()` Returns the world direction the turtle is currently facing.
`int` | `getFuelLevel()` 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.
`int` | `getInventorySize()` Returns the size of the turtles inventory, in number of slots.
`IHostedPeripheral` | `getPeripheral(TurtleSide side)` Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.
`net.minecraft.util.Vec3` | `getPosition()` Returns a vector containing the integer block co-ordinates at which the turtle resides.
`int` | `getSelectedSlot()` Returns which slot the turtle currently has selected in its inventory using turtle.select().
`net.minecraft.item.ItemStack` | `getSlotContents(int index)` Returns the item stack that the turtle has in one of its inventory slots.
`ITurtleUpgrade` | `getUpgrade(TurtleSide side)` Returns the upgrade on the specified side of the turtle, if there is one.
`net.minecraft.util.Vec3` | `getVisualPosition(float f)` Returns a vector containing the co-ordinates at which the turtle is rendered.
`net.minecraft.world.World` | `getWorld()` Returns the world in which the turtle resides.
`int` | `issueCommand(ITurtleCommandHandler handler)` Adds a custom command to the turtles command queue.
`boolean` | `refuelWithItemStack(net.minecraft.item.ItemStack stack)` Tries to increase the fuel level of a turtle by burning an item stack.
`void` | `setSlotContents(int index, net.minecraft.item.ItemStack stack)` Changes the item stack that the turtle has in one of its inventory slots.
`boolean` | `storeItemStack(net.minecraft.item.ItemStack stack)` Tries to store an item stack into the turtles current inventory, starting from the turtles currently selected inventory slot.

Method Detail

### getWorld

    net.minecraft.world.World getWorld()

  Returns the world in which the turtle resides.

  Returns:
    the world in which the turtle resides.

### getPosition

    net.minecraft.util.Vec3 getPosition()

  Returns a vector containing the integer block co-ordinates at which the turtle resides.

  Returns:
    a vector containing the integer block co-ordinates at which the turtle resides.

### getVisualPosition

    net.minecraft.util.Vec3 getVisualPosition(float f)

  Returns a vector containing the co-ordinates at which the turtle is rendered. This will shift when the turtle is moving.

  Parameters:
    `f` - The subframe fraction
  Returns:
    a vector containing the integer block co-ordinates at which the turtle resides.

### getFacingDir

    int getFacingDir()

  Returns the world direction the turtle is currently facing.

  Returns:
    the world direction the turtle is currently facing.

### getInventorySize

    int getInventorySize()

  Returns the size of the turtles inventory, in number of slots. This will currently always be 16.

  Returns:
    the size of the turtles inventory, in number of slots. This will currently always be 16.

### getSelectedSlot

    int getSelectedSlot()

  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.

  Returns:
    which slot the turtle currently has selected in its inventory

### getSlotContents

    net.minecraft.item.ItemStack getSlotContents(int index)

  Returns the item stack that the turtle has in one of its inventory slots.

  Parameters:
    `index` - which inventory slot to retreive, should be between 0 and getInventorySize() - 1
  Returns:
    the item stack that the turtle has in one of its inventory slots. May be null.

### setSlotContents

    void setSlotContents(int index,
                         net.minecraft.item.ItemStack stack)

  Changes the item stack that the turtle has in one of its inventory slots.

  Parameters:
    `index` - which inventory slot to change, should be between 0 and getInventorySize() - 1
    `stack` - an item stack to put in the slot. May be null.

### storeItemStack

    boolean storeItemStack(net.minecraft.item.ItemStack stack)

  Tries to store an item stack into the turtles current inventory, starting from the turtles currently selected inventory slot.

  Parameters:
    `stack` - The item stack to try and store.
  Returns:
    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.

### dropItemStack

    boolean dropItemStack(net.minecraft.item.ItemStack stack,
                          int dir)

  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.

  Parameters:
    `stack` - The item stack to drop.
    `dir` - The world direction to drop the item
  Returns:
    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.

### deployWithItemStack

    boolean deployWithItemStack(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.

  Parameters:
    `stack` - The item stack to deploy
    `dir` - The world direction to deploy the item
  Returns:
    true if the stack was deployed, false if it was not.

### attackWithItemStack

    boolean attackWithItemStack(net.minecraft.item.ItemStack stack,
                                int dir,
                                float damageMultiplier)

  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.

  Parameters:
    `stack` - The item stack to attack with
    `dir` - The world direction to attack with the item
  Returns:
    true if something was attacked, false if it was not

### getFuelLevel

    int getFuelLevel()

  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.

  Returns:
    the fuel level

### refuelWithItemStack

    boolean refuelWithItemStack(net.minecraft.item.ItemStack stack)

  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.

  Parameters:
    `stack` - The stack to try to refuel with
  Returns:
    Whether the turtle was refueled

### consumeFuel

    boolean consumeFuel(int fuel)

  Removes some fuel from the turtles fuel supply. Negative numbers can be passed in to INCREASE the fuel level of the turtle.

  Returns:
    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.

### issueCommand

    int issueCommand(ITurtleCommandHandler handler)

  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.

  Parameters:
    `handler` - an object which will execute the custom command when its point in the queue is reached
  Returns:
    the unique command identifier described above
  See Also:
    `ITurtleCommandHandler`

### getUpgrade

    ITurtleUpgrade getUpgrade(TurtleSide side)

  Returns the upgrade on the specified side of the turtle, if there is one.

  Returns:
    the upgrade on the specified side of the turtle, if there is one.

### getPeripheral

    IHostedPeripheral getPeripheral(TurtleSide side)

  Returns the peripheral created by the upgrade on the specified side of the turtle, if there is one.

  Returns:
    the peripheral created by the upgrade on the specified side of the turtle, if there is one.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD