Revert "Fixes #1144 - "Refined Storage thinks that I have double of everything in my drawers when using two external storages busses""
This reverts commit 393a3ffa3c
.
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
- Fixed Crafting Tweaks buttons positioned wrongly (blay09)
|
||||
- Fixed Crafting Tweaks keybindings interfering with RS keybindings (blay09)
|
||||
- Fixed crash when updating storages (raoulvdberge)
|
||||
- Fixed External Storage showing the wrong amount of items if you connect multiple External Storages to the same inventory (raoulvdberge)
|
||||
|
||||
### 1.4.4
|
||||
- Updated Forge to 2284 (raoulvdberge)
|
||||
|
@@ -23,6 +23,10 @@ public interface IStorageCache<T> {
|
||||
|
||||
/**
|
||||
* Adds a stack to the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link IStorage#insert(T, int, boolean)} to add a stack to an actual storage.
|
||||
* <p>
|
||||
* Will merge it with another stack if it already exists.
|
||||
*
|
||||
* @param stack the stack to add, do NOT modify
|
||||
@@ -33,6 +37,9 @@ public interface IStorageCache<T> {
|
||||
|
||||
/**
|
||||
* Removes a stack from the cache.
|
||||
* <p>
|
||||
* Note that this doesn't modify any of the connected storages, but just modifies the cache.
|
||||
* Use {@link IStorage#extract(T, int, int, boolean)} to remove a stack from an actual storage.
|
||||
*
|
||||
* @param stack the stack to remove, do NOT modify
|
||||
* @param size the size to remove
|
||||
@@ -51,16 +58,7 @@ public interface IStorageCache<T> {
|
||||
IStackList<T> getList();
|
||||
|
||||
/**
|
||||
* @return the storages in this cache, do NOT modify
|
||||
* @return the storages connected to this network
|
||||
*/
|
||||
List<IStorage<T>> getStorages();
|
||||
|
||||
/**
|
||||
* Adds a storage to the cache.
|
||||
* Will not add duplicate storages, it checks this with Object#equals.
|
||||
*
|
||||
* @param storage the storage
|
||||
* @return true if the storage was added successfully, false otherwise
|
||||
*/
|
||||
boolean addStorage(IStorage<T> storage);
|
||||
}
|
||||
|
@@ -3,17 +3,19 @@ package com.raoulvdberge.refinedstorage.api.storage;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Represents a node that provides the network with storage.
|
||||
*/
|
||||
public interface IStorageProvider {
|
||||
/**
|
||||
* @param cache the storage cache
|
||||
* @param storages the item storages
|
||||
*/
|
||||
void addItemStorages(IStorageCache<ItemStack> cache);
|
||||
void addItemStorages(List<IStorage<ItemStack>> storages);
|
||||
|
||||
/**
|
||||
* @param cache the storage cache
|
||||
* @param storages the fluid storages
|
||||
*/
|
||||
void addFluidStorages(IStorageCache<FluidStack> cache);
|
||||
void addFluidStorages(List<IStorage<FluidStack>> storages);
|
||||
}
|
||||
|
@@ -162,12 +162,8 @@ public abstract class NetworkNode implements INetworkNode, INetworkNeighborhoodA
|
||||
}
|
||||
}
|
||||
|
||||
public BlockPos getFacingTilePosition() {
|
||||
return holder.pos().offset(holder.getDirection());
|
||||
}
|
||||
|
||||
public TileEntity getFacingTile() {
|
||||
return holder.world().getTileEntity(getFacingTilePosition());
|
||||
return holder.world().getTileEntity(holder.pos().offset(holder.getDirection()));
|
||||
}
|
||||
|
||||
public IItemHandler getDrops() {
|
||||
|
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageDiskFluid;
|
||||
@@ -22,6 +22,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage, IStorageProvider, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
|
||||
public static final String ID = "fluid_storage";
|
||||
@@ -117,14 +118,14 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemStorages(IStorageCache<ItemStack> cache) {
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(IStorageCache<FluidStack> cache) {
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
if (storage != null) {
|
||||
cache.addStorage(storage);
|
||||
storages.add(storage);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import com.raoulvdberge.refinedstorage.RSBlocks;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.storage.StorageDiskItem;
|
||||
@@ -22,6 +22,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, IStorageProvider, IComparable, IFilterable, IPrioritizable, IExcessVoidable, IAccessType {
|
||||
public static final String ID = "storage";
|
||||
@@ -114,14 +115,12 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemStorages(IStorageCache<ItemStack> cache) {
|
||||
if (storage != null) {
|
||||
cache.addStorage(storage);
|
||||
}
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
storages.add(storage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(IStorageCache<FluidStack> cache) {
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,7 @@ import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IStorageProvider, IComparable, IFilterable, IPrioritizable, IType, IExcessVoidable, IAccessType {
|
||||
@@ -75,8 +76,8 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
||||
private ItemHandlerBase itemFilters = new ItemHandlerBase(9, new ItemHandlerListenerNetworkNode(this));
|
||||
private ItemHandlerFluid fluidFilters = new ItemHandlerFluid(9, new ItemHandlerListenerNetworkNode(this));
|
||||
|
||||
private IStorageDisk<ItemStack>[] itemStorages = new IStorageDisk[8];
|
||||
private IStorageDisk<FluidStack>[] fluidStorages = new IStorageDisk[8];
|
||||
private IStorageDisk[] itemStorages = new IStorageDisk[8];
|
||||
private IStorageDisk[] fluidStorages = new IStorageDisk[8];
|
||||
|
||||
private AccessType accessType = AccessType.INSERT_EXTRACT;
|
||||
private int priority = 0;
|
||||
@@ -135,19 +136,19 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemStorages(IStorageCache<ItemStack> cache) {
|
||||
for (IStorage<ItemStack> storage : itemStorages) {
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
for (IStorage<ItemStack> storage : this.itemStorages) {
|
||||
if (storage != null) {
|
||||
cache.addStorage(storage);
|
||||
storages.add(storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(IStorageCache<FluidStack> cache) {
|
||||
for (IStorage<FluidStack> storage : fluidStorages) {
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
for (IStorage<FluidStack> storage : this.fluidStorages) {
|
||||
if (storage != null) {
|
||||
cache.addStorage(storage);
|
||||
storages.add(storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageCache;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageProvider;
|
||||
import com.raoulvdberge.refinedstorage.api.util.IComparer;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.IGuiStorage;
|
||||
@@ -229,13 +229,13 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItemStorages(IStorageCache<ItemStack> cache) {
|
||||
itemStorages.removeIf(storage -> !cache.addStorage(storage));
|
||||
public void addItemStorages(List<IStorage<ItemStack>> storages) {
|
||||
storages.addAll(this.itemStorages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addFluidStorages(IStorageCache<FluidStack> cache) {
|
||||
fluidStorages.removeIf(storage -> !cache.addStorage(storage));
|
||||
public void addFluidStorages(List<IStorage<FluidStack>> storages) {
|
||||
storages.addAll(this.fluidStorages);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -120,9 +120,4 @@ public class StorageFluidExternal implements IStorage<FluidStack> {
|
||||
public void updateCacheForcefully() {
|
||||
cache = RSUtils.copyStack(getContents());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof StorageFluidExternal && externalStorage.getFacingTilePosition().equals(((StorageFluidExternal) o).externalStorage.getFacingTilePosition());
|
||||
}
|
||||
}
|
||||
|
@@ -22,13 +22,13 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class StorageItemCyclops extends StorageItemExternal {
|
||||
private NetworkNodeExternalStorage externalStorage;
|
||||
private EnumFacing opposite;
|
||||
private Supplier<InventoryTileEntityBase> cyclopsInv;
|
||||
private int oldInventoryHash = -1;
|
||||
|
||||
public StorageItemCyclops(NetworkNodeExternalStorage externalStorage) {
|
||||
super(externalStorage);
|
||||
|
||||
this.externalStorage = externalStorage;
|
||||
this.opposite = externalStorage.getHolder().getDirection().getOpposite();
|
||||
this.cyclopsInv = () -> {
|
||||
TileEntity f = externalStorage.getFacingTile();
|
||||
@@ -40,7 +40,6 @@ public class StorageItemCyclops extends StorageItemExternal {
|
||||
@Override
|
||||
public void detectChanges(INetworkMaster network) {
|
||||
InventoryTileEntityBase inv = cyclopsInv.get();
|
||||
|
||||
if (inv != null) {
|
||||
int inventoryHash = inv.getInventoryHash();
|
||||
|
||||
@@ -119,9 +118,9 @@ public class StorageItemCyclops extends StorageItemExternal {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isValid(TileEntity facingTile, EnumFacing facing) {
|
||||
return facingTile instanceof InventoryTileEntityBase
|
||||
&& (SlotlessItemHandlerHelper.isSlotless(facingTile, facing)
|
||||
|| ((InventoryTileEntityBase) facingTile).getInventory() instanceof SimpleInventory);
|
||||
public static boolean isValid(TileEntity facingTE, EnumFacing facing) {
|
||||
return facingTE instanceof InventoryTileEntityBase
|
||||
&& (SlotlessItemHandlerHelper.isSlotless(facingTE, facing)
|
||||
|| ((InventoryTileEntityBase) facingTE).getInventory() instanceof SimpleInventory);
|
||||
}
|
||||
}
|
||||
|
@@ -15,11 +15,11 @@ import java.util.Collections;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageItemDrawer extends StorageItemExternal {
|
||||
private NetworkNodeExternalStorage externalStorage;
|
||||
private Supplier<IDrawer> drawerSupplier;
|
||||
|
||||
public StorageItemDrawer(NetworkNodeExternalStorage externalStorage, Supplier<IDrawer> drawerSupplier) {
|
||||
super(externalStorage);
|
||||
|
||||
this.externalStorage = externalStorage;
|
||||
this.drawerSupplier = drawerSupplier;
|
||||
}
|
||||
|
||||
|
@@ -14,11 +14,11 @@ import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageItemDrawerGroup extends StorageItemExternal {
|
||||
private NetworkNodeExternalStorage externalStorage;
|
||||
private Supplier<IDrawerGroup> groupSupplier;
|
||||
|
||||
public StorageItemDrawerGroup(NetworkNodeExternalStorage externalStorage, Supplier<IDrawerGroup> groupSupplier) {
|
||||
super(externalStorage);
|
||||
|
||||
this.externalStorage = externalStorage;
|
||||
this.groupSupplier = groupSupplier;
|
||||
}
|
||||
|
||||
|
@@ -11,13 +11,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class StorageItemExternal implements IStorage<ItemStack> {
|
||||
protected NetworkNodeExternalStorage externalStorage;
|
||||
private List<ItemStack> cache;
|
||||
|
||||
public StorageItemExternal(NetworkNodeExternalStorage externalStorage) {
|
||||
this.externalStorage = externalStorage;
|
||||
}
|
||||
|
||||
public abstract int getCapacity();
|
||||
|
||||
public void detectChanges(INetworkMaster network) {
|
||||
@@ -94,9 +89,4 @@ public abstract class StorageItemExternal implements IStorage<ItemStack> {
|
||||
public int getCacheDelta(int storedPreInsertion, int size, @Nullable ItemStack remainder) {
|
||||
return remainder == null ? size : (size - remainder.getCount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return o instanceof StorageItemExternal && externalStorage.getFacingTilePosition().equals(((StorageItemExternal) o).externalStorage.getFacingTilePosition());
|
||||
}
|
||||
}
|
||||
|
@@ -16,12 +16,12 @@ import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageItemItemHandler extends StorageItemExternal {
|
||||
private NetworkNodeExternalStorage externalStorage;
|
||||
private Supplier<IItemHandler> handlerSupplier;
|
||||
private AccessType lockedAccessType = AccessType.INSERT_EXTRACT;
|
||||
|
||||
public StorageItemItemHandler(NetworkNodeExternalStorage externalStorage, Supplier<IItemHandler> handlerSupplier) {
|
||||
super(externalStorage);
|
||||
|
||||
this.externalStorage = externalStorage;
|
||||
this.handlerSupplier = handlerSupplier;
|
||||
|
||||
if (externalStorage.getFacingTile().getBlockType().getUnlocalizedName().equals("tile.ExtraUtils2:TrashCan")) {
|
||||
|
@@ -27,11 +27,9 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
public synchronized void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph()
|
||||
.all()
|
||||
.stream()
|
||||
network.getNodeGraph().all().stream()
|
||||
.filter(node -> node.canUpdate() && node instanceof IStorageProvider)
|
||||
.forEach(node -> ((IStorageProvider) node).addFluidStorages(this));
|
||||
.forEach(node -> ((IStorageProvider) node).addFluidStorages(storages));
|
||||
|
||||
list.clear();
|
||||
|
||||
@@ -80,9 +78,4 @@ public class StorageCacheFluid implements IStorageCache<FluidStack> {
|
||||
public List<IStorage<FluidStack>> getStorages() {
|
||||
return storages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addStorage(IStorage<FluidStack> storage) {
|
||||
return !storages.contains(storage) && storages.add(storage);
|
||||
}
|
||||
}
|
||||
|
@@ -27,11 +27,9 @@ public class StorageCacheItem implements IStorageCache<ItemStack> {
|
||||
public synchronized void invalidate() {
|
||||
storages.clear();
|
||||
|
||||
network.getNodeGraph()
|
||||
.all()
|
||||
.stream()
|
||||
network.getNodeGraph().all().stream()
|
||||
.filter(node -> node.canUpdate() && node instanceof IStorageProvider)
|
||||
.forEach(node -> ((IStorageProvider) node).addItemStorages(this));
|
||||
.forEach(node -> ((IStorageProvider) node).addItemStorages(storages));
|
||||
|
||||
list.clear();
|
||||
|
||||
@@ -82,9 +80,4 @@ public class StorageCacheItem implements IStorageCache<ItemStack> {
|
||||
public List<IStorage<ItemStack>> getStorages() {
|
||||
return storages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addStorage(IStorage<ItemStack> storage) {
|
||||
return !storages.contains(storage) && storages.add(storage);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user