Hi Gamepedia users and contributors! Please complete this survey to help us learn how to better meet your needs in the future. We have one for editors and readers. This should only take about 7 minutes!

Redstone Comparator

From Minecraft Wiki
Jump to: navigation, search
Redstone Comparator
Redstone Comparator.pngSubtracting Redstone Comparator.png
Active Redstone Comparator.pngActive Subtracting Redstone Comparator.png
Transparent

Yes

Luminance

No

Blast resistance

0

Hardness

0

Tool

Any tool

Renewable

No

Stackable

Yes (64)

Flammable

No

Catches fire from lava

No

Drops
Block entity ID

See § Data values

Data values

See § Data values

Namespaced ID

See § Data values

A redstone comparator is a block used in redstone circuits to maintain, compare, or subtract signal strength, or to measure certain block states (primarily the fullness of containers).

Obtaining[edit]

To remove a redstone comparator, mine it. A redstone comparator can be broken instantly with anything, and drops itself as an item.

A redstone comparator is removed and drops itself as an item if:

  • its attachment block is moved, removed, or destroyed.
  • water flows into its space.‌[Java Edition only]
  • a piston tries to push it or moves a block into its space.

If lava flows into a redstone comparator's space, the redstone comparator is destroyed without dropping itself as an item.

Crafting[edit]

Ingredients Crafting recipe Description
Redstone Torch +
Nether Quartz +
Stone

Can use stone and its variants interchangeably.‌[LCE only]

Usage[edit]

A redstone comparator can be placed on the top of any opaque block with a solid full-height top surface (including upside-down slabs and upside-down stairs). In Bedrock Edition, a comparator can also be placed on walls and fences. For more information about placement on transparent blocks, see Opacity/Placement. To place a redstone comparator, use the Place Block control.

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 with the Use Item control:

  • 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 redstone dust, redstone blocks, redstone repeaters, and other comparators. The redstone comparator's front is its output.

It takes 1 redstone tick (2 game ticks, or 0.1 seconds barring lag) 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 usually do not respond 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.

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[edit]

A redstone comparator with no powered sides outputs the same signal strength as its rear input.

Compare signal strength[edit]

Comparators in comparison mode.

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.

in summary : Output = Rear × (Left < Rear AND Right < Rear)

Subtract signal strength[edit]

A redstone comparator in subtraction mode (front torch up and powered) subtracts the signal strength of the highest side input from the signal strength of the rear input.

in summary : Output = Rear - max(Left,Right)

For example, if Signal of the left is 6, the right is 7 and the rear is 4 then the result should be : 4 - max(6,7) = 4-7 = 0

If the signal of the rear is 9, the right is 2 and the left is 5 then the result should be : 9 - max(2,5) = 9-5 = 4

Measure block state[edit]

A redstone comparator can measure the fullness of a chest, as well as other block states, even through a block.

A redstone comparator treats certain blocks behind it as power sources and output a signal strength proportional to the block's state. The comparator may be separated from the measured block by a solid block. However, in Java Edition, if the solid block is powered to signal strength 15, then the comparator outputs 15 no matter the fullness of the container.[1]

Containers[edit]

Minimum Items for Container Signal Strength
Power
Level
Containers and Number of Slots








3 5 9 27 54
0 0i 0i 0i 0i 0i No music disc inserted
1 1i 1i 1i 1i 1i "13"
2 14i 23i 42i 1s
60i
3s
55i
"cat"
3 28i 46i 1s
19i
3s
55i
7s
46i
"blocks"
4 42i 1s
5i
1s
60i
5s
51i
11s
37i
"chirp"
5 55i 1s
28i
2s
37i
7s
46i
15s
28i
"far"
6 1s
5i
1s
51i
3s
14i
9s
42i
19s
19i
"mall"
7 1s
19i
2s
10i
3s
55i
11s
37i
23s
10i
"melohi"
8 1s
32i
2s
32i
4s
32i
13s
32i
27s "stal"
9 1s
46i
2s
55i
5s
10i
15s
28i
30s
55i
"strad"
10 1s
60i
3s
14i
5s
51i
17s
23i
34s
46i
"ward"
11 2s
10i
3s
37i
6s
28i
19s
19i
38s
37i
"11"
12 2s
23i
3s
60i
7s
5i
21s
14i
42s
28i
"wait"
13 2s
37i
4s
19i
7s
46i
23s
10i
46s
19i
14 2s
51i
4s
42i
8s
23i
25s
5i
50s
10i
15 3s 5s 9s 27s 54s

A redstone comparator used to measure the state of a container outputs a signal strength in proportion to how full the container is (0 for empty, 15 for full, etc.).

Containers that can be measured by a comparator include:

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).

The Minimum Items for Container Signal Strength table (right) shows the minimum number of 64-stackable items required to produce the different signal strengths from each type of container. Numbers followed by an "s" or "i" indicate the number of full 64-stack equivalents ("s"), and additional items less than a stack ("i") required. For items that stack in 16s (snowballs, signs, ender pearls, etc.), divide the "i" number by 4 and round up. Each non-stackable item counts as one full-stack.

For example, to produce a signal strength of 10 from a hopper requires the equivalent of 3 full stacks plus 14 more items, or 206 items total, assuming they all stack in 64.

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. A chest or trapped chest that cannot be opened (either because it has an opaque block or ocelot 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:
signal strength = floor(1 + ((sum of all slots' fullnesses) / (number of slots in container)) * 14)
fullness of a slot = (number of items in slot) / (max stack size for this type of item)
Example: 300 blocks in a dispenser (which has 9 slots), where each block stacks to a maximum of 64, produces output with a signal strength of 8:

1 + ((300 items / 64 items per slot) / 9 slots) * 14 = 8.292, floored is 8

Note that a non-stackable item is counted as a full slot (1 item in a slot, with a max stack size of 1: 1 / 1 = 1.0), and items that stack up to 16 (such as ender pearls and snowballs and eggs) are similarly considered a full slot at 16.
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:
items required = max(desired signal strength, roundup((total slots in container * 64 / 14) * (desired signal strength - 1) ) )
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[edit]

Comparators used to measure containers.

Some non-container blocks can also be measured by a redstone comparator:

Cake
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.
Cauldron signal strength
Cauldron
A cauldron outputs different signal strengths depending on how much water is inside. From completely empty to completely full, the output values are 0, 1, 2, and 3.
Composter signal strength
Composter
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.
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 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).
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).
End Portal Frame
An end portal frame outputs a full signal of 15 if it contains an eye of ender and zero otherwise.
A comparator can measure the presence and rotation of an item frame's contents.
Item Frame
A comparator can measure the state of an 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.
The comparator must be placed behind the block the item frame is attached to, facing away from the item frame. The block must be a full block, and the item frame cannot be submerged in water.
Jukebox
A jukebox outputs a signal strength indicating which music disc is currently playing. See the Minimum Items for Container Signal Strength table above.
Lectern
A lectern outputs a signal strength that depends on what page the player is currently on. (e.g. a book with 15 pages powers 1 redstone level per page, or one with 5 pages emits 3 signal strength per page.)
Beehive and Bee nest[upcoming: JE 1.15]
A hive outputs a signal strength equal to the amount of honey in the hive.

Sounds[edit]

Sound Subtitle Namespaced ID Subtitle ID Source Pitch Volume Attenuation distance
Block breaking block.wood.hit subtitles.block.generic.hit Blocks 0.5 0.25 16
Block broken block.wood.break subtitles.block.generic.break Blocks 0.8 1.0 16
Block placed block.wood.place subtitles.block.generic.place Blocks 0.8 1.0 16
Footsteps block.wood.step subtitles.block.generic.footsteps Blocks 1.0 0.15 16
No subtitle block.wood.fall (Plays when fallen on from a height) Blocks 0.75 0.5 16
Comparator clicks block.comparator.click subtitles.block.comparator.click ? (<1.0) ? 16

Data values[edit]

A redstone comparator is defined by its ID, block data, and block entity. A redstone comparator also has a block state that is expected to replace the functionality of block data in a future version.

ID[edit]

Java Edition:

Redstone Comparator Namespaced ID
Redstone Comparator comparator
Block entity

Bedrock Edition:

Redstone Comparator Namespaced ID Numeric ID
Block (inactive) unpowered_comparator 149
Block (active) powered_comparator 150
Item comparator 404
Block entity Comparator -

Block data[edit]

In Bedrock Edition, redstone comparators use the following data values: A redstone comparator's block data specifies its orientation, mode, and powered status.

Bits Values
0x1
0x2
A two-bit field storing a value from 0 to 3 specifying the redstone comparator's orientation:
  • 0: Facing north.
  • 1: Facing east.
  • 2: Facing south.
  • 3: Facing west.
0x4 Set if in subtraction mode (front torch up and powered).
0x8 Set if powered (at any power level).

Block states[edit]

Java Edition:

Name Default value Allowed values Description
facingnortheast
north
south
west
The direction from the output side to the input side of the comparator,
or the opposite from the direction the player faces while placing the comparator.
modecomparecompare
subtract
Specifies the current mode of the redstone comparator.
poweredfalsefalse
true
True if the redstone comparator is being powered.

Block entity[edit]

A redstone comparator has a block entity associated with it that holds additional data about the block.

Video[edit]


Painting.png
This page would benefit from the addition of more images.
Please remove this notice once you've added suitable images to the article. The specific instructions are: The redstone comparator item before (and after) the Texture Update.

History[edit]

Java Edition
November 24, 2012Jeb stated that there may be a "capacitor" in Minecraft.
December 27, 2012Dinnerbone released pictures of the first version of the "comparator", stating it was a replacement for the "capacitor" idea that has variable, alternate inputs.
January 2, 2013Dinnerbone released one more picture of the comparator. The picture itself showing a digital-to-analog converter, using the comparator as the main block.
1.513w01aRedstone Comparator Revision 1.pngActive Redstone Comparator Revision 1.pngSubtracting Redstone Comparator Revision 1.pngActive Subtracting Redstone Comparator Revision 1.png Added redstone comparator, with 0 delay.
13w01bAdded delay of 1 game tick (12 redstone tick) to comparator to fix bugs.
Added ability to measure containers to redstone comparator.
13w02aRedstone Comparator Revision 2.pngActive Redstone Comparator Revision 2.pngSubtracting Redstone Comparator Revision 2.pngActive Subtracting Redstone Comparator Revision 2.png Updated texture to show quartz in the middle.
Changed algorithm for measuring containers so that comparators output a signal with as few as 1 item in the container.
13w02bComparators now treat large chests as a single container.
13w03aComparators now output success count of command blocks.
Comparators now measure container minecarts on detector rails.
13w04aComparators now measure jukeboxes.
13w05aComparators no longer cause constant block updates, the delay is made consistent, and side input no longer causes a pulse output.
Block 150 (powered_comparator) is no longer used; powered state is now represented by the 8s bit on block 149 (unpowered_comparator).
13w05bComparator delay changed from 1 game tick (1/2 redstone tick) to 2 game ticks (1 redstone tick).
13w09cThe redstone signal strength from a comparator next to a brewing stand with 3 water bottles in it is the same as one with 3 water bottles and 1 ingredient in it.
1.6.113w18aComparators now measure cauldrons and end portal frames.
1.7.213w37aThe item forms of blocks 149 (unpowered_comparator) and 150 (powered_comparator) were removed from the game. They can no longer exist in inventories, only as blocks in the world.
1.814w04aComparators now measure item frames.
14w28aComparators now measure cakes.
1.915w42aWith the addition of the blaze powder fuel slot, brewing stands now have 5 slots instead of 4. Their original comparative power values are listed below:
15w47aComparators' side inputs now take power from redstone blocks.
1.1317w47aAll 3 IDs for the redstone comparator got merged into one ID: comparator.
Comparators now render the underside.
Prior to The Flattening, these blocks' numeral IDs were 149 and 150, and the item's 404.
1.1418w43aRedstone Comparator.pngActive Redstone Comparator.pngSubtracting Redstone Comparator.pngActive Subtracting Redstone Comparator.png Changed the texture of comparators.
19w02aComparators now measure lecterns.
19w03aComparators now measure composters.
Upcoming Java Edition
1.1519w34aComparators now measure how much honey is inside bee hives and bee nests.
Pocket Edition Alpha
0.14.0build 1Added redstone comparators.
Pocket Edition
1.0.0alpha 0.17.0.1Comparator now measure end portal frames.
1.0.5alpha 1.0.5.0Comparator now output success count of command blocks.
1.1.0alpha 1.1.0.0Comparator now measure shulker box.
Bedrock Edition
1.2.0beta 1.2.0.2Comparator now measure jukebox.
1.11.0beta 1.11.0.1Comparator now measure smoker, blast furnace, lectern, and composter.
Legacy Console Edition
TU19CU71.12Patch 1Added redstone comparators.
TU31CU191.22Patch 3Can now measure item frames.
New Nintendo 3DS Edition
0.1.0 Added redstone comparators.

Issues[edit]

Issues relating to "Redstone Comparator" are maintained on the bug tracker. Report issues there.

Trivia[edit]

  • Comparators have no bottom texture; they appear transparent when viewed from below.‌[Bedrock Edition only]

References[edit]