X

NOTICE

Are you sure you want to report this?

When you are making your redstone suggestions, please note that Java and Bedrock will not have the exact same the same redstone systems - this would require redoing redstone system completely on one platform or the other. The two systems are functionally different and are going to stay that way. Please be sure to tag your suggestions with (Java) or (Bedrock).

2

Item Comparator

4 Comments

Post a new comment:

Please sign in to leave a comment.

  • Avatar

    Imagine an automatic crafting bench that determines the recipe using the quantity of items instead of where those items are placed.

    To build a fence I would insert a stack of 2 sticks and 4 planks.

    Activating with redstone gives me fences.

    The same crafting block can create gates as well so your redstone system has to calculate how many of each item is in the crafting block.

    The Item Comparator can do that. The regular Comparator cannot.

  • Avatar

    I believe this is a feature that is not too difficult to program and is almost impossible to do using current materials.

    Below is pseudocode for implementing it:

    Int multiples = 0
    FOR stack1 in Comparator:
       IF stack1 != null:
          Int size = 0
          FOR stack2 in container:
             IF stack2 != null AND stack1.name == stack2.name:
                size += stack2.size
          IF multiples == 0:
             multiples = size / stack1.size
          ELSE:
             multiples = min(multiples, size / stack1.size)
    redstoneSignal = min(multiples, 15)

  • Avatar
    Auldrick commented

    There are some complications to work out. For instance, the recipes for wooden slabs require that all the planks be of the same species, but the recipe for a bookshelf doesn't, so how do you know whether you need to count all planks or specifically spruce planks, birch planks, etc.?

    I doubt that more slots would be a problem. A hopper has to do (nominally) 5 x 54 comparisons when used with a double chest, and while hoppers can be a source of lag, that's only if you have a lot of them. It doesn't seem likely you'd use very many of these in a given device; the absolute most you could use on a given container is 6, and if you have many containers you'd have complications with items need to be in more than one of them.

  • Avatar

    @Auldrick Thanks for the excellent feedback! Basically items with different names should be considered unique. You would need multiple of these to detect different types of wool but I think it's more important to detect them separately than to detect them together.

    It is more efficient to compare IDs than to compare names but I'm not sure how the game handles damage values anymore. I would like damaged swords to be considered the same as non-damaged swords but pink wool to be different to blue wool.