1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-10-31 13:42:59 +00:00

Correctly obey stack limits in OffsetStorage.extract/insert

Many thanks to Lem for managing to reproduce it. It was actually an easy
bug bug to spot on second look, but having a reliable way to verify was
super helpful.

Fixes #1338
This commit is contained in:
Jonathan Coates
2023-03-15 20:07:17 +00:00
parent e96ac35d67
commit 44f945c040
5 changed files with 48 additions and 13 deletions

View File

@@ -111,7 +111,7 @@ public class FabricContainerTransfer implements ContainerTransfer {
long transferred = 0;
for (var i = 0; i < size; i++) {
transferred += slots.get(wrap(i, size)).insert(resource, maxAmount, transaction);
transferred += slots.get(wrap(i, size)).insert(resource, maxAmount - transferred, transaction);
if (transferred >= maxAmount) break;
}
@@ -125,7 +125,7 @@ public class FabricContainerTransfer implements ContainerTransfer {
long transferred = 0;
for (var i = 0; i < size; i++) {
transferred += slots.get(wrap(i, size)).extract(resource, maxAmount, transaction);
transferred += slots.get(wrap(i, size)).extract(resource, maxAmount - transferred, transaction);
if (transferred >= maxAmount) break;
}