{{about|the detector rail|other types of rails|Rail (disambiguation)}}
{{Infobox block
| image = Detector Rail.png
| image2 = Powered Detector Rail.png
| transparent = Yes
| light = No
| tool = pickaxe
| renewable = Yes
| stackable = Yes (64)
| flammable = No
| lavasusceptible = No
| waterloggable = Yes
}}
A '''detector rail''' is a type of [[rail]] that produces a [[redstone]] signal while a [[minecart]] is on it.

== Obtaining ==
=== Breaking ===
A detector rail can be broken fairly easily by hand, dropping itself as an item. It can be broken faster by using a pickaxe. 
{{breaking row|horizontal=1|Detector Rail|Pickaxe}}

A detector rail also drops as an item if:
* the block beneath it is removed
* [[water]] or [[lava]] flows over it{{only|java}}
* a [[piston]] moves it into a space with no floor below it.

=== Generated loot ===
{{LootChestItem|detector-rail}}

=== Crafting ===
{{Crafting
|A1= Iron Ingot
|C1= Iron Ingot
|A2= Iron Ingot
|B2= Stone Pressure Plate
|C2= Iron Ingot
|A3= Iron Ingot
|B3= Redstone Dust
|C3= Iron Ingot
|Output= Detector Rail,6
|type= Transportation
}}

== Usage ==
A detector rail can be used as a [[rail]] that can detect when [[minecart]]s are on it or how full container minecarts on it are.

To place a detector rail, use the {{control|Place Block}} [[control]] on the face of a block adjacent to the destination space.

A detector rail can be attached to:
* the '''top''' of any full solid [[opaque]] block (stone, dirt, blocks of gold, etc.), including full-block mechanism components ([[command block]]s, [[dispenser]]s, [[dropper]]s, [[note block]]s, and [[redstone lamp]]s)
* the '''top''' of a [[hopper]], upside-down [[slab]], or upside-down [[stairs]].

A detector rail cannot be attached to the side or bottom of any block, but attempting to make such an attachment may cause the detector rail to attach to the top of a block under the destination space. For example, if a fence is on the ground, attempting to attach a detector rail to the side of the fence causes the detector rail to be attached to the top of the ground next to the fence instead.

If [[Block update|updated]] while on an opened trapdoor, a detector rail (or other rails) breaks drops as an item. Placing a minecart on a detector rail on top of a closed and unpowered trapdoor opens the trapdoor and updates it, causing the detector rail to break. If the trapdoor is powered while the minecart is placed, the trapdoor does not open and the rail does not break. The minecart on the detector rail powers the trapdoor and keeps it closed even if the external power source is removed, allowing the detector rail to stay on.

When placed, a detector rail configures itself to line up with any adjacent [[rail]]s (including [[activator rail]]s, [[powered rail]]s, and other [[detector rail]]s), as well as adjacent rails one block up. If there are two adjacent rails on non-opposite sides, or three or more adjacent rails, a detector rail lines up in the east-west direction. If there are no adjacent rails, a detector rail lines up in the north-south direction (but if a rail is later placed to the east or west, the detector rail re-orients itself in the east-west direction even if it is already connected to another rail to the north or south). If a rail it would line up with is one block up, a detector rail slants upward toward it (with multiple options to slant upward to, a detector rail "prefers", in order: west, east, south, and north). Other configurations can be created by placing and removing various rails.

[[Mob]]s avoid walking across a detector rail (or other rails), but can be pushed onto them.

It cannot be placed suspended in midair, even with commands.<ref>{{bug|MC-182709|||Invalid}}</ref>

=== Rail ===
{{main|Rail}}

Detector rails (and other rails) act as "roads" for [[minecart]]s. A minecart that enters a detector rail's space from either end of the detector rail continues to move, losing only a little velocity (which can then be increased again with [[powered rail]]s). A minecart that enters a detector rail's space from the side turns east or south (depending on the detector rail's orientation), or in the downward direction for a slanted detector rail.

=== Redstone component ===
[[File:Comparitor signal strength minecart.png|thumb|Example for signal strength of a full minecart (right) and a half-full one (left)]]
{{see also|Redstone circuit}}

A detector rail activates when any minecart is on it (even if only a portion of the minecart is on it), and deactivates when no minecarts are on it. The duration of the signal is always a multiple of 10 redstone ticks (although lag or unloading/reloading a chunk might affect this). While active, a detector rail:
* powers adjacent '''[[redstone dust]]''' and adjacent '''[[redstone repeater]]s''' facing away from the detector rail, to [[Redstone circuit#Power level|power level]] 15
* powers adjacent '''[[redstone comparator]]s''' facing away from the detector rail to a level corresponding to the fullness of the minecart if it is a [[minecart with chest]] or a [[Minecart with Hopper]].
* strongly powers any full solid opaque '''block''' beneath the detector rail to power level 15
* activates any adjacent '''[[Redstone components#Mechanism components|mechanism components]]''', including above or below, such as [[piston]]s, [[redstone lamp]]s, [[powered rail]]s, [[hopper]]s, etc.

[[File:Detector-comparator-diff.png|thumbnail|right|Comparators give a signal for a minecart with chest or a minecart with hopper]]
If the minecart on the detector rail is a [[minecart with chest]] or [[minecart with hopper]], an adjacent redstone comparator facing away from the detector rail outputs a power level proportional to the [[Redstone Comparator#Measure block state|container's fullness]], possibly power level 0. For any other type of minecart (including a regular minecart with a mob riding it) the comparator's output is zero.

A comparator can read the contents of a minecart with hopper or with chest on a detector rail through a solid opaque block, as it can with other container blocks.
{{-}}

=== Mob interaction ===
Like other types of rails, [[spider]]s, [[cave spider]]s, and [[warden]]s are the only land mobs that can walk onto detector rails.

== Sounds ==
{{Sound table/Block/Metal}}

== Data values ==
=== ID ===
{{edition|java}}:
{{ID table
|edition=java
|showblocktags=y
|showitemtags=y
|showforms=y
|generatetranslationkeys=y
|displayname=Detector Rail
|spritetype=block
|nameid=detector_rail
|blocktags=prevent_mob_spawning_inside, rails
|itemtags=rails
|foot=1}}

{{edition|bedrock}}:
{{ID table
|edition=bedrock
|shownumericids=y
|showforms=y
|generatetranslationkeys=y
|displayname=Detector Rail
|spritetype=block
|nameid=detector_rail
|id=28
|foot=1}}

=== Block states ===
{{see also|Block states}}
{{:Powered Rail/BS}}

== Video ==
<div style="text-align:center">{{yt|bxVOSJGSDlA}}</div>

== History ==
{{HistoryTable
|{{HistoryLine|java beta}}
|{{HistoryLine||1.5|[[File:Detector Rail (NS) JE1 BE1.png|32px]] [[File:Detector Rail (EW) JE1 BE1.png|32px]] [[File:Detector Rail (nS) JE1 BE1.png|32px]] [[File:Detector Rail (Ew) JE1 BE1.png|32px]] [[File:Detector Rail (Ns) JE1 BE1.png|32px]] [[File:Detector  Rail (eW) JE1 BE1.png|32px]]<br>Added detector rails.}}
|{{HistoryLine|java}}
|{{HistoryLine||1.0.0|dev=Beta 1.9 Prerelease 6|Detector rails are now broken faster using a [[pickaxe]].}}
|{{HistoryLine||1.3.1|dev=12w21a|Detector rails are now [[renewable]], due to redstone dust being obtainable from [[trading]].}}
|{{HistoryLine||1.5|dev=13w10a|[[File:Powered Detector Rail (NS) JE1 BE1.png|32px]] [[File:Powered Detector Rail (EW) JE1 BE1.png|32px]] [[File:Powered Detector Rail (nS) JE1 BE1.png|32px]] [[File:Powered Detector Rail (Ew) JE1 BE1.png|32px]] [[File:Powered Detector Rail (Ns) JE1 BE1.png|32px]] [[File:Powered Detector Rail (eW) JE1 BE1.png|32px]]<br> A texture for active detector rails has now been added.}}
|{{HistoryLine||1.9|dev=15w44a|Detector rails can now be found in [[chest minecart]]s in [[mineshaft]]s.}}
|{{HistoryLine||1.11|dev=16w32b|All sloped rail types' hitbox heights have now been decreased from a full block to a half block.}}
|{{HistoryLine||1.14|dev=18w43a|[[File:Detector Rail (NS) JE2 BE2.png|32px]] [[File:Detector Rail (EW) JE2 BE2.png|32px]] [[File:Detector Rail (nS) JE2 BE2.png|32px]] [[File:Detector Rail (Ew) JE2 BE2.png|32px]] [[File:Detector Rail (Ns) JE2 BE2.png|32px]] [[File:Detector Rail (eW) JE2 BE2.png|32px]]<br>[[File:Powered Detector Rail (NS) JE2 BE2.png|32px]] [[File:Powered Detector Rail (EW) JE2 BE2.png|32px]] [[File:Powered Detector Rail (nS) JE2 BE2.png|32px]] [[File:Powered Detector Rail (Ew) JE2 BE2.png|32px]] [[File:Powered Detector Rail (Ns) JE2 BE2.png|32px]] [[File:Powered Detector Rail (eW) JE2 BE2.png|32px]]<br>The textures of detector rails have now been changed.}}
|{{HistoryLine|||dev=19w12b|Detector rails can now be placed on [[glass]], [[ice]], [[glowstone]] and [[sea lantern]]s.}}
|{{HistoryLine||1.17|dev=20w45a|All rail types can now be waterlogged.}}

|{{HistoryLine|pocket alpha}}
|{{HistoryLine||v0.13.0|dev=build 1|[[File:Detector Rail (NS) JE1 BE1.png|32px]] [[File:Powered Detector Rail (NS) JE1 BE1.png|32px]] Added detector rails.}}
|{{HistoryLine||v0.14.0|dev=build 1|Detector rails can now be found inside [[minecarts with chests]] in [[mineshaft]]s.}}
|{{HistoryLine|bedrock}}
|{{HistoryLine||1.10.0|dev=beta 1.10.0.3|[[File:Detector Rail (NS) JE2 BE2.png|32px]] [[File:Powered Detector Rail (NS) JE2 BE2.png|32px]] The textures of detector rails have now been changed.}}

|{{HistoryLine|console}}
|{{HistoryLine||xbox=TU1|xbone=CU1|ps3=1.00|psvita=1.00|ps4=1.00|wiiu=Patch 1|switch=1.0.1|[[File:Detector Rail (NS) JE1 BE1.png|32px]] [[File:Powered Detector Rail (NS) JE1 BE1.png|32px]]{{verify|Did detector rails really have a texture for being activated in TU1 or was it later added in TU19/TU12?}} Added detector rails.}}
|{{HistoryLine||xbox=TU54|xbone=CU44|ps3=1.52|psvita=1.52|ps4=1.52|wiiu=Patch 24|switch=1.0.4|All sloped rail types' hitbox heights have now been decreased from a full block to a half block.}}
|{{HistoryLine||xbox=none|xbone=none|ps3=none|psvita=none|ps4=1.90|wiiu=none|switch=none|[[File:Detector Rail (NS) JE2 BE2.png|32px]] [[File:Powered Detector Rail (NS) JE2 BE2.png|32px]] The textures of detector rails have now been changed.}}

|{{HistoryLine|new 3ds}}
|{{HistoryLine||0.1.0|[[File:Detector Rail (NS) JE1 BE1.png|32px]] [[File:Powered Detector Rail (NS) JE1 BE1.png|32px]] Added detector rails.}}
}}

=== Data history ===
{{HistoryTable
|{{HistoryLine|java}}
|{{HistoryLine||1.8|dev=14w10a|Detector rails with [[Java Edition data values/Pre-flattening/Block IDs/Before 14w25a|numerical metadata variants]] 6, 7, 14 and 15, which are inaccessible through normal gameplay or even commands and as such require the use of external editors to exist, now have [[Missing model|no model]] [[File:Missing Model JE2.png|32px]]. Their appearances prior to this point were unknown.}}
|{{HistoryLine|||dev=14w25a|Detector rails are now defined via [[block states]] rather than by numerical metadata. Prior to this version, the numerical metadata variants of the detector rail were as follows:
{{dvt|spritetype=block|sprite=detector-rail|Unpowered north-south}}
{{dvt|spritetype=block|sprite=detector-rail|Unpowered east-west}}
{{dvt|spritetype=block|sprite=detector-rail|Unpowered ascending east}}
{{dvt|spritetype=block|sprite=detector-rail|Unpowered ascending west}}
{{dvt|spritetype=block|sprite=detector-rail|Unpowered ascending north}}
{{dvt|spritetype=block|sprite=detector-rail|Unpowered ascending south}}
{{dvt|spritetype=block|sprite=missing-texture-block|dv=6-7|[[Java Edition removed blocks/Metadata variants#Boring variants|Inaccessible - behavior unknown]]}}
{{dvt|spritetype=block|sprite=detector-rail|dv=8|Powered north-south}}
{{dvt|spritetype=block|sprite=detector-rail|Powered east-west}}
{{dvt|spritetype=block|sprite=detector-rail|Powered ascending east}}
{{dvt|spritetype=block|sprite=detector-rail|Powered ascending west}}
{{dvt|spritetype=block|sprite=detector-rail|Powered ascending north}}
{{dvt|spritetype=block|sprite=detector-rail|Powered ascending south}}
{{dvt|spritetype=block|sprite=missing-texture-block|dv=14-15|[[Java Edition removed blocks/Metadata variants#Boring variants|Inaccessible - behavior unknown]]|foot=1}}}}
|{{HistoryLine|||dev=14w26a|Detector rails with metadata values 6, 7, 14 and 15 have now been completely removed from the game.}}
|{{HistoryLine||1.13|dev=17w47a|Prior to [[Java Edition 1.13/Flattening|''The Flattening'']], this block's numeral ID was 28.}}
}}

== Issues ==
{{issue list}}

== Gallery ==
=== Screenshots ===
<gallery>
Detector Rail Teaser.jpg|Image from Notch’s twitter teasing detector rails.
</gallery>

== See also ==
*[[Rail]]
*[[Activator Rail]]
*[[Powered Rail]]

== Navigation ==
{{Navbox redstone|components}}
{{Navbox blocks|Utility}}

[[Category:Non-solid blocks]]
[[Category:Mechanisms]]
[[Category:Manufactured blocks]]
[[Category:Readable by comparators]]

[[de:Sensorschiene]]
[[es:Raíl detector]]
[[fr:Rails détecteurs]]
[[it:Binario]]
[[ja:ディテクターレール]]
[[ko:탐지 레일]]
[[nl:Detectiespoor]]
[[pl:Tory z czujnikiem]]
[[pt:Trilho detector]]
[[ru:Нажимные рельсы]]
[[uk:Детекторні рейки]]
[[zh:探测铁轨]]
