fixed invManager wrong invState update

thanks chatGPT
This commit is contained in:
Niklas Kapelle 2024-01-29 00:08:13 +01:00
parent 8cd105b84c
commit 64f4304626
Signed by: niklas
GPG Key ID: 4EB651B36D841D16

View File

@ -142,6 +142,7 @@ class InvManager {
while (loopProtect > 0) { while (loopProtect > 0) {
loopProtect--; loopProtect--;
if (topIndex < k) { if (topIndex < k) {
return; return;
} }
@ -159,10 +160,9 @@ class InvManager {
Log.error("Failed to transfer items"); Log.error("Failed to transfer items");
} }
// Update invState
var topState = invState.get(slots[topIndex]); var topState = invState.get(slots[topIndex]);
topState.count += transferCount; topState.count += transferCount;
invState.set(topIndex, topState); invState.set(slots[topIndex], topState);
var botState = invState.get(slot); var botState = invState.get(slot);
botState.count -= transferCount; botState.count -= transferCount;
@ -174,6 +174,10 @@ class InvManager {
break; break;
} }
} }
if (loopProtect < 0) {
Log.silly("Loopprotection triggerd");
}
} }
} }
} }