Fix pushing to drawers
This commit is contained in:
@@ -31,28 +31,8 @@ public class DrawerStorage extends ExternalStorage {
|
|||||||
@Override
|
@Override
|
||||||
public ItemStack push(ItemStack stack, boolean simulate) {
|
public ItemStack push(ItemStack stack, boolean simulate) {
|
||||||
if (ModeFilter.respectsMode(externalStorage.getFilters(), externalStorage, externalStorage.getCompare(), stack) && drawer.canItemBeStored(stack)) {
|
if (ModeFilter.respectsMode(externalStorage.getFilters(), externalStorage, externalStorage.getCompare(), stack) && drawer.canItemBeStored(stack)) {
|
||||||
if (drawer.isEmpty()) {
|
if (!drawer.isEmpty()) {
|
||||||
if (getStored() + stack.stackSize > getCapacity()) {
|
if (getStored() + stack.stackSize > drawer.getMaxCapacity(stack)) {
|
||||||
int remainingSpace = getCapacity() - getStored();
|
|
||||||
|
|
||||||
if (remainingSpace <= 0) {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!simulate) {
|
|
||||||
drawer.setStoredItem(stack, remainingSpace);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ItemHandlerHelper.copyStackWithSize(stack, stack.stackSize - remainingSpace);
|
|
||||||
} else {
|
|
||||||
if (!simulate) {
|
|
||||||
drawer.setStoredItem(stack, stack.stackSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (getStored() + stack.stackSize > getCapacity()) {
|
|
||||||
int remainingSpace = getCapacity() - getStored();
|
int remainingSpace = getCapacity() - getStored();
|
||||||
|
|
||||||
if (remainingSpace <= 0) {
|
if (remainingSpace <= 0) {
|
||||||
@@ -69,6 +49,26 @@ public class DrawerStorage extends ExternalStorage {
|
|||||||
drawer.setStoredItemCount(drawer.getStoredItemCount() + stack.stackSize);
|
drawer.setStoredItemCount(drawer.getStoredItemCount() + stack.stackSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (getStored() + stack.stackSize > drawer.getMaxCapacity(stack)) {
|
||||||
|
int remainingSpace = getCapacity() - getStored();
|
||||||
|
|
||||||
|
if (remainingSpace <= 0) {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!simulate) {
|
||||||
|
drawer.setStoredItem(stack, remainingSpace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ItemHandlerHelper.copyStackWithSize(stack, stack.stackSize - remainingSpace);
|
||||||
|
} else {
|
||||||
|
if (!simulate) {
|
||||||
|
drawer.setStoredItem(stack, stack.stackSize);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user