Minecraft – Redstone circuit that activates from two inputs, but only requires one input to stay on

minecraft-java-editionminecraft-redstone

I want to build a circuit that has a single output from two inputs. The output can be activated when both inputs are true, but once activated it will maintain its state while either input is true. Only once BOTH are false does the output turn false.

My use case for this is a button-activated chest unloader. When the button is pressed, it will empty the chest until the chest is empty. Then it will deactivate.

What I tried to do was a logic gate input into a T Flip Flop gate that looked like:

TFlipFlipInput = (chest && button) || !chest

This almost works, but there's undesired behavior like manually emptying the chest toggles it, or pressing the button a second time will toggle it off.

Best Answer

When I read the question, I quickly thought that a memory cell could be involved somewhere in the solution. But actually, a memory cell (with one input inverted) is already all you need!

Imagine that the comparator comes from your minecart and the button is just your button. The redstone lamp is the output for emptying the minecart.


When the minecart arrives with items, it turns on the comparator, which turns off the redstone lamp on the left and the redstone dust. Nothing else happens, because the memory cell still holds its state, that's the point of a memory cell.

When you now press the button, the bottom redstone torch and the left repeater turn off, which allows the top right redstone torch to turn on (since it's also not deactivated by the redstone line anymore), which turns on the output and the repeater on the right.

When the button input ends, the bottom redstone torch still does not turn on, because the right repeater is still on. Again, what a memory cell is supposed to do.

Only when the comparator turns off and the left redstone torch and the dust turn on again, then the top right redstone torch turns off again, deactivating the right repeater, activating the bottom redstone torch and the left repeater.

Special cases:

  • If the minecart empties before the button turns off, the input turns off rightaway (with 3 ticks delay).
  • If you press the button while the minecart is empty or not there, nothing happens.
  • Spamming both inputs in certain ways very quickly and very often might cause the torches to burn out, but that should be extremely unlikely in your usecase and probably very easy to fix (it might even fix itself).