Minecraft – How to block minecart with chest until they are empty

minecraft-java-edition

So I got an item-transfer system.
I got a hopper under a detector rail, which detects whenever the chest is empty, but I have no way to block it.

What should I do?

Best Answer

You must use a comparator on the hopper (with one powered rail above it), than a redstone torch to activate it.

Check bellow:

block-minecart_side

block-minecart_up

What happens is that when the minecart move one item into the hopper, the comparator detect this and send one energy pulse to the repeater, that energizes a block. This guy have a redstone above it that charges a second block with a redstone torch on it, consequently deactivating the torch and unpowering the rail. When all items were moved to the chest, there's no more energy, so the redstone torch power on and activate the rail, forcing the minecart to move back.

IF YOUR MINECART CAN'T GO BACK:

The same system above, the difference is that you need a detector rail 1 block far from the hopper and the powered rail must be going down:

up

side

front

down_side