Skip to content

Undoing

dflat2 edited this page Feb 17, 2024 · 1 revision

TL;DR. Use /Undo to undo, /Redo to redo. Don't enable physics.

There are 6 undo-related commands:

  • /Undo
  • /Redo
  • /Later <duration>
  • /Earlier <duration>
  • /UndoList
  • /Checkout <operation>

Limitations

  1. It is not possible to undo physics. It's highly recommended not to turn block physics on (the plugin will disable them automatically when loading), as it may cause strange behaviour when undoing.
  2. You cannot undo the default /Cuboid command (included with ClassiCube). It is recommended to use /Z, instead.
  3. The block database is cleared when you quit the game and when you change map (like most programs, actually, but unlike MCGalaxy which has persistent undo storage).

Undo

When you do any draw operation such as /Fill, /Tree, etc. it will be recorded in the block database, which has the structure of a tree. For example, after loading a new world and running /Z, the block database will look like:

graph TD;
    root["# (0)"]-->cuboid1["Z (1)"]
    style cuboid1 color:aqua
Loading

Where # is the name of the root. The number between parenthesis is the operation identifier (it will auto increment). If you do /Undo, the Z will be undone, and your position in the tree will be updated accordingly.

graph TD;
    root["# (0)"]-->cuboid1["Z (1)"]
    style root color:aqua
Loading

If you do another operation, ie. place a block, it will create another operation from the current node, etc.

graph TD;
    root["# (0)"]-->cuboid1["Z (1)"]
    root-->place2["Place (2)"]
    place2-->fill3["Fill (3)"]
    style fill3 color:aqua
Loading

The /Undo command always perform the same movement in the tree: it ascends. Undoing from the last position will bring you back to Place.

graph TD;
    root["# (0)"]-->cuboid1["Z (1)"]
    root-->place2["Place (2)"]
    place2-->fill3["Fill (3)"]
    style place2 color:aqua
Loading

Redo

The /Redo command will revert the last movement in the block database structure. When used after /Undo, it descends back. In addition, it can also be used to revert /Later <duration>, /Earlier <duration>, and /Checkout <operation>.

Later/earlier

These commands allow you to travel through time, relatively to where you stand in the undo tree. For example, let's say this is the block database:

graph TD;
    root["# (9:01 AM)"]-->cuboid1["Z (9:19 AM)"]
    root-->place2["Place (10:00 AM)"]
    place2-->fill3["Fill (10:23 AM)"]
    place2-->tree4["Tree (10:43 AM)"]
    tree4-->fill5["Fill (11:05 AM)"]
    style place2 color:aqua
Loading

If you do /Earlier 1min, it will sets the map to its state 1 minute before you placed that block, checking out the operation Z (9:19 AM).

graph TD;
    root["# (9:01 AM)"]-->cuboid1["Z (9:19 AM)"]
    root-->place2["Place (10:00 AM)"]
    place2-->fill3["Fill (10:23 AM)"]
    place2-->tree4["Tree (10:43 AM)"]
    tree4-->fill5["Fill (11:05 AM)"]
    style cuboid1 color:aqua
Loading

Now, if you do /Later 2h, it navigates 2 hours after you did that Z, which is 9:19 AM + 2 hours = 11:19 AM, resolving to Fill (11:05 AM).

graph TD;
    root["# (9:01 AM)"]-->cuboid1["Z (9:19 AM)"]
    root-->place2["Place (10:00 AM)"]
    place2-->fill3["Fill (10:23 AM)"]
    place2-->tree4["Tree (10:43 AM)"]
    tree4-->fill5["Fill (11:05 AM)"]
    style fill5 color:aqua
Loading

If you accidentally /Later or /Earlier to an operation and want to come back where you were, just do /Redo.

Checkout

The /Checkout <operation> command will checkout an operation from its identifier. For example, /Checkout 0 will checkout the root.

graph TD;
    root["# (0)"]-->cuboid1["Z (1)"]
    root-->place2["Place (2)"]
    place2-->fill3["Fill (3)"]
    place2-->tree4["Tree (4)"]
    tree4-->fill5["Fill (5)"]
    style root color:aqua
Loading

UndoList

The /UndoList command does not perform any movement in the block database. It will just print the terminal operations (in red below).

graph TD;
    root["# (0)"]-->cuboid1["Z (1)"]
    root-->place2["Place (2)"]
    place2-->fill3["Fill (3)"]
    place2-->tree4["Tree (4)"]
    tree4-->fill5["Fill (5)"]
    style root color:aqua
    style fill5 color:red
    style fill3 color:red
    style cuboid1 color:red
Loading

For convenience, only that 5 most recent terminal operations are displayed to the user.

Clone this wiki locally