Fix AE2 partial material loss when filling compacting drawer through terminal

This commit is contained in:
Justin Aquadro committed 2015-06-09 00:44:33 -04:00
1 parent f6042d3138
commit 3e7643e13c
5 files changed
+36 -12

No files matched your search

@@ -19,4 +19,10 @@ public interface IFractionalDrawer extends IDrawer
* The equivalency is determined by the next compression tier, and not necessarily the conversion rate.
*/
int getStoredItemRemainder ();
/**
* Gets whether or not the stored item represents the smallest granularity of material that can be stored within
* the drawer group.
*/
boolean isSmallestUnit ();
}
@@ -504,6 +504,14 @@ public class TileEntityDrawersComp extends TileEntityDrawers
return TileEntityDrawersComp.this.getStoredItemRemainder(slot);
}
@Override
public boolean isSmallestUnit (int slot) {
if (protoStack[slot] == null || convRate == null || convRate[slot] == 0)
return false;
return convRate[slot] == 1;
}
@Override
public boolean isVoidSlot (int slot) {
return isVoid();
@@ -9,6 +9,7 @@ import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup;
import com.jaquadro.minecraft.storagedrawers.api.storage.IFractionalDrawer;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable;
import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute;
@@ -81,22 +82,24 @@ public class DrawerMEInventory implements IMEInventory<IAEItemStack>
private long injectItemsIntoDrawer (IDrawer drawer, long itemCount, Actionable type) {
int capacity = drawer.getMaxCapacity();
int storedItems = drawer.getStoredItemCount();
if (capacity == storedItems)
int storableItems = capacity - storedItems;
if (drawer instanceof IFractionalDrawer) {
IFractionalDrawer fracDrawer = (IFractionalDrawer)drawer;
if (!fracDrawer.isSmallestUnit() && fracDrawer.getStoredItemRemainder() > 0)
storableItems--;
}
if (storableItems == 0)
return itemCount;
storedItems += itemCount;
if (storedItems > capacity) {
if (type == Actionable.MODULATE)
drawer.setStoredItemCount(capacity);
long remainder = Math.max(itemCount - storableItems, 0);
storedItems += Math.min(itemCount, storableItems);
return storedItems - capacity;
}
else {
if (type == Actionable.MODULATE)
drawer.setStoredItemCount(storedItems);
if (type == Actionable.MODULATE)
drawer.setStoredItemCount(storedItems);
return 0;
}
return remainder;
}
@Override
@@ -108,6 +108,11 @@ public class CompDrawerData extends BaseDrawerData implements IFractionalDrawer,
return central.getStoredItemRemainder(slot);
}
@Override
public boolean isSmallestUnit () {
return central.isSmallestUnit(slot);
}
public void refresh () {
reset();
refreshOreDictMatches();
@@ -28,6 +28,8 @@ public interface ICentralInventory
public int getStoredItemRemainder (int slot);
public boolean isSmallestUnit (int slot);
public boolean isVoidSlot (int slot);
public boolean isShroudedSlot (int slot);