Minecraft:Redstone Comparator
More actions
Template:For Template:Infobox block A redstone comparator is a Minecraft:block that can produce a Minecraft:redstone signal from its front by reading Minecraft:chests, Minecraft:lecterns, Minecraft:copper bulbs, and similar blocks. It can also repeat a signal without changing its strength.
It can also be Template:Control to either stop outputting a signal while its side input is receiving a stronger one (front torch off), or output a weaker signal based on its side input's signal strength (front torch on).
Obtaining
Breaking
A redstone comparator can be broken instantly with any Minecraft:tool, or by hand, and drops itself as an item.
A redstone comparator is removed and dropped as an item if:
- its attachment block is moved, removed, or destroyed;
- Minecraft:water flows into its space;Template:Only
- a Minecraft:piston tries to push it or moves a block into its space.
If Minecraft:lava flows into a redstone comparator's space, the redstone comparator is destroyed without dropping as an item.
Natural generation
2–9 Redstone comparators generate in Minecraft:ancient cities.
Crafting
Usage
A redstone comparator can be placed on the top of any Minecraft:opaque block with a solid full-height top surface (including upside-down Minecraft:slabs and upside-down Minecraft:stairs). Template:IN, a comparator can also be placed on Minecraft:walls and Minecraft:fences. For more information about placement on transparent blocks, see Minecraft:Opacity/Placement.
The redstone comparator has a front and a back — the arrow on the top of the comparator points to the front. When placed, the comparator faces away from the player. The comparator has two miniature redstone torches at the back and one at the front. The back torches turn on when the comparator's output is greater than zero (the arrow on top also turns red). The front torch has two states that can be toggled by Template:Control the comparator:
- Down and unpowered (indicating the comparator is in "comparison mode")
- Up and powered (indicating the comparator is in "subtraction mode")
The redstone comparator can take a signal strength input from its rear as well as from both sides. Side inputs are accepted only from Minecraft:redstone dust, Minecraft:block of redstoneTemplate:Only, Minecraft:redstone repeaters, other comparators, and Minecraft:observers in specific scenarios. The redstone comparator's front is its output.
It takes Template:Convert for signals to move through a redstone comparator, either from the rear or from the sides. This applies to changing signal strengths as well as simply to turning on and off.
Redstone comparators check their power state before their scheduled ticks update. This results in redstone comparators not usually responding to 1-tick fluctuations of power or signal strength — for example, a 1-clock input is treated as always off from the side, and always on from the rear. This happens because the signal changes back to its original state before the redstone comparator checks its input states. However, certain setups such as powering any input with two separate observer pulses at the same time causes a redstone comparator to respond to 2-game-tick pulses.
The redstone comparator has four functions: maintain signal strength, compare signal strength, subtract signal strength, and measure certain block states (primarily the fullness of containers).
Maintain signal strength
A redstone comparator with no powered sides outputs the same signal strength as its rear input, with a 1 redstone tick (= 2 game ticks) delay.
Compare signal strength
A redstone comparator in comparison mode (front torch down and unpowered) compares its rear input to its two side inputs. 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 formula for calculating the output signal strength is as follows:
output = rear × [left ≤ rear AND right ≤ rear]
Subtract signal strength
A redstone comparator in subtraction mode (front torch up and powered) subtracts the signal strength of the greater side input from the signal strength of the rear input.
output = max(rear − max(left, right), 0)
For example: if the signal strength is 6 at the left input, 7 at the right input and 4 at the rear, the output signal has a strength of max(4 − max(6, 7), 0) = max(4−7, 0) = max(−3, 0) = 0.
If the signal strength is 9 at the rear, 2 at the right input and 5 at the left input, the output signal has a strength of max(9 − max(2, 5), 0) = max(9−5, 0) = 4.
Measure block state
Template:Schematic A redstone comparator treats certain blocks behind it as power sources and outputs a signal strength proportional to the block's state. The comparator may be separated from the measured block by a comparator-conducting block. These blocks include all Minecraft:conductive blocks, but see below.
The comparator disregards the power level of the intervening block in this configuration.
Template:IN, if the intervening block is powered to signal strength 15, then the comparator outputs 15 no matter the fullness of the container.<ref>Template:Bug</ref> This never occurs Template:In.
Template:IN the list of comparator-conducting blocks also includes some non-conductive blocks. This may be useful in contraptions as they do not conduct redstone signals from elsewhere like a regular Minecraft:conductive block would.<ref>Template:Bug</ref> These blocks are:
- Template:BlockLink
- Template:BlockLink and Template:BlockLink
- Template:BlockLink and Template:BlockLink
- Template:BlockLink (all variants)
- Template:BlockLink and Template:BlockLink
- Template:BlockLink
Fullness of containers
| Containers | Template:BlockSprite | Template:BlockSprite Template:BlockSprite Template:BlockSprite |
Template:BlockSprite Template:EntitySprite Template:BlockSprite |
Template:BlockSprite Template:BlockSprite |
Template:BlockSprite Template:EntitySprite Template:BlockSprite Template:BlockSprite Template:BlockSprite |
Template:BlockSpriteTemplate:BlockSprite | Template:BlockSprite | Template:BlockSprite | Template:BlockSprite |
|---|---|---|---|---|---|---|---|---|---|
| Total slots | 1 | 3 | 5 | 9 | 27 | 54 | 1 | 9 | 4 |
| Power level | Number of items | Music disc | No. of slots
filled |
No. of
Glowstone | |||||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | No disc | 0 | 0 |
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 13 | 1 | |
| 2 | 5 | 14 | 23 | 42 | 1s+60 | 3s+55 | cat | 2 | |
| 3 | 10 | 28 | 46 | 1s+19 | 3s+55 | 7s+46 | blocks | 3 | 1 |
| 4 | 14 | 42 | 1s+5 | 1s+60 | 5s+51 | 11s+37 | chirp | 4 | |
| 5 | 19 | 55 | 1s+28 | 2s+37 | 7s+46 | 15s+28 | far | 5 | |
| 6 | 23 | 1s+5 | 1s+51 | 3s+14 | 9s+42 | 19s+19 | mall | 6 | |
| 7 | 28 | 1s+19 | 2s+10 | 3s+55 | 11s+37 | 23s+10 | mellohi | 7 | 2 |
| 8 | 32 | 1s+32 | 2s+32 | 4s+32 | 13s+32 | 27s | stal | 8 | |
| 9 | 37 | 1s+46 | 2s+55 | 5s+10 | 15s+28 | 30s+55 | strad Lava Chicken |
9 | |
| 10 | 42 | 1s+60 | 3s+14 | 5s+51 | 17s+23 | 34s+46 | ward Tears |
- | |
| 11 | 46 | 2s+10 | 3s+37 | 6s+28 | 19s+19 | 38s+37 | 11 Creator (Music Box) |
- | 3 |
| 12 | 51 | 2s+23 | 3s+60 | 7s+5 | 21s+14 | 42s+28 | wait Creator |
- | |
| 13 | 55 | 2s+37 | 4s+19 | 7s+46 | 23s+10 | 46s+19 | Pigstep Precipice |
- | |
| 14 | 60 | 2s+51 | 4s+42 | 8s+23 | 25s+5 | 50s+10 | otherside Relic |
- | |
| 15 | 1s | 3s | 5s | 9s | 27s | 54s | 5 | - | 4 |
A redstone comparator can output a signal indicating how full a container is. (0 for empty, 15 for full, etc.) The table on the right is described more in detail, later in this section.
Note: s means stack.
Containers that can be measured by a comparator include:
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockLink
- Template:BlockSpriteTemplate:BlockSprite Minecraft:Large chest
- Template:BlockSpriteTemplate:BlockSprite Minecraft:Large copper chest
- Template:BlockSpriteTemplate:BlockSprite Minecraft:Large trapped chest
- Template:ItemLink on top of a Minecraft:detector rail
- Template:ItemLink on top of a Minecraft:detector rail
- Template:BlockLink
- Template:BlockLink (any color)
- Template:BlockLink
- Template:BlockLink
Generally speaking, the comparator output signal strength represents the average fullness of the slots, based on how many of that item form a full stack (64, 16, or 1 for non-stackable items). A partially filled bundle counts as a full stack.
The Minimum items for container signal strength table (right) shows the minimum full-stack-equivalent (FSE) to produce different signal strengths from common containers. A full-stack-equivalent quantifies how many normal 64-stackable items are needed to output a corresponding signal strength. The 's' is a constant 64, with the additional amount needed following after.
One may also consider the terms: cumulative-weight or weighted-sum instead of full-stack-equivalent.
Items that stack to a max of 16 (Minecraft:snowballs, Minecraft:signs, Minecraft:ender pearls, etc.), contribute +4 to the full-stack-equivalent for each unity (count of 1 item). Similarly, items that stack to 1 (Minecraft:minecart, Minecraft:boat, etc.) contribute +64, and items that stack to 64 contribute +1.
Example 1: 3 ender pearls contribute a 3×4 = 12 full-stack-equivalent.
Example 2: 16 ender pearls and 60 redstone dust contributes a 16×4 + 60×1 = 124 full-stack-equivalent.
Example 3: 1 minecart and 60 redstone dust contributes a 1×64 + 60×1 = 124 full-stack-equivalent.
Example 4: To produce a signal strength of 10 from a hopper, one requires a full-stack-equivalent of at least 3s + 14 = 206 but strictly less than 3s + 37 = 229. This can be done with 3 minecarts, and 14 dirt.
When a comparator measures a large chest or large trapped chest, it measures the entire large chest (54 slots), not just the half directly behind the comparator. Template:In, a chest or trapped chest that cannot be opened (either because it has a Minecraft:conductive block or a sitting Minecraft:cat above it) always produces an output of 0 no matter how many items are in the container — shulker boxes can always be measured, even if they cannot open.
- Calculating signal strength from items
- When a container is empty, the output is off.
- When it is not empty, the output signal strength is calculated as follows:
- Example: 300 blocks in a dispenser (which has 9 slots), where each block stacks to a maximum of 64 has a 300 full-stack-equivalent. This produces an output with a signal strength of 8:
1 + ((300 items / 64 items per slot) / 9 slots) × 14 = 8.292, floored is 8
- Calculating items from signal strength
- It can be useful in redstone circuits to use containers with comparators to create signals of a specific strength. The number of items required in a container to produce a signal of desired strength is calculated as follows:
- Example: To use a furnace (which has 3 slots) to create a strength 9 signal, players need 110 items:
max(9, (3×64/14) × (9−1)) = 109.714, rounded up is 110
Miscellaneous
Some non-container blocks can also be measured by a redstone comparator:
- Template:BlockLink and Template:BlockLink
- A hive or nest outputs a signal strength equal to the amount of honey in the hive/nest.
- Template:BlockLink
- A cake outputs a signal strength relative to the amount of cake remaining. Each slice is worth 2 signal strength, with 7 total slices, for an output of 14 for a full cake.
- Template:BlockLink
- A cauldron outputs different signal strengths depending on how much water or powder snow is inside. From completely empty to completely full, the output values are 0, 1, 2, and 3. If lava is inside, the strength is always 3.
- Template:BlockLink
- A chiseled bookshelf outputs a signal strength between 1 and 6 indicating the last slot interacted with. When no slot has been interacted with yet, it outputs 0.
- Template:BlockLink
- A composter outputs different signal strengths depending on the level inside. From completely empty to completely full, the output values are 0, 1, 2, 3, 4, 5, 6, 7 and 8.
- Note that under normal circumstances, a Composter will only temporarily produce power level 7 before automatically updating itself to level 8.
- Template:BlockLink
- A copper bulb at any oxidation stage emits a full signal of 15 when lit and 0 otherwise.
- Template:BlockLink
- A copper golem statue emits a signal strength from 1 to 4 based on its pose.
- Template:AnchorTemplate:BlockLink
- 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 Minecraft:command's success conditions: if a red error message is returned in the chat, the command was not successful.
- Most commands can succeed once per execution, but certain commands (such as those that accept players as arguments) can succeed multiple times, and the comparator outputs the number of times it succeeded (maximum 15 when sent to redstone dust, but in the code it is able to go up to the 32-bit integer limit, and can be used in contraptions with no redstone dust with those values).
- A command block continues to store the success count of the last command executed until it executes its command again, thus the comparator continues 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).
- Template:BlockLink
- A crafter outputs a signal strength equal to the number of crafting slots that are either disabled or occupied by an item. An empty crafter with no disabled slots does not output any signal through a comparator. A crafter with at least one slot disabled or filled outputs a signal through a comparator, with strength corresponding to the number of occupied slots.
- Template:BlockLink
- An active creaking heart with a Minecraft:creaking linked to it outputs a signal strength dependent on the Minecraft:Euclidean distance between the heart and its creaking. The strength is calculated as follows:
- Template:Math
- Template:BlockLink
- An end portal frame outputs a full signal of 15 if it contains an Minecraft:eye of ender and 0 otherwise.
- Template:EntityLink and Template:EntityLink
- A comparator can measure the state of an Minecraft:item frame's contents. An item frame comparator outputs 0 if the item frame is empty, or 1 to 8 for any item depending on its rotation: 1 at initial placement, plus 1 for each 45° of rotation for a maximum of 8.
- A map placed inside of an item frame rotates 90° per Template:Control instead of 45°, but a comparator still outputs power levels 1 through 8. It takes two full rotations to cycle through all comparator outputs, and each orientation of the map corresponds to two output levels that differ by 4.
- The item frame must be attached to a full block, and the comparator must be placed behind this block, facing away from the item frame.
- If the item frame occupies the same space as another block that the comparator can measure,Template:Only such as a chest, lectern, brewing stand, detector rail, decorative pot, copper golem statue, or cake, the comparator behind the item frame outputs whichever signal is stronger.
- Template:BlockLink
- A jukebox outputs a signal strength indicating which music disc is currently playing. See the Minimum Items for Container Signal Strength table above.
- Template:BlockLink
- A lectern outputs a signal strength that depends on which page of the lectern's book is opened. The calculation used is:
- Template:Math
- This results in page 1 having a signal strength of 1, and the last page having a signal strength of 15. The exception is a single page book, which outputs a signal strength of 15.
- For example, a book with 15 pages outputs a signal equal to the current page number. A book with 5 pages outputs signal strengths of 1, 4, 8, 11 and 15 for the different pages. A book with 100 pages has the signal strength increase to the next level on pages 1, 9, 16, 23, 30, 37, 44, 51, 58, 65, 72, 79, 86, 93 and 100.
- Template:BlockLink
- A respawn anchor outputs a signal strength of 0, 3, 7, 11, or 15, depending on the "charged" value.
- Template:BlockLink
- A sculk sensor outputs a signal strength depending on the type of vibration that is detected.
- Template:BlockLink
- A shelf outputs a signal strength of 1, 2, or 4 if an item is in the left, middle, or right slot respectively. Shelves with items in multiple slots sum the signal strengths, up to a total of 7.
Sounds
Generic
Template:Edition: Template:Sound table/Block/Stone/JE Template:Edition: Template:Sound table/Block/Comparator/BE
Unique
Data values
ID
Template:Edition: Template:ID table Template:ID table
Template:Edition: Template:ID table Template:ID table Template:ID table Template:ID table
Block states
Template:El: Template:Bst Template:Bst Template:Bst
Template:El: Template:Bst Template:Bst Template:Bst
Block data
A redstone comparator has a block entity associated with it that holds additional data about the block.
Template:El: Template:See also
<section begin="block data" />
- Template:Nbt Block entity data
- Template:Nbt inherit/blockentity
- Template:Nbt: Represents the strength of the analog signal output of this redstone comparator.
<section end="block data" />
Advancements
Videos
History
Template:More sounds Template:See asset history Template:See technical block
Development
Java Edition
Bedrock Edition
Legacy Console Edition
New Nintendo 3DS Edition
Data history
Java Edition
Bedrock Edition
Issues
Trivia
- Comparators do not emit redstone particles when powered, unlike redstone torches and repeaters.<ref>Template:Bug</ref>
Gallery
Screenshots
-
Dinnerbone showing how comparators work.
-
Dinnerbone showing how comparators work.
-
Dinnerbone showing how comparators work.
-
A contraption incorporating comparators.
-
Comparators in action.
-
Output specific signals.
-
Another comparator in use.
-
Rotating the torch in the item frame adjusts the comparator's output.
References
Template:Navbox redstone Template:Navbox blocks
Minecraft:de:Redstone-Komparator Minecraft:es:Comparador de redstone Minecraft:fr:Comparateur de redstone Minecraft:hu:Redstone-komparátor Minecraft:it:Comparatore di redstone Minecraft:ja:レッドストーンコンパレーター Minecraft:ko:레드스톤 비교기 Minecraft:nl:Redstonevergelijker Minecraft:pl:Komparator redstone Minecraft:pt:Comparador de Redstone Minecraft:ru:Редстоуновый компаратор Minecraft:uk:Редстоуновий компаратор Minecraft:zh:红石比较器