Skip to content

Instantly share code, notes, and snippets.

@JosephMedina96
Last active April 17, 2018 18:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JosephMedina96/6fea914c67bd54ef3eda7a2ae641433f to your computer and use it in GitHub Desktop.
Save JosephMedina96/6fea914c67bd54ef3eda7a2ae641433f to your computer and use it in GitHub Desktop.
Intermediate-Programming Class Language Cheat Sheet Assignment

Minecraft Command Blocks / Redstone Cheatsheet

Intermediate Programming

Minecraft redstone and command blocks, though impractical as a means of programming complex behaviors outside of the context of Minecraft, are an effective way to augment your gameplay experiences. This cheatsheet aims to help identify the core components of Minecraft's redstone system as well as set up some foundational knowledge of a simple redstone "program".

Components:

Power Sources:

Constant Sources

  • Redstone Block (High Power)
  • Redstone Torch (Low Power)
  • Lever (Low Power)
  • Daylight Sensor (Variable Power, Based around in-game day cycle)

Impulse Sources

  • Pressure Plates [Wooden, Stone, Iron, Gold] (Low Power)
  • Buttons [Wooden, Stone] (Low Power)
  • Armed Tripwire (Low Power)
  • Trapped Chest (Low Power)
  • Detector Rail (Low Power)

Wires (Connections):

  • Redstone Dust [Known simply as “Redstone”]
  • Redstone Repeater

Function Object:

  • Command Block

Redstone Behavior:

  • Redstone will become powered when placed next to a power source. This will always be true unless there is an obstruction or space between the power source and the Redstone.
  • When wired to a block, the Redstone signal will affect anything that block is touching.
  • Redstone torches have two distinct states: On and Off. A Redstone torch can be powered off when another Redstone signal is wired and powered to the block that the torch is on.
  • Redstone cannot be wired vertically.
  • A Redstone signal can be extended by attaching a Redstone repeater.

Commands:

Target Selectors:

  • @p = Nearest Player
  • @r = Random Player
  • @a = All Players
  • @e = All Entities (Includes Players)
  • @s = The Entity that Initiated the Command

A Full Command List Can Be Found Here: Commands

Functions:

Getting a command block:

In Minecraft, the command block is a block that cannot be obtained through normal in-game means. To obtain a command block, there are certain pre-requisites:

  • In single player: Ensure that commands are enabled.
  • In multiplayer: Ensure that you have operator permissions on the server. To gain operator permissions, type: /op Your-In-Game-Name-Here. This command will not work if you aren’t either A) the server owner -OR- B) a server moderator.

Once the pre-requisites are fulfilled, type: /give Your-In-Game-Name-Here minecraft:command_block 1

The command block and you - The Basics:

  • A command block can execute a command when activated by redstone power.
  • An individual command block has an orientation when placed. This orientation will determine which commands will be executed first when working with chains of command blocks.
  • You can interact with a command block by right clicking it. However, the contents of the block cannot be altered unless you have met the pre-requisites for getting a command block in the first place.
  • A command block has three modes, which can be set from the GUI that is opened when the block is right-clicked:
    • Impulse: Will execute the commands inside it once per activation.
    • Chain: Will only execute when the command block pointing to it is processed.
    • Repeat: Will constantly (once per game tick, 20 times a second barring lag) execute until it is deactivated.
  • A command block can be conditional or unconditional:
    • Conditional: Will only execute when a command is successfully processed.
    • Unconditional: Will execute regardless of success. Unsuccessful activations will not do anything.
  • Additionally, a command block can be set to always be active. When this property is set, impulse command blocks will fire only once and become unactivate-able afterward, chain command blocks will activate when chained even if there is no power source, and repeat command blocks will always execute the commands (20 times per second, not accounting for game lag).

A Simple Hello World Program:

One of the simplest “Hello, World!” programs written in Minecraft using Redstone and Command Blocks can be made with three components:

  • A Lever -OR- A Button -OR- A Pressure Plate
  • A piece of Redstone
  • A Command Block

This setup can be simplified further by taking advantage of the “Always Active” property of the command block, but for this example we will be using these components to outline a basic program structure.

To begin, place down your Button / Lever / Pressure Plate. As a conditional power source, these components are the most common. Next, place the Redstone next to your power source. Finally, place your command block at the end of the Redstone wiring. Right-click the command block to access the commands GUI. In the space provided for commands, type the following: /say Hello, World!

Upon exiting the GUI, the system should say something along the lines of “Command set: /say Hello, World! ”. This signifies that our program is ready to be activated. From here, simply activate the power source and the words “Hello, World!” will be written in the in-game chat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment