Incorrect bytes requirement calculation when input fluid isn't sufficient
xyqyear opened this issue ยท 2 comments
When crafting fluid, if the input fluid isn't sufficient, the crafting simulation shows incorrect bytes requirement
If the input fluid is sufficient, the calculation is correct
Problem analysis
ae2fc modifies ae2's code so that when the crafting process is crafting fluid drops, the item stack size used for bytes requirement calculation is divided by 1000. This process is done through the following code snippets
The above code modifies CraftingTreeNode
when a IAEItemStack
's getStackSize is called in line 152, 174, 188 and 208
However, it only considers the part that already exists in the network or can be crafted. The part that's missing is directly added to bytes property of CraftingTreeNode without the division.
This is a code snippet of CraftingTreeNode
line 233-255 [note 2]. The first line of code block 1 is modified by ae2fc, however, the local variable l
(number of items that still needed to be crafted. You can see in the following if statement, if it's less than 0, then return excessive item stack) isn't modified by a factor of 1/1000. In code block 2 (this if statement is only effective when the item is insufficient, meaning not enough in the network nor can be crafted), the variable l
is directly added to this.bytes
, resulting in the bug of the subject matter.
Possible solution
modify line 251 of CraftingTreeNode to this.bytes += l / 1000L;
. Of course, we can't just modify the exact line, just somehow locate the line where this.bytes
is added by l
. Variable l
shouldn't be modified because it tells the user how much more fluid is still needed.
Due to my unfamiliarity with the ASM library, I can only present a possible solution rather than submitting a PR.
note 1: code from external repo can't be rendered as a code block, so I used a screenshot
note 2: this is only one of the four places where this.bytes
is added by an IAEItemStack
's getStackSize()
honestly i really don't want fix it since you can't order crafting job without enough input so the bytes doesn't matter :doom:
but a fix is still doable though it needs more hacky asm injection
fixed by 0221c24