Getting a comparator signal from a Minecraft hopper or storage minecart requires the minecart to rest on detector rail. This presents a challenge, as detector rail cannot propel minecarts. To solve this, you’ll need a block swapper, along with some control circuitry.
Building a Block Swapper for Comparator Signal
Traditional simple block swapper designs may not function as expected. A more reliable approach involves a specific design using pistons and redstone, as demonstrated in this YouTube tutorial (link to video if available). This design horizontally swaps detector rail and powered rail, ensuring the minecart moves smoothly while also allowing for comparator readings.
A crucial, often overlooked detail, is the redstone torch placed behind the central piston. This torch plays a vital role in the swapper’s operation.
Wiring the Block Swapper for Automated Control
The block swapper needs to be triggered based on the minecart’s and hopper’s contents. Ideally, the trigger logic should resemble this pseudocode:
if(!cart.empty() && hopper.empty() || cart.full()) block_swapper.trigger();
This ensures the swapper activates when the minecart isn’t empty and the hopper is empty, or when the minecart is full. This more comprehensive condition prevents the minecart from remaining stationary when items remain in the hopper.
Resetting the Detector Rail
To prevent continuous back-and-forth movement, the detector rail needs to be replaced after the minecart departs. This requires triggering the block swapper a second time, achieved by incorporating a delay circuit. A simple delay circuit using repeaters can accomplish this:
Important Considerations and Observations
Testing reveals that storage minecarts might not function as intended in this setup. They might not be filled by the hopper, possibly due to the powered detector rail beneath them. Hopper minecarts, however, work correctly.
An MCEdit schematic file containing the system described above is available (link to schematic if available but remove dropbox link). This schematic includes the block swapper and reset circuit but does not incorporate the complete cart detection logic, leaving its implementation as an exercise for the reader.
Finally, note that this behavior was observed in Minecraft version 1.8 snapshots. Whether this interaction between comparators, minecarts, and detector rails existed in previous versions remains unconfirmed.