Skip to content

Commit 8168bae

Browse files
committed
Fixed upgrades not being able to be extracted properly in compacting drawers, closes #417
1 parent 5207b1e commit 8168bae

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Support fractional factors and base amounts - Matyrobbrt
66
* Fixed Controller, Access Point and Armory Cabinet having their model reversed, closes #435
77
* Fixed being able to extract upgrades from Fluid Drawers, closes #437
8+
* Fixed upgrades not being able to be extracted properly in compacting drawers, closes #417
89

910
# VERSION 1.5.1
1011

src/main/java/com/buuz135/functionalstorage/block/tile/CompactingDrawerTile.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,13 @@ public IItemHandler getStorage() {
119119

120120
@Override
121121
protected boolean canChangeMultiplier(double newSizeMultiplier) {
122-
var stack = getStorage().getStackInSlot(2);
123-
if (stack.isEmpty()) return true;
124-
return stack.getCount() <= Math.min(Integer.MAX_VALUE, Math.floor(stack.getMaxStackSize() * newSizeMultiplier));
122+
for (int i = 0; i < getStorage().getSlots(); i++) {
123+
var stored = getStorage().getStackInSlot(i);
124+
if (!stored.isEmpty() && stored.getCount() > Math.min(Integer.MAX_VALUE, Math.floor(newSizeMultiplier * getHandler().getSlotLimitBase(i)))) {
125+
return false;
126+
}
127+
}
128+
return true;
125129
}
126130

127131
@NotNull

src/main/java/com/buuz135/functionalstorage/block/tile/SimpleCompactingDrawerTile.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,13 @@ public IItemHandler getStorage() {
120120

121121
@Override
122122
protected boolean canChangeMultiplier(double newSizeMultiplier) {
123-
var stack = getStorage().getStackInSlot(1);
124-
if (stack.isEmpty()) return true;
125-
return stack.getCount() <= Math.min(Integer.MAX_VALUE, Math.floor(stack.getMaxStackSize() * newSizeMultiplier));
123+
for (int i = 0; i < getStorage().getSlots(); i++) {
124+
var stored = getStorage().getStackInSlot(i);
125+
if (!stored.isEmpty() && stored.getCount() > Math.min(Integer.MAX_VALUE, Math.floor(newSizeMultiplier * getHandler().getSlotLimitBase(i)))) {
126+
return false;
127+
}
128+
}
129+
return true;
126130
}
127131

128132
@NotNull

src/main/java/com/buuz135/functionalstorage/inventory/CompactingInventoryHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public int getSlotLimit(int slot) {
155155

156156
public int getSlotLimitBase(int slot) {
157157
if (slot == this.slots) return Integer.MAX_VALUE;
158-
return (int) Math.min(Integer.MAX_VALUE, Math.floor(64 * 9 * 9f / this.resultList.get(slot).getNeeded()));
158+
return (int) Math.min(Integer.MAX_VALUE, Math.floor((slots == 2 ? 64 * 9d : 64 * 9d * 9)/ this.resultList.get(slot).getNeeded()));
159159
}
160160

161161
@Override

0 commit comments

Comments
 (0)