The redstone comparator, you’ve all seen it in the redstone menu, but how do you actually use it? The redstone comparator has a couple of functions that will be highlighted in this article.
This is the crafting recipe of the redstone comparator. You’ll be needing 3 redstone torches, 1 quartz and 3 (smooth) stone.
The redstone comparator’s first mode is the comparison mode, where it has its front torch switched off. It will compare its rear input to the side inputs. The side where the torch is that you can switch on or off, that is the front side of the comparator. Here’s how the comparison mode works: if either side input is greater than the rear input, the comparator output turns off. If neither side input is greater than the rear input, the comparator outputs the same signal strength as its rear input.
The redstone comparator’s second mode is the subtraction mode: here it has its front torch switched on. How does it work? The comparator will subtract the signal strength of the highest side input from the signal strength of the rear input.
For example, if the rear input signal strength is 7, the left side is 2, and the right side is 4, then the output will be a signal strength of 3, since the highest side input is 4, and 7-4=3.
Measuring block states
A redstone comparator can also emit a redstone signal with a strength depending on the block state of the block behind it. For example, an empty chest at the rear side of the comparator will emit a redstone signal with 0 strength (so no signal at all). However, a chest which is completely filled will make the redstone comparator emit a redstone signal with the maximum strength (so 15). The comparator can even ‘feel’ the block’s block state through a (solid) block!
Here’s a list of basic blocks that can have their block state measured by a comparator:
- Furnace, blast furnace or smoker (measures all 3 slots together)
- Shulker box
- Chest or double chest
- Trapped chest or trapped double chest
- Brewing stand (measures all 5 slots together)
- Minecart with chest or hopper (must be on top of a detector rail)
Then, there are some special miscellaneous blocks that can also have their block state measured:
- Cake (each slice is worth 2 signal strength, with 7 total slices, for an output of 14 for a full cake)
- Cauldron (from completely empty to completely full, the output values are 0, 1, 2, and 3)
- Item frame (measures the item’s rotation, output values are 1 up to 8)
- Composter (from completely empty to completely full, the output values are 0 up to 8)
- End portal frame (if it has no ender eye, the output value is 0, if it contains an ender eye, the output value is 15)
- Jukebox (a jukebox outputs a signal strength which indicates which music disc is currently playing)
- Lectern (a lectern outputs a signal strength which depending on what page the player is currently on (e.g. a book with 15 pages will power 1 redstone level per page, or one with 5 pages will emit 3 signal strength per page))
Finally, there’s one more block that we haven’t covered yet and this is the command block, as this one demands some extra clarification.
Measuring block states: the command block
A command block stores the “success count” of the last command executed, which represents the number of times the most recently used command of this command block succeeded. A “success” is defined by the command’s success conditions: if a red error message is returned in the chat, the command was not successful.
Most commands can only succeed once per execution, but certain commands (such as those which accept players as arguments) can succeed multiple times, and the comparator will output the number of times it succeeded (maximum 15).
A command block continues to store the success count of the last command executed until it executes its command again, thus the comparator will continue to output the same signal strength even after the command block is no longer being activated (it doesn’t turn off when the signal to the command block turns off).
Protip: read more about commands on the minecraft wiki.