Tutorials/Command blocks and functions/tp engine

From Minecraft Wiki
Jump to: navigation, search
C1
D1
C2
D2
C3
D3
A
C4
D4
C5
D5
B
C6
D6
Teleport-flying engine.
Command block key
Letter Meaning or command
A /clear @a filled_map - clears filled maps from all players. (Start/Stop trigger)
B /give @a empty_map - gives all players an empty map upon toggling.
Cx These command blocks check for the closest players holding the xth item in the hotbar, starting from the left:
  1. /testfor @p {SelectedItemSlot:0}
  2. /testfor @p {SelectedItemSlot:1}
  3. /testfor @p {SelectedItemSlot:2}
  4. /testfor @p {SelectedItemSlot:3}
  5. /testfor @p {SelectedItemSlot:4}
  6. /testfor @p {SelectedItemSlot:5}
Dx Depends on the x number in the schematic:
  1. /tp @p ~ ~1 ~0.5 - teleports the closest player to the south.
  2. /tp @p ~-0.5 ~1 ~ - teleports the closest player to the west.
  3. /tp @p ~ ~1 ~-0.5 - teleports the closest player to the north.
  4. /tp @p ~0.5 ~1 ~ - teleports the closest player to the east.
  5. /tp @p ~ ~2.0 ~ - teleports the closest player upwards.
  6. /tp @p ~ ~0.5 ~ - teleports the closest player downwards.
Behavior

On each comparator 1-clock pulse, the engine checks for a filled map and for specific tools (2nd line, locked when off). When there is a map, the command block (D) and T Flip-Flop are activated. The former gives an empty map back, while the latter unlocks the repeater on the 2nd line. When another filled map appears, it is deleted too, the T Flip-Flop is toggled, and the 2nd line is locked.

When the 2nd line is unlocked, the 6 command blocks checking current hotbar slots are activated on each clock pulse. Each corresponds to its own flying direction. If the nearest player holds something, they are moved in a specific direction.

The machine can be turned off by flipping the lever.