@@ -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