From e9d1bf0385d16ed2bc92515417d09468c7427ae2 Mon Sep 17 00:00:00 2001 From: Raoul Van den Berge Date: Sun, 5 Jun 2016 21:16:34 +0200 Subject: [PATCH] Fixes --- .../refinedstorage/api/storage/IStorage.java | 4 +- .../tile/TileExternalStorage.java | 54 +++++-------------- 2 files changed, 16 insertions(+), 42 deletions(-) diff --git a/src/main/java/refinedstorage/api/storage/IStorage.java b/src/main/java/refinedstorage/api/storage/IStorage.java index 41bf04252..b8b20183f 100755 --- a/src/main/java/refinedstorage/api/storage/IStorage.java +++ b/src/main/java/refinedstorage/api/storage/IStorage.java @@ -32,9 +32,9 @@ public interface IStorage { * For example: this function is called for dirt (64x) while there is only dirt (32x), return the dirt (32x) anyway. * * @param stack A prototype of the stack to push, do NOT modify this stack - * @param size The amount of that prototype we're pushing + * @param size The amount of that prototype we're taking * @param flags On what we are comparing to take the item, see {@link CompareFlags} - * @return The ItemStack we took from the system, or null if we didn't take anything + * @return null if we didn't take anything, or an ItemStack with the take result */ ItemStack take(ItemStack stack, int size, int flags); diff --git a/src/main/java/refinedstorage/tile/TileExternalStorage.java b/src/main/java/refinedstorage/tile/TileExternalStorage.java index 7f6087d6f..a21652361 100755 --- a/src/main/java/refinedstorage/tile/TileExternalStorage.java +++ b/src/main/java/refinedstorage/tile/TileExternalStorage.java @@ -17,10 +17,7 @@ import refinedstorage.api.storage.IStorageProvider; import refinedstorage.container.ContainerStorage; import refinedstorage.inventory.BasicItemHandler; import refinedstorage.network.MessagePriorityUpdate; -import refinedstorage.tile.config.ICompareConfig; -import refinedstorage.tile.config.IModeConfig; -import refinedstorage.tile.config.IRedstoneModeConfig; -import refinedstorage.tile.config.ModeConstants; +import refinedstorage.tile.config.*; import java.util.List; @@ -69,20 +66,22 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider @Override public ItemStack push(ItemStack stack, boolean simulate) { - IDeepStorageUnit storageUnit = getStorageUnit(); + if (ModeFilter.respectsMode(filters, this, compare, stack)) { + IDeepStorageUnit storageUnit = getStorageUnit(); - // @todo: fix push for deep storage units - if (storageUnit != null) { - if (storageUnit.getStoredItemType() == null) { - storageUnit.setStoredItemType(stack.copy(), stack.stackSize); + // @todo: fix push for deep storage units + if (storageUnit != null) { + if (storageUnit.getStoredItemType() == null) { + storageUnit.setStoredItemType(stack.copy(), stack.stackSize); + } else { + storageUnit.setStoredItemCount(storageUnit.getStoredItemType().stackSize + stack.stackSize); + } } else { - storageUnit.setStoredItemCount(storageUnit.getStoredItemType().stackSize + stack.stackSize); - } - } else { - IItemHandler handler = getItemHandler(); + IItemHandler handler = getItemHandler(); - if (handler != null) { - return ItemHandlerHelper.insertItem(handler, stack.copy(), simulate); + if (handler != null) { + return ItemHandlerHelper.insertItem(handler, stack, simulate); + } } } @@ -126,31 +125,6 @@ public class TileExternalStorage extends TileMachine implements IStorageProvider return null; } - /* - @Override - public boolean mayPush(ItemStack stack) { - if (ModeFilter.respectsMode(filters, this, compare, stack)) { - IDeepStorageUnit storageUnit = getStorageUnit(); - - if (storageUnit != null) { - if (storageUnit.getStoredItemType() == null) { - return stack.stackSize < storageUnit.getMaxStoredCount(); - } - - return RefinedStorageUtils.compareStackNoQuantity(storageUnit.getStoredItemType(), stack) && (storageUnit.getStoredItemType().stackSize + stack.stackSize) < storageUnit.getMaxStoredCount(); - } else { - IItemHandler handler = getItemHandler(); - - if (handler != null) { - return ItemHandlerHelper.insertItem(handler, stack, true) == null; - } - } - } - - return false; - } - */ - public IDeepStorageUnit getStorageUnit() { return getFacingTile() instanceof IDeepStorageUnit ? (IDeepStorageUnit) getFacingTile() : null; }