{{about|the detector rail|other types of rails|Rail (disambiguation)}}
{{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
}}

A '''detector rail''' is a type of [[rail]] that produces a [[Redstone Dust|redstone signal]] when 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.

=== Chest 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.
{{-}}

== 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 ==
{{History|java beta}}
{{History||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.}}
{{History|java}}
{{History||1.0.0|snap=Beta 1.9 Prerelease 6|Detector Rails are now broken faster using a [[pickaxe]].}}
{{History||1.3.1|snap=12w21a|Detector rails are now [[renewable]], due to redstone dust being obtainable from [[trading]].}}
{{History||1.5|snap=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.}}
{{History||1.9|snap=15w44a|Detector rails can now be found in [[minecart with chest|chest minecart]]s in [[mineshaft]]s.}}
{{History||1.11|snap=16w32b|All rail types' hitbox heights have now been decreased from a full block to a half block.}}
{{History||1.14|snap=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.}}
{{History|||snap=19w12b|Detector rails can now be placed on [[glass]], [[ice]], [[glowstone]] and [[sea lantern]]s.}}
{{History||1.17|snap=20w45a|All rail types can now be waterlogged.}}

{{History|pocket alpha}}
{{History||v0.13.0|snap=build 1|[[File:Detector Rail (NS) JE1 BE1.png|32px]] [[File:Powered Detector Rail (NS) JE1 BE1.png|32px]] Added detector rails.}}
{{History||v0.14.0|snap=build 1|Detector rails can now be found inside [[minecart with chest]]s in [[mineshaft]]s.}}
{{History|bedrock}}
{{History||1.10.0|snap=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.}}

{{History|console}}
{{History||xbox=TU1|xbone=CU1|ps=1.0|wiiu=Patch 1|switch=1.0.1|[[File:Detector Rail (NS) JE1 BE1.png|32px]] [[File:Powered Detector Rail (NS) JE1 BE1.png|32px]] Added detector rails.}}
{{History||xbox=none|xbone=none|ps=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.}}

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

=== Data history ===
{{History|java}}
{{History||1.8|snap=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.}}
{{History|||snap=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}}}}
{{History|||snap=14w26a|Detector rails with metadata values 6, 7, 14 and 15 have now been completely removed from the game.}}
{{History||1.13|snap=17w47a|Prior to [[Java Edition 1.13/Flattening|''The Flattening'']], this block's numeral ID was 28.}}
{{History|foot}}

== Issues ==
{{issue list}}

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

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

{{Redstone}}
{{Blocks|Utility}}

[[Category:Non-solid blocks]]
[[Category:Redstone mechanics]]
[[Category:Mechanisms]]
[[Category:Mechanics]]
[[Category:Manufactured blocks]]

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