Skip to content

Commit 731349d

Browse files
committed
Fix: Fixes #326 for 1.20.1
1 parent e4563f7 commit 731349d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
apply plugin: 'net.minecraftforge.gradle'
1313

1414
group = 'com.buuz135'
15-
version = '1.20.1-1.2.12'
15+
version = '1.20.1-1.2.13'
1616

1717
java {
1818
archivesBaseName = 'functionalstorage'

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate
6161
return ItemStack.EMPTY;
6262
if (isValid(slot, stack)) {
6363
CompactingUtil.Result result = this.resultList.get(slot);
64-
int inserted = Math.min(getSlotLimit(slot) * result.getNeeded() - amount, stack.getCount() * result.getNeeded());
65-
inserted = (int) (Math.floor(inserted / result.getNeeded()) * result.getNeeded());
64+
int inserted = Math.toIntExact(Math.min((long) getSlotLimit(slot) * (long) result.getNeeded() - amount,
65+
(long) stack.getCount() * result.getNeeded()));
66+
inserted = (int) (Math.floor((double) inserted / result.getNeeded()) * result.getNeeded());
6667
if (!simulate) {
67-
this.amount = Math.min(this.amount + inserted, totalAmount * getMultiplier());
68+
this.amount = Math.toIntExact(
69+
Math.min((long) this.amount + inserted, totalAmount * (long) getMultiplier()));
6870
onChange();
6971
}
7072
if (inserted == stack.getCount() * result.getNeeded() || isVoid()) return ItemStack.EMPTY;
@@ -146,7 +148,8 @@ public int getSlotLimit(int slot) {
146148
if (slot == this.slots) return Integer.MAX_VALUE;
147149
int total = totalAmount;
148150
if (hasDowngrade()) total = 64 * 9 * 9;
149-
return (int) Math.min(Integer.MAX_VALUE, Math.floor((total * getMultiplier()) / this.resultList.get(slot).getNeeded()));
151+
return (int) Math.min(Integer.MAX_VALUE, Math.floor(
152+
(double) (total * (long) getMultiplier()) / this.resultList.get(slot).getNeeded()));
150153
}
151154

152155
public int getSlotLimitBase(int slot) {

0 commit comments

Comments
 (0)