Recipes with both "count" and "chance" fields on the same item using default value for "count" of 1 instead of intended amount when crafting (washing/splashing on Red sand and Soul sand specifically tested)
Healex2 opened this issue ยท 9 comments
Describe the Bug
When washing/splashing red sand, I am getting singular gold nuggets, instead of groups of 3 gold nuggets as suggested by JEI.
Edit: I have also tried the same process on soul sand and it also yields the default count of 1 item, instead of the expected 4.
I suspect this may effect other processes that contain both count and chance fields for a specific item like:
{
"item": "minecraft:gold_nugget",
"count": 3,
"chance": 0.125
}
as opposed to items that only have one or the other (with respect to count and chance).
Reproduction Steps
- Set up a washing station on a moving belt
- Add a red sand feed for singular blocks at a time
- Observe resulting products via right clicking the belt to pick up the items
Expected Result
clumps of 3 gold nuggets (1/8 of the time when red sand is washed, as it's a 12.5% chance)
Screenshots and Videos
No response
Crash Report or Log
No response
Operating System
Windows 10
Mod Version
0.4.0a
0.4.0b
Minecraft Version
1.18.1
Forge Version
39.0.0
Other Mods
Full list in "Name: filename.jar" format:
Create: create-mc.1.18.1_v0.4a.jar or create-mc.1.18.1_v0.4b.jar
Flywheel: flywheel-forge-1.18-0.4.1.jar
Just Enough Items (JEI): jei-1.18.1-9.1.0.44.jar
Additional Context
No response
JEI is not misleading. This is how all vanilla loot table works. chance of x% and stack size of y always means a binomial distribution Bi(y,x%), which has an average of y*x%
Anyway, the expected result should be the same.
Source code also suggests it should be 3 gold nuggets, instead of 1.
{
"type": "create:splashing",
"ingredients": [
{
"item": "minecraft:red_sand"
}
],
"results": [
{
"item": "minecraft:gold_nugget",
"count": 3,
"chance": 0.125
},
{
"item": "minecraft:dead_bush",
"chance": 0.05
}
]
}
Also tried washing (splashing) soul sand and it also only gives singles of items that have both count and chance fields on the same item.
{
"type": "create:splashing",
"ingredients": [
{
"item": "minecraft:soul_sand"
}
],
"results": [
{
"item": "minecraft:quartz",
"count": 4,
"chance": 0.125
},
{
"item": "minecraft:gold_nugget",
"chance": 0.02
}
]
}
Some other items that have similar item/count/chance format I've found (though I have not tested most of these yet):
Crushing: horse armors, prismarine crystals, misc. modded items (ores & gems);
Splashing/Washing: red sand, soul sand, misc. modded items;
Milling: allium, wheat, bone, rose bush, misc. modded items (flowers)
I think this is likely to be intented. Every single item in the stack is rolled with the probability. It means that a stack of 4 with probability 0.125 will most likely showing up with a stack of 1 with the chance of 0.335, and with the chance of showing up with a stack of 4 of 0.125^4 = 0.000244
In ProcessingOutput
,
public ItemStack rollOutput() {
int outputAmount = stack.getCount();
for (int roll = 0; roll < stack.getCount(); roll++)
if (r.nextFloat() > chance)
outputAmount--;
if (outputAmount == 0)
return ItemStack.EMPTY;
ItemStack out = stack.copy();
out.setCount(outputAmount);
return out;
}
I think this is likely to be intented. Every single item in the stack is rolled with the probability. It means that a stack of 4 with probability 0.125 will most likely showing up with a stack of 1 with the chance of 0.335, and with the chance of showing up with a stack of 4 of 0.125^4 = 0.000244
In
ProcessingOutput
,public ItemStack rollOutput() { int outputAmount = stack.getCount(); for (int roll = 0; roll < stack.getCount(); roll++) if (r.nextFloat() > chance) outputAmount--; if (outputAmount == 0) return ItemStack.EMPTY; ItemStack out = stack.copy(); out.setCount(outputAmount); return out; }
Though I had an admittedly small sample size (20-50 attempts with yield) they were ALL singles regardless. Also, if what you're saying is the case, then I find the JEI prompt misleading.
P.S. I noticed this unexpected behavior when making a gold nugget generator to feed gold plates to an automatic precision mechanism assembly line.
Okay, I looked through the math myself and did some testing with 16,000 red sand washed and I got ~3% over expected value, so within error for that sample size.
Is it possible to close my own ticket? (I haven't found an option to do so.)
This issue has been marked as stale because it has been inactive for 3 weeks. It will be closed if it remains inactive for another 3 weeks.