Redstone for Beginners – Sorting Machine

André and I are working on a fancy new housing on the survival instance on his server and it’s becoming obvious that we need a sorting-system for all the good stuff we are getting out of the ground.

So I watched this, tried to build it – and failed.

There were comments saying that it would not work with V 1.8.x but I did not believe that.
The major problem was that I did not understand how the components actually work, therefore I could not debug the system.

Having looked at the Minecraft-Wiki, I realized that it is quite easy to understand. I rebuilt it and now it works – with a small restriction (it is a little annoying that it was not pointed out in the video) described on the bottom of this post .

Here is what you want to achieve: Put random items in a box and let them be delivered to another box of your choice. The transport from the original box to the destination is done via hoppers.

Things to know about the hopper:

  • In general, they will suck items out of dispensers (like boxes or other hoppers) placed above of them for as long as they can
  • In general, if their outlet is connected to a device that can store items, they will pass on everything that is put into them until the target is full. If the outlet is not connected to anywhere, they will not pass items on.
  • They possess 5 item slots of their own. If all slots contain items, the hopper will accept further items of the same kind only. The slots are being emptied from left to right.
  • They send a redstone signal if they have items in their slots. The signal strength is based on the percentage of the fill level – it goes up for every 1/14 of filling. To find out what signal strength your hopper is sending, you need to know the max storage capacity, which again is based on the items you put into the hopper.
    E.g. if you put blocks of iron and dirt into the hopper, the max amount of blocks would be 5 x 64. Floor 1/14 of that is 22, so the signal strength would be 0 for 0 blocks total, 1 for 1 – 22 blocks total, 2 for 23 – 45 blocks total and so on. However, if you use eggs, the total capacity is only 5 x 16 as eggs can only be stacked to 16. 1/14 capacity would then be only 5 eggs.
  • If they receive a redstone signal, e.g from a redstone torch underneath, they will block their in- and outlet

You probably see where this is leading to. We want to have one hopper per material we want to sort (placed in the leftmost slot). To achieve that, we need to pre-fill the sorting hoppers. To pre-fill them, we also need to define one item that we never must put into the machine for being sorted – which is dirt in my case.

Hopper setup front view:

Hopper setup side view:

We need to pre-fill the sorting hoppers with the correct amount of blocks, so that one added block will change the generated signal-strength from 1 to 2. Huh, why is that? Because the bottom level hopper which sucks items out of the sorting hopper above and puts them into the box is deactivated by a redstone torch, so that he does not suck out our pre-filling materials.
If the signal strentgh of the sorting hopper changes, we know that we have to activate the bottom-level hopper. This is done by sending a redstone signal to the redstone torch – for as long as the sorting hopper sends signal strength > 1.

Processing the hopper’s signal

For that we’re going to need the comparator; it has three inputs, one output and a switch.

Basically it does this to calculate the output:

w = y > z ? y : z;
out = x >= w ? (A ? x - w : x) : 0;

For the sorting machine we can use the sorting hopper as the only input x, so that the comparator will just pass on the signal received – with unchanged strength.

Next, we want a sticky piston to activate on signal strength 2. It has a redstone block attached which sends a signal to the appropriate redstone torch and deactivating it, while the piston is extended.
We achieve this by putting exactly 2 blocks between the piston and the comparator and connecting them via redstone, because the signal is diminishing by 1 per redstone wire.

Here it is important to not let a wire interfere with others. That’s what the nifty placing of blocks in the area between comparators and pistons is for. On the floor, mostly comparators are used because they will not compromise each other sideways.

Pistons and comparators on the floor:

Non-interfering redstone-wires:

Most probable sources of error if you are facing problems

  • Hoppers and/or comparators are not facing the correct way
  • Redstone wires interfere with each other on their way to the pistons
  • Incorrect amount of pre-filling in the sorting hoppers

Also, for some components the correct order of placement can be kind of important, e.g. if you prefill your sorting hopper and then put the bottom hopper underneath it without having the redstone torch in place already, it will suck your sorting hopper empty.

About the boxes

To put to small boxes next to each other, every second box has to be a Trapped box instead of a normal one.

Final thoughts

This should enable you to not only build the sorting machine as shown in the video but also understand it and its components – giving you a good base for future Minecraft automation projects.

If you try out the machine, you will notice the small drawback I mentioned in the beginning: The bottom hopper will always keep the last item processed, because the redstone torch underneath is reactivated before the hopper has been emptied completely. I thought about the problem and currently found no easy way to fix that.

Leave a Reply

Your email address will not be published. Required fields are marked *