McJtyMods / InControl

Be In Control of Mob Spawns and others
MIT License
45 stars 16 forks source link

Inconsistent/too many drops when using the "random" argument in loot.json #8

Open TheDeviantCrafter opened 7 years ago

TheDeviantCrafter commented 7 years ago

When creating a loot rule that includes the "random" argument and setting it to a value less than 1, it drops way too many drops, and it seems to choose a new number every time you do /ctrlreload.

I used this script on an instance with only In Control! and CompatLayer installed:

[

  {
    "mob": "Husk",
    "fire": false,
    "item": "minecraft:sand",
    "random": 0.49
  },
  {
    "mob": "Husk",
    "fire": true,
    "item": "minecraft:sand@1",
    "random": 0.49
  }
]

Replication steps:

  1. Load the script and do /ctrlreload to ensure it's active

  2. Kill several husks

  3. Take note of how many drops each husk dropped.

  4. Repeat steps 1-3, doing /ctrlreload before each test.

In my testing, sometimes it gave me the number of drops I was expected. Other times it would give me a stack of sand. I've also gotten 1, 2, 4, and 8 every kill.

McJty commented 7 years ago

With a random of 0.49 it should be about 49% chance of getting a drop. You still can get both at the same time though. Exactly how many are you getting? What if you remove random?

TheDeviantCrafter commented 7 years ago

If I remove random, I get exactly one sand every time. If I add random, sometimes I get way more.

In one particular test I got a stack of sand with every kill. Sometimes it will work as expected. Sometimes I'll get 2 every time, 4 every time, etc. It's random, and it seems to choose a multiple of two at random every time I do /ctrlreload.

TheDeviantCrafter commented 7 years ago

I am getting much more than an average of 0.49. Also, the bug triggers when using 0.5, 0.6 or 0.4 - I've tested all three with identical results. Setting it to 1 gives exactly one sand every time, which is expected behavior.

McJty commented 7 years ago

And you are not using a looting sword?

McJty commented 7 years ago

I just copied your script and I cannot reproduce this at all