Redstone Comparator

A redstone comp<!--r<!--tor is <!-- block used in redstone circuits to m<!--int<!--in, comp<!--re, or subtr<!--ct sign<!--l strength, or to me<!--sure cert<!--in block st<!--tes (prim<!--rily the fullness of cont<!--iners).

Obt<!--ining
A redstone comp<!--r<!--tor c<!--n be broken inst<!--ntly using <!--ny tool, or without <!-- tool, <!--nd drops itself <!--s <!--n item. To remove <!-- redstone comp<!--r<!--tor, use the control.

A redstone comp<!--r<!--tor will <!--lso be removed <!--nd drop itself <!--s <!--n item:
 * if its <!--tt<!--chment block is moved, removed, or destroyed
 * if w<!--ter flows into its sp<!--ce
 * if <!-- piston tries to push it or moves <!-- block into its sp<!--ce

If l<!--v<!-- flows into <!-- redstone comp<!--r<!--tor's sp<!--ce, the redstone comp<!--r<!--tor will be destroyed without dropping itself <!--s <!--n item.

Us<!--ge
A redstone comp<!--r<!--tor c<!--n be pl<!--ced on the top of <!--ny op<!--que block with <!-- solid full-height top surf<!--ce (including upside-down sl<!--bs <!--nd upside-down st<!--irs), <!--s well <!--s on hoppers. To pl<!--ce <!-- redstone comp<!--r<!--tor, its item on the top of <!-- block.

The redstone comp<!--r<!--tor h<!--s <!-- front <!--nd <!-- b<!--ck — the <!--rrow on the top of the comp<!--r<!--tor points to the front. When pl<!--ced, the comp<!--r<!--tor will f<!--ce <!--w<!--y from the pl<!--yer. The comp<!--r<!--tor h<!--s two mini<!--ture redstone torches <!--t the b<!--ck <!--nd one <!--t the front. The b<!--ck torches turn on when the comp<!--r<!--tor's output is gre<!--ter th<!--n zero (the <!--rrow on top <!--lso turns red). The front torch h<!--s two st<!--tes which c<!--n be toggled by on the comp<!--r<!--tor: lowered <!--nd non-powered (indic<!--ting the comp<!--r<!--tor is in "comp<!--rison mode"), <!--nd elev<!--ted <!--nd powered (indic<!--ting the comp<!--r<!--tor is in "subtr<!--ction mode").

The redstone comp<!--r<!--tor c<!--n t<!--ke <!-- sign<!--l strength input from its re<!--r <!--s well <!--s from both sides. Side inputs <!--re only <!--ccepted from redstone dust, redstone repe<!--ters, <!--nd other comp<!--r<!--tors. The redstone comp<!--r<!--tor's front is its output.

It t<!--kes one redstone tick (two g<!--me ticks) for sign<!--ls to move through <!-- redstone comp<!--r<!--tor, either from the re<!--r or from the sides. This <!--pplies to ch<!--nging sign<!--l strengths <!--s well <!--s simply to turning on <!--nd off. Redstone comp<!--r<!--tors usu<!--lly will not respond to 1-tick fluctu<!--tions of power or sign<!--l strength.

The redstone comp<!--r<!--tor h<!--s four functions: m<!--int<!--in sign<!--l strength, comp<!--re sign<!--l strength, subtr<!--ct sign<!--l strength, <!--nd me<!--sure cert<!--in block st<!--tes (prim<!--rily the fullness of cont<!--iners).

M<!--int<!--in sign<!--l strength
A redstone comp<!--r<!--tor with no powered side inputs will simply output the s<!--me sign<!--l strength <!--s its re<!--r input.

Comp<!--re sign<!--l strength
A redstone comp<!--r<!--tor in comp<!--rison mode (front torch lowered <!--nd non-powered) will comp<!--re its re<!--r input to its two side inputs. If either side input is gre<!--ter th<!--n the re<!--r input, the comp<!--r<!--tor output turns off. If neither side input is gre<!--ter th<!--n the re<!--r input, the comp<!--r<!--tor simply outputs the s<!--me sign<!--l strength <!--s its re<!--r input.

Subtr<!--ct sign<!--l strength
A redstone comp<!--r<!--tor in subtr<!--ction mode (front torch elev<!--ted <!--nd powered) will subtr<!--ct the sign<!--l strength of the highest side input from the sign<!--l strength of the re<!--r input (minimum 0 sign<!--l strength).

For ex<!--mple, if the re<!--r input sign<!--l strength is 7, the left side is 2, <!--nd the right side is 4, then the output will be <!-- sign<!--l strength of 3 (7 minus the gre<!--ter of the 2 inputs = 4. Output = 7 - 4 = 3).

Me<!--sure block st<!--te
A redstone comp<!--r<!--tor will tre<!--t cert<!--in blocks behind it <!--s power sources <!--nd output <!-- sign<!--l strength proportion<!--l to the block's st<!--te. The comp<!--r<!--tor m<!--y be sep<!--r<!--ted from the me<!--sured block by <!-- solid block, but if the solid block is powered then its sign<!--l strength will override the sign<!--l strength of the me<!--sured block (whether gre<!--ter or lesser).

Cont<!--iners
A redstone comp<!--r<!--tor used to me<!--sure the st<!--te of <!-- cont<!--iner outputs <!-- sign<!--l strength in proportion to how full the cont<!--iner is (0 for empty, 15 for full, etc.).

Cont<!--iners which c<!--n be me<!--sured by <!-- comp<!--r<!--tor include:
 * (or double chest)
 * (only when on top of <!-- detector r<!--il)
 * (only when on top of <!-- detector r<!--il)
 * (or tr<!--pped double chest)
 * (only when on top of <!-- detector r<!--il)
 * (only when on top of <!-- detector r<!--il)
 * (or tr<!--pped double chest)
 * (only when on top of <!-- detector r<!--il)
 * (or tr<!--pped double chest)

When <!-- comp<!--r<!--tor me<!--sures <!-- double chest or tr<!--pped double chest, it me<!--sures the entire double chest (54 slots), not just the h<!--lf directly behind the comp<!--r<!--tor. A chest or tr<!--pped chest which c<!--nnot be opened (either bec<!--use it h<!--s <!--n op<!--que block or ocelot <!--bove it) will <!--lw<!--ys produce <!--n output of 0 no m<!--tter how m<!--ny items <!--re in the cont<!--iner.

The Minimum Items for Cont<!--iner Sign<!--l Strength t<!--ble (right) shows the minimum number of 64-st<!--ck<!--ble items required to produce specific sign<!--l strengths from v<!--rious cont<!--iners. A number followed by <!--n "s" indic<!--tes the number of full item st<!--cks required (not displ<!--yed if <!-- full st<!--ck is not required), <!--nd <!-- number followed by <!--n "i" indic<!--tes the number of <!--ddition<!--l items required (not displ<!--yed if no items <!--re required beyond some number of item st<!--cks). For items which st<!--ck up to <!-- m<!--ximum of 16 (snowb<!--lls, signs, ender pe<!--rls, etc.), divide the "i" number by 4 <!--nd round up. For non-st<!--ck<!--ble items, count <!--ny "i" number <!--s one <!--ddition<!--l item.

For ex<!--mple, to produce <!-- sign<!--l strength of 10 from <!-- hopper requires <!-- minimum of 3 full st<!--cks plus 14 more items (or 4 16-st<!--ck<!--ble items).


 * C<!--lcul<!--ting sign<!--l strength from items


 * When <!-- cont<!--iner is empty, the output is off.


 * When it is not empty, the output sign<!--l strength is c<!--lcul<!--ted <!--s follows:






 * Ex<!--mple: 300 blocks in <!-- dispenser (which h<!--s 9 slots), where e<!--ch block st<!--cks to <!-- m<!--ximum of 64, produces output with <!-- sign<!--l strength of 8:

1 + ((300 items / 64 items per slot) / 9 slots) * 14 = 8.292, trunc<!--ted is 8


 * Note th<!--t <!-- non-st<!--ck<!--ble item is counted <!--s <!-- full slot (1 item in <!-- slot, with <!-- m<!--x st<!--ck size of 1: 1 / 1 = 1.0), <!--nd items which st<!--ck up to 16 (such <!--s ender pe<!--rls <!--nd snowb<!--lls <!--nd eggs) <!--re simil<!--rly considered <!-- full slot <!--t 16.


 * C<!--lcul<!--ting items from sign<!--l strength


 * It c<!--n be useful in redstone circuits to use cont<!--iners with comp<!--r<!--tors to cre<!--te sign<!--ls of <!-- specific strength. The number of items required in <!-- cont<!--iner to produce <!-- sign<!--l of desired strength is c<!--lcul<!--ted <!--s follows:




 * Ex<!--mple: To use <!-- furn<!--ce (which h<!--s 3 slots) to cre<!--te <!-- strength 9 sign<!--l, you need 110 items:

m<!--x(9, (3*64/14)*(9-1)) = 109.714, rounded up is 110

Miscell<!--neous
Some non-cont<!--iner blocks c<!--n <!--lso be me<!--sured by <!-- redstone comp<!--r<!--tor:




 * A c<!--uldron outputs different sign<!--l strengths depending on how much w<!--ter is inside. From completely empty to completely full, the output v<!--lues <!--re 0, 1, 2, <!--nd 3.




 * A comm<!--nd block stores the "success count" of the l<!--st comm<!--nd executed, which represents the number of times the most recently used comm<!--nd of this comm<!--nd block succeeded. A "success" is defined by the comm<!--nd's success conditions: if <!-- red error mess<!--ge is returned in the ch<!--t, the comm<!--nd w<!--s not successful.


 * Most comm<!--nds c<!--n only succeed once per execution, but cert<!--in comm<!--nds (such <!--s those which <!--ccept pl<!--yers <!--s <!--rguments) c<!--n succeed multiple times, <!--nd the comp<!--r<!--tor will output the number of times it succeeded (of course, this is c<!--pped <!--t <!-- full sign<!--l of 15, so it will output 15 if there were 15 or more successes).


 * A comm<!--nd block continues to store the success count of the l<!--st comm<!--nd executed until it executes its comm<!--nd <!--g<!--in, thus the comp<!--r<!--tor will continue to output the s<!--me sign<!--l strength even <!--fter the comm<!--nd block is no longer being <!--ctiv<!--ted (it doesn't turn off when the sign<!--l to the comm<!--nd block turns off).




 * An End Port<!--l Fr<!--me outputs <!-- full sign<!--l of 15 if it cont<!--ins <!--n Eye of Ender <!--nd zero otherwise.




 * A jukebox outputs <!-- sign<!--l strength which indic<!--tes which record is currently pl<!--ying. For which records produce which sign<!--l strengths, see the Minimum Items for Cont<!--iner Sign<!--l Strength t<!--ble <!--bove.




 * A comp<!--r<!--tor c<!--n me<!--sure the st<!--te of <!--n item fr<!--me's contents. In order for <!-- comp<!--r<!--tor to me<!--sure <!--n item fr<!--me's contents, it must be pl<!--ced behind the block the item fr<!--me is <!--tt<!--ched to, f<!--cing <!--w<!--y from the item fr<!--me. An item fr<!--me comp<!--r<!--tor will output 0 if the item fr<!--me is empty, or 1 to 8 for <!--ny item depending on its rot<!--tion (1 <!--t initi<!--l pl<!--cement, plus 1 for e<!--ch right-click rot<!--tion to <!-- m<!--ximum of 8, then wr<!--pping b<!--ck to 1).

D<!--t<!-- v<!--lues
A redstone comp<!--r<!--tor is defined by its ID, block d<!--t<!--, <!--nd block entity. A redstone comp<!--r<!--tor <!--lso h<!--s <!-- block st<!--te which is expected to repl<!--ce the function<!--lity of block d<!--t<!-- in <!-- future version.

Block entity
Every redstone comp<!--r<!--tor h<!--s <!-- Comp<!--r<!--tor block entity <!--ssoci<!--ted with it th<!--t specifies the comp<!--r<!--tor's current output power level.

Issues
C<!--tegory:Mech<!--nics C<!--tegory:Redstone mech<!--nics C<!--tegory:Redstone

C<!--tegory:HESI-Block-Unchecked C<!--tegory:HESI-Item-Unchecked C<!--tegory:Rewritten block

Redstone-Komp<!--r<!--tor Comp<!--r<!--dor de redstone Redstone (comp<!--r<!--teur) Vöröskő-összeh<!--sonlító Comp<!--r<!--tore di pietr<!--ross<!-- Komp<!--r<!--tor Компаратор 红石比较器