mojira.dev
MC-75571

Comparators don't detect flowing items

When some hoppers are making a way down, as on the screenshot, if any item is thrown in the hopper on top, this item will travel down too fast and the comparator is not able to detect the items flowing through.
the only way to detect the items is to put more than 3 items, at the same times (no one by one) in the hopper where the comparator is.

Code analysis: https://bugs.mojang.com/browse/MC-75571?focusedCommentId=285109&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-285109

Linked issues

Attachments

Comments 6

Atlas Abraham Weed

Mark as ''Intended''
This is intended: comparators cannot detect items flowing away from it. The hopper must be pointing at the comparator.

user-f2760

The hopper must be pointing at the comparator.

no it doesn't

place a hopper facing away from the comperator and place a item in, the comperator will turn on

Roy Sajima

Confirmed for 16w05b

marcono1234

Confirmed for

  • 16w06a

marcono1234

Please link to this comment in the description

The following is based on decompiled version of Minecraft 1.8 using MCP. All method and class names are the names used in the decompiled version.

When a hopper receives an item its cooldown is set to 8 ticks. So it has to wait 8 ticks until it can pass an item. The problem is that hoppers can collect the item of containers above them as well. This means even though the hopper which just received an item is on cooldown, the hopper below it can collect the item. This causes hoppers to transfer item downwards much faster than horizontally. Another problem that acts here is that (if I understand it correctly) redstone updates are not applied immediately. So when a horizontal hopper chain transports an item, the comparator is able to detect the item due to the cooldown of 8 ticks. However when the item is transported downwards, when the comparator is updated the item is no longer in the hopper.

This could be fixed by having hoppers collect items from hoppers above them only, when they are disabled by a redstone signal. The fix would be needed for the public static boolean func_145891_a(IHopper p_145891_0_) method of the net.minecraft.tileentity.TileEntityHopper class.

public static boolean func_145891_a(IHopper p_145891_0_)
{
    IInventory var1 = func_145884_b(p_145891_0_);

    if (var1 != null)
    {
        EnumFacing var2 = EnumFacing.DOWN;

        if (func_174917_b(var1, var2))
        {
            return false;
        }

        if (var1 instanceof ISidedInventory)
        {
            //...
        }
        else
        {
            // Added the following lines
            // Imported net.minecraft.entity.item.EntityMinecartHopper
            if (var1 instanceof TileEntityHopper) {
                if (BlockHopper.getActiveStateFromMetadata(((TileEntityHopper) var1).getBlockMetadata())) {
                    return false;
                }
            }
            else if (var1 instanceof EntityMinecartHopper) {
                if (!((EntityMinecartHopper) var1).getBlocked()) {
                    return false;
                }
            }
            
            int var7 = var1.getSizeInventory();

            for (int var8 = 0; var8 < var7; ++var8)
            {
                if (func_174915_a(p_145891_0_, var1, var8, var2))
                {
                    return true;
                }
            }
        }
    }
    else
    {
        //...
    }

    return false;
}
shahar ben hamo

Idk why it's closed because it is still happening on 19w08b for me..

matt b

Nathan Adams

Confirmed

Minecraft 1.8, Minecraft 1.8.1, Minecraft 1.8.2-pre1, Minecraft 1.8.8, Minecraft 1.8.9, Minecraft 16w05b, Minecraft 16w06a

Retrieved