Is it possible to modify this Minecraft contraption to make the cart leave if it is full?

I have the following contraption:

enter image description here

I got it from this video, the only component not shown in the image is a redstone torch on the back side of the top stone block.

It works by stopping the minecart if there are items in the hopper, and letting the minecart go if the hopper is empty. This works fine if I manually put items in the chest above the hopper and I'm careful not to over-fill it.

Now, I would like to have this contraption at the end of a farm, some distance away (but not so much that the chunks aren't loaded) from my storage building.

Can I modify the contraption so that the cart leaves if the hopper is empty OR the cart is full?

Alternatively, can I make it so the cart leaves only when full?


Solution 1:

This is a nice, compact, simple setup that works most of the time.

In particular, it will send the minecart away when the bottom hopper is empty (meaning the farm ran out of items) or when the cart can't accumulate any more items and the hopper accumulates enough to raise signal strength to 2. It will fail if the storage/farm has exactly between 1 and 21 items more than the minecart can fit. It will resume work as soon as the bottom hopper picks 22 extra items.

Since it doesn't ever look at cart contents, depending only on failing to place more than it can fit, it doesn't mind mixed and non-full stacks, so the problem from the other two designs is absent. It won't work with non-stackable items though.

enter image description here

Solution 2:

My solution isn't the prettiest, but it works.

First, a full minecart on top of a detector rail with a comparator emits a signal strength of 15 (Full cart - 1 item emits 14). We can also subtract signals using one comparator and a signal coming from the side so this measurement won't take too much space.

Full minecart on top of a detector rail emitting 1 signal

With this idea in mind, I made this contraption:

Full contraption

A 2x3 rail cycle with the exit (bottom right normal rail) always powered by a torch (not the case of the pic as the hopper is empty) which would result in the cycle being closed.

On the right side of the picture, we have the hopper with a comparator and torch, so when it is empty, it emits a signal, turning off the torch bellow the entrance rail, making it open (Exactly as seen in the pic)

On the left we have the same comparator situation described earlier, powering the torch below the entrance in case the cart is full.

This solution has minor problems:

  • It wont fill the cart chest at full speed (Should be around 0.8x as fast). This can be solved by putting more hoppers around the track, but that would mean more hoppers with comparators in a cramped space.
  • The cart is always moving, contributing to server lag (Even if in extremely small quantities).
  • Is relatively large for a simple task.

Major problem

In case you have a farm/storage that outputs different type of items, the cart will only leave if every stack has 64 units. This could even totally freeze the system by having the hopper flooded with one type of item and the car needing another one.

Cart Stuck:

Cart stuck

Hopper: Full Hopper

Cart: Not fully, clogged, cart

You can solve this by making the comparator from the detector rail receive less than 14 signals from the side. Each 2 stacks-ish represents a signal, except for 0 and 15 which are Full and Empty carts

Solution 3:

So, I was watching this video on the subject and at the shared timestamp there is a nice approach to stop a minecart: use an incline and two solid blocks.

So I came up with these solutions (click on the images for larger versions):

  1. here we let the cart go when it is full
    top view of only full contraption

  2. here we let the cart go when it is full OR the hopper above it is empty
    top view of both conditions contraption side view of both conditions contraption

Still, this does not address the problem highlighted by Bruno, i.e. the cart could get stuck.

UPDATE:

After using , observing and playing with this contaption a bit, this is my latest iteration:

top view of updated both conditions contraption side view of updated both conditions contraption

Apart from managing to make it a bit more compact, using Bruno's insight I moved the redstone torch powering the powered rails away from the comparator, allowing the cart to leave when a few items are missing. Then I added a stone block above that comparator, or the cart could be pushed off the rails if the piston activates while the cart is moving on/off the ramp.