<no title> — MCPQ 1.0.0 documentation

MCPQ 1.0.0 documentation

class Turtle(mc: Minecraft | None = None, pos: Vec3 | None = None, world: World | str | None = None)

  The turtle is similar to the Python turtle module, in that it is a construct that can move precisely while drawing a line behind it.

  The turtle takes three optional arguments, which will be set to the following defaults if not otherwise specified:

  - mc will be initialized with a connection to localhost

  - pos will be initialized to pos of `getPlayer()`

  - world will be initialized to mc (default world)

  If any of these are provided use the provided arguments instead.

      from mcpq import Minecraft, Vec3
      from mcpq.tools import Turtle

      mc = Minecraft()  # connect to server on localhost
      t = Turtle(mc)  # spawn turtle at player position
      t.speed(10)

      for i in range(4):
          t.fd(10).right(90)

  Note

  All methods of `Turtle` return itself, so that methods can be chained together, e.g., `t.speed(10).fd(50).rt(90).body("iron_block").fd(10)`.

  Note

  Most methods have shortcuts, such as `forward()` = fd or `right()` = rt.

  property pos: Vec3

    Current precise position of head (including decimal points)

  home() → Turtle

    Equivalent to `goto()` with the position the turtle spawned at

  goto(pos: Vec3) → Turtle

    Look at and move in a direct line to pos

  teleport(pos: Vec3) → Turtle

    Teleport directly to pos. Does not draw line there

  head(block: str) → Turtle

    Set the head of the turtle to block

  body(block: str) → Turtle

    Set the body of the turtle to block - this will be used to draw

  speed(speed: float) → Turtle

    Set the speed of the turtle. Roughly corresponds to the number of blocks set per second, i.e., how long the turtle waits between each step => 1 / speed. Can be set to 0 for fastest, i.e., do not wait between steps.

  forward(by: float) → Turtle

    Move by 1-sized steps in the current forward direction

  backward(by: float) → Turtle

    Move by 1-sized steps opposite the current forward direction

  right(angle: float) → Turtle

    Turn angle degrees right in place

  left(angle: float) → Turtle

    Turn angle degrees left in place

  up(angle: float) → Turtle

    Turn angle degrees up in place

  down(angle: float) → Turtle

    Turn angle degrees down in place

  pendown() → Turtle

    Stop drawing while moving until `penup()` is called (default)

  penup() → Turtle

    Stop drawing while moving until `pendown()` is called

  pensize(size: int) → Turtle

    Change the width of the pen used to draw

  hidehead() → Turtle

    Do not show the head of the turtle (draws body instead)

  showhead() → Turtle

    Show the head of the turtle (default)

  start_batch_mode(batch_time: float) → Turtle
  stop_batch_mode() → Turtle