Shuffling items in a chest

Shuffling items in a chest - Brown and Black Clothes Hanged on Clothes Hanger

I am trying to make a game in vanilla Minecraft, and I need to shuffle items in chest. To do that I made a dropper system that allows to shuffle 9 items (and multiples of 9). The problem is, that when inputted 10 items, it shuffles only 9. Also the problem I face is that I need the dropper to wait until all 9 slots are full.

To make it easier I use only unstackable items such as swords and armor.

Can you please help me with creating another shuffle device or helping improve mine?

Photos:

This is the input:

enter image description here

And this is the output:

enter image description here

More pictures:

enter image description here

enter image description here



Best Answer

As of 1.9, you can use Loot Tables to randomize chest contents, which includes what slots the items appear within.

For example, given the following loot table under the filepath .minecraft/saves/WORLD/data/loot_tables/test/pickaxes.json:

{
    "pools": [
        {
            "rolls": 27,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:diamond_pickaxe",
                    "weight": 1
                },
                {
                    "type": "item",
                    "name": "minecraft:golden_pickaxe",
                    "weight": 1
                }
            ]
        }
    ]
}

The chest to be created using that loot table:

/setblock ~ ~1 ~ minecraft:chest 0 replace {LootTable:"test:pickaxes"}

Chest filled with diamond/gold pickaxes

All 27 slots will be filled with each slot having an equal chance of being either a diamond or a gold pickaxe. Modify the weight to change the chances in comparison to one another; if diamond pickaxes have a higher weight compared to gold, they will be chosen more often. Modify rolls to change how many slots are to be filled.




Pictures about "Shuffling items in a chest"

Shuffling items in a chest - Man in Black Hoodie Looking at the Window
Shuffling items in a chest - Free stock photo of antique, art, culture
Shuffling items in a chest - Free stock photo of adult, bowl, coffee





How to EFFICIENTLY MOVE ITEMS in Minecraft 1.16 [Inventory Tips]




More answers regarding shuffling items in a chest

Answer 2

I made a point not to use commands, so that you can build the shuffler in full survival mode.

Well, i did not manage to shrink the time. I could have, but not waiting for the droppers to fill up completely leads to a partial shuffling, and this is not good.

My design solves the other problem, the number of items scrambled. With this machine you can randomize up to a full double chest of items.

I look forward to build a more efficient one, the challenge intrigues me, but here's the product this far, hope you like it :)

This is the world download.

Some instruction + pics

To make the shuffler run, turn off the lever. The light will turn off. For the farm to work correctly, keep the lever off until finished. When the items starts to be delivered, a yellow block rises from the farm, dropping down again once is finished. Left chest is input (i put 18 name tagged items for demo), right one is output.

enter image description here

To test it out another time after the first one, turn the lever on again, put the item to shuffle all together in the left chest, then switch off again and wait. I prepared a chest full of nbt chest with the demo items. If you want ot repeat the test, just empty the output chest and replace one of the two in input with an nbt one, then switch off the lever aaaand you got it.

enter image description here

EDIT: i built a bigger one. Added to the same world download. Always 54 items max sorting size, but this one is capable of shuffling them better and at a much higher speed.

54 items take 1.08 min to be completely randomized.

The system works in the same way as the one before, only starts shuffling as soon as a dropper is full, instead of waiting a full shuffle and then doing another cycle. The design is also infinitely stackable (reeeeeally well shuffled, baby)

enter image description here

I think i'll do a final one in the next days, one with settable shuffling levels and much more compact.

Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

Images: Ron Lach, Nicolás Langellotti, ANTONI SHKRABA, ANTONI SHKRABA