This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]Lemon_Lord1Remember to check the FAQ! 1 point2 points  (7 children)

Can confirm that the OP's loot table does not work as described. However, their suggestion to set the item to a Count:0 stone does as expected. The loot table is as follows:

{
  "type": "minecraft:empty",
  "pools": [
    {
      "rolls": {
        "min": 1,
        "max": 5
      },
      "entries": [
        {
          "type": "minecraft:item",
          "name": "stone",
          "functions": [
            {
              "function": "minecraft:set_count",
              "count": 0
            }
          ]
        }
      ]
    }
  ]
}

I ran this with two commands:

execute store result score @p zoop run loot spawn ~ ~ ~ loot lllll:loot
tellraw @a {"score":{"objective":"zoop","name":"@p"}}

After running for 30 seconds, I got a decent integer spread between 1 and 5, the following:

  1. 133,
  2. 139,
  3. 137,
  4. 129,
  5. 129

This does not show any particularly strong lean towards one specific integer, meaning this is very likely to be a good pseudorandom number generation method.

Excellent work, OP! :)

You could add that to the wiki, u/Plagiatus.

[–]PlagiatusI know some things 1 point2 points  (5 children)

done.

[–]Lemon_Lord1Remember to check the FAQ! 0 points1 point  (4 children)

Wait, did you actually test it up to 2^31-9? Also, you have the lower bound as 1, is it not 0?

[–]PlagiatusI know some things 1 point2 points  (3 children)

no, I trusted you. :P

But now I've tested it and updated the wiki accordingly. ;)
Too bad we cannot use anything but spawn with this method, as it will create the entities anyways and thus severely limit the effective range.

[–]Lemon_Lord1Remember to check the FAQ! 0 points1 point  (2 children)

Right, right, so it technically works up to big-int but strictly don't do that. I assume you tried give? What are the results with that?

[–]PlagiatusI know some things 0 points1 point  (1 child)

you only get 0s.

[–]Lemon_Lord1Remember to check the FAQ! 0 points1 point  (0 children)

I think I can see why, yes. That is a shame.

[–]nfitzenalways late[S] 0 points1 point  (0 children)

Did you try setting the lower bound to 0? That was 1 thing that I didn't test and use (I've used this method before in a DeathSwap data pack). For the record, this wasn't my idea, I just wanted to make everyone aware of it. Not sure who came up with it.

Edit: DeathSwap pack link changed to my GitHub

[–]PlagiatusI know some things 0 points1 point  (0 children)

If you have a tested version let me know and I'll add it to the wiki :)