Namespaces

Variants

Share

Share
Views
Actions

Redstone Comparator

From Minecraft Wiki
Jump to: navigation, search
[edit]Redstone Comparator
Redstone Comparator (Inactive).gif
Redstone Comparator (Active).gif
Redstone Comparator
Type

Solid block

Requirements

None

Physics

No

Transparency

Yes

Luminance

No

Blast resistance

0

Hardness

0

Tool

Any tool

Renewable

No

Stackable

Yes (64)

Flammable

No

First appearance

1.5 (13w01a)

Drops

Itself

Data values
Block
dec: 149 hex: 95 bin: 10010101
Item
dec: 404 hex: 194 bin: 110010100
Name
Block
unpowered_comparator
Item
comparator

The Redstone Comparator is a block for use with redstone circuitry. It resembles a repeater with an additional redstone torch. It has two inputs: one from the back, signal A; and one from the side, signal B. The output, the single torch in front, has different behavior depending on the mode of operation: subtraction, which occurs when the torch is lit, and comparison, which occurs when the torch is dark. Right clicking the comparator will change modes.

In subtraction mode, when signal A exceeds signal B, it outputs proportionally to (A-B). Example: the back has a strength of 15, the side a strength of 1, and the output is 14.

In comparison mode, when signal A exceeds or equals signal B, it outputs signal A. Example: the back has a strength of 15, the side a strength of 1, and the output is 15. Compare Bipolar Junction Transistor (electronics).

If the rear of the comparator (the side with two redstone torches) touches a storage block, then the output is a signal that is proportional to the fullness the storage block is full (see below).

Unlike the repeater, the comparator hasn't two separated blocks for the active and inactive states. Data values from 0 to 7 correspond to the inactive state, those from 8 to 15 correspond to the active state (the block ID 150, even if it has the comparator's texture, is not used by the game and does not transmit redstone signals).

Contents

[edit] Crafting

Ingredients Crafting recipe

Redstone Torch +
Nether Quartz +
Stone


Redstone Torch
Grid layout Arrow (small).png Redstone Comparator
Redstone Torch Nether Quartz Redstone Torch
Stone Stone Stone

[edit] Uses

[edit] As a low-delay wire/diode

Like a repeater, the comparator acts as a diode. Its delay is one tick. However, unlike a repeater, it will not create an output for a 1-tick pulse.

[edit] As a comparator

The side inputs can set a threshold for the input signal. Signal A inputs to the back of the comparator and will only output while exceeding or equaling signal B. Signal B is considered the greater of the two side inputs; the weaker side input is ignored. In this mode, the comparator resembles a real-life op-amp without a feedback circuit, with signal A to its non-inverting input and signal B to its inverting input.

[edit] As a diminisher

If a comparator is right-clicked, then its third redstone torch activates. In this state, the output will be signal A minus signal B: the input signal will decrease by the comparison signal. If signal B exceeds or equals signal A, then no output will occur.

[edit] As a damper signal

If 2 or more comparators are placed in a loop with at least two redstone connecting them, then the signal will weaken by 1 with each cycle until entirely dying.

[edit] As a sustainer

Use the output of a damper, or feed it to a repeater to boost signal, and you get a long period sustainer. Add more comparators to loop to make a longer period sustainer.

[edit] As a clock

Whenever Signal A is connected with full strength and the output is forwarded to signal B and the comparator toggle is set to on, the device will act as a 1-clock.

[edit] As a pseudo-random selector

Wire two or more redstone repeaters in a ring to make a clock, then wire each redstone wire to a comparator side input. Wire a switch to each comparator's back input so the wire from the switch is longer. The clock toggles round the repeaters and the switch activates one of the comparator outputs when activated. If the mechanism cannot be seen, it is effectively random.

[edit] As an inventory contents checker

If a comparator is placed next to a container, it will provide an output based on the percentage of used space in the container. This includes: regular/large/trapped Chest, Furnace, Dispenser, Hopper, Brewing Stand, Dropper, Jukebox, End Portal Frame, Cauldron, Item Frame(Upcoming), or a Detector Rail with a Minecart with Chest / Hopper on it. The comparator may be separated from the input by one solid block if the 3 blocks form a line, however redstone current from below the separator may interfere. See below for more info.

[edit] Inventory checking output

When a container is empty, the output is off.

When it is not empty, the output signal strength is calculated as follows:

signal strength = truncate(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, truncated 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 which stack up to 16 (such as ender pearls and snowballs and eggs) are similarly considered a full slot at 16.

[edit] Specific output signal strength creation

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, you need 110 items:

max(9, (3*64/14)*(9-1)) = 109.714, rounded up is 110

[edit] Power listings of a furnace

This table shows the number of full slots(e.g. non-stackables like shovels,...) and blocks/items(stackable to 64) needed to get a specific output strength when using a furnace. Minimum and maximum needed items are shown. The optimal column tries to round to the nearest number of full slots between the minimum and maximum, if that isn't possible it optimizes by splitting 64-stacks in half and so on. Basically it's easier to count and needs less clicks to get a number of blocks/items in the furnace.

Signal strength At least At most Optimal
Full slots Blocks/Items Full slots Blocks/Items Full slots Blocks/Items
1 0 1 0 13 0 8
2 0 14 0 27 0 16
3 0 28 0 41 0 32
4 0 42 0 54 0 48
5 0 55 1 4 1 0
6 1 5 1 18 1 16
7 1 19 1 31 1 24
8 1 32 1 45 1 40
9 1 46 1 59 1 48
10 1 60 2 9 2 0
11* 2 10 2 22 2 16
12* 2 23 2 36 2 32
13* 2 37 2 50 2 48
14* 2 51 2 63 2 56
15* 3 0 3 0 3 0

*Note that you have to smelt things to get items into the third slot, therefore using chests may be a better option if you want signal strength 11 or higher.

[edit] Power listings of a hopper

Signal strength At least Optimal
Full slots Blocks/Items Full slots Blocks/Items
1 0 1 0 16
2 0 23 0 32
3 0 46 1 0
4 1 5 1 16
5 1 28 1 32
6 1 51 2 0
7 2 10 2 16
8 2 32 2 32
9 2 55 3 0
10 3 14 3 32
11 3 37 3 48
12 3 60 4 0
13 4 19 4 32
14 4 42 4 48
15 5 0 5 0

[edit] Power listings of a single chest

This table shows the number of full slots(e.g. non-stackables like shovels,...) and blocks/items(stackable to 64) needed to get a specific output strength when using a single chest. Minimum and maximum needed items are shown. The optimal column tries to round to the nearest number of full slots between the minimum and maximum.

Signal strength At least At most Optimal
Full slots Blocks/Items Full slots Blocks/Items Full slots
1 0 1 1 59 1
2 1 60 3 54 2
3 3 55 5 50 4
4 5 51 7 45 6
5 7 46 9 41 8
6 9 42 11 36 10
7 11 37 13 31 12
8 13 32 15 27 14
9 15 28 17 22 16
10 17 23 19 18 18
11 19 19 21 13 20
12 21 14 23 9 22
13 23 10 25 4 24
14 25 5 26 63 26
15 27 0 27 0 27

By using the /give command, it is possible to get a stack that has more than the normal maximum for an item. For example, beds normally do not stack, however you can use /give <Player> bed 27 to get a stack of 27 beds. If you put the resulting stack of 27 beds in a chest, it will then output a signal strength of 15. Using this technique, and increasing the number to greater than 27, you can create chests (and other containers) which are more than 100% full. While you cannot store a signal with strength larger than 15 in redstone wire, redstone comparators can internally have a strength of more than 15. This internal strength can then be subtracted to reach signal strengths that wire can carry. For example, if you put 29 beds in a chest, set a comparator examining the chest to subtraction mode, and subtract a signal of maximum strength (15), the comparator will output a signal strength of 1.

Signal strength At least At most Optimal
Full slots Blocks/Items Full slots Blocks/Items Full slots
16*  ?  ?  ?  ? 29
17*  ?  ?  ?  ? 31
18*  ?  ?  ?  ? 33
19*  ?  ?  ?  ? 35
20*  ?  ?  ?  ? 37
21*  ?  ?  ?  ? 39
n (n>1)  ?  ?  ?  ? n*2-2-n/15

(round up)

897*  ?  ?  ?  ? 1728 (max)

[edit] Jukebox record identification

Unlike most containers, the signal output by a jukebox represents the record it contains. It outputs:

Signal Record
0 none
1 13
2 cat
3 blocks
4 chirp
5 far
6 mall
7 mellohi
8 stal
9 strad
10 ward
11 11
12 wait
13 unused
14 unused
15 unused

[edit] Other unique block outputs

End Portal Frame blocks output a full signal of 15 if they contain an Eye of Ender and zero otherwise.

Cauldrons output 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.

Item Frames (Upcoming) output different signal strengths depending on how many times it has been turned. 0 for an empty item frame, one for an item, plus one signal strength per turn, resets to one after eight turns.

[edit] Command block output

Command Blocks output a property called "Success Count", 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, 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 (of course, this is capped at a full signal of 15, so it will output 15 if there were 15 or more successes). Examples of such commands are /tell and /testfor. Note that /say will never output more than 1, as the command only outputs one message in chat regardless of the number of players who are referenced (their names are merely formatted as a list of the form "name1, name2, and name3").

Note that the comparator will output the Command Block's success count for the last command executed: it will be a constant signal (or lack thereof) and will only update when the command is next executed. Unfortunately many commands fail to pass on a failure, meaning once the redstone comparator is lit it will be permanently lit. The blockdata command can be used to reset such a "problem circuit".

[edit] Video

[edit] History

Official release
24 November 2012 Jeb stated that there may be a ‘Capacitor’ in Minecraft
27 December 2012
Dinnerbone released pictures of the first version of the 'Comparator,' stating it was a replacement for the 'Capacitor' idea which has variable, alternate inputs.
2 January 2013
Dinnerbone released one more picture of the Comparator. The picture itself showing a digital-to-analogue converter, using the comparator as the main block.
1.5 13w01a Added redstone comparator, with 0 delay.
13w01b Added delay of 1 game tick (1/2 redstone tick) to fix bugs.
All containers output a redstone signal when a Comparator is placed against it directly. The strength of it depends on how full the container is. This works with Trapped Chests as well, meaning it can provide two redstone signals with different causes at the same time.
13w02a Updated texture to show quartz in the middle.
When fed by containers, they will now start giving out a signal as soon as 1 item is in the container, allowing for empty container detection.
13w02b Large/double chests can now release a redstone signal when connected to a Comparator depending on the amount of stacks within. Before, double chests would only emit a signal depending on how full each individual chest was (a double chest with only the the top half full would emit a full signal from the side that the items were in).
13w03a Comparators fed by command blocks will now indicate whether the last run command was run successfully
Comparators can be used to get an analog redstone signal indicating the amount of found players by using the new /testfor command.
Comparators powered by detector rails now give out a signal depending on the fullness of the container on the rail.
13w04a Comparators can now be used with jukeboxes - the output signal strength relates to disk number.
13w05a Comparators no longer cause constant block updates, the delay is made consistent, and side input no longer causes a pulse output.
13w05b Comparator delay changed from 1 game tick (1/2 redstone tick) to 2 game ticks (1 redstone tick).
13w09c The 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.1 13w18a Comparators now give out a signal for Cauldrons and End Portal frames depending on their state.
Upcoming
1.8 14w04a Comparators now give out a signal for Item Frames based on item orientation.

[edit] Issues

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

[edit] Trivia

  • The comparator does not re-strengthen a redstone signal. This means it can not be used for super-long instant circuits.
  • If placed every second block between redstone, they can endlessly carry a signal, at same speed than repeaters on first setting, without it losing power strength. Placing a non-transparent block at every corner allows it to bend without losing power. It is also possible to reduce the needed amount of comparators further (and thus improve the signal speed) by facing the comparators into solid blocks behind which redstone is placed
  • A redstone comparator outputs a strong signal. This does not mean it resets the signal strength like repeaters, but it means the signal can be picked up through a block without using a repeater (Like a repeater)
  • If you join up the redstone torches, an arrow is created which points to the redstone output. This arrow can also be seen as a red triangle on the Comparator, if one looks hard enough.
  • If placed on a Barrier, you can see the bottoms of the torches
  • An empty Minecart, an empty Minecart with Chest and a Minecart with a mob in it will all give no redstone output when passing over a Detector Rail with a comparator next to it

[edit] Gallery