Discuss Minecraft's Redstone systems, including automation, circuits, components, and technical gameplay. Share ideas and feedback on Redstone mechanics across Minecraft. Because Java Edition and Bedrock Edition use different Redstone systems, some behaviors will differ between versions. Please tag your posts with Java, Bedrock, or Both where applicable.

4

Item Comparator

4 Comments

Post a new comment:

Please sign in to leave a comment.

Sorted by oldest
  • 0
    Registered User commented
    Comment actions Permalink

    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.

  • 0
    Registered User commented
    Comment actions Permalink

    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)

  • 0
    Registered User commented
    Comment actions Permalink

    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.

  • 0
    Registered User commented
    Comment actions Permalink

    @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.