Fixed bug where disks in Disk Drive didn't respect access type or void excess stacks option
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
### 1.4.3
|
||||
- Storage Monitors don't render any quantity text when no item is specified to monitor anymore (raoulvdberge)
|
||||
- The Solderer isn't sided anymore (raoulvdberge)
|
||||
- Fixed bug where disks in Disk Drive didn't respect access type or void excess stacks option (raoulvdberge)
|
||||
- The Solderer inventory isn't sided anymore (raoulvdberge)
|
||||
|
||||
### 1.4.2
|
||||
- Updated Forge to 2261 (raoulvdberge)
|
||||
|
@@ -117,7 +117,7 @@ public final class RSUtils {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void createStorages(ItemStack disk, int slot, IStorageDisk<ItemStack>[] itemStorages, IStorageDisk<FluidStack>[] fluidStorages, Function<IStorageDisk, IStorageDisk> itemStorageWrapper, Function<IStorageDisk, IStorageDisk> fluidStorageWrapper) {
|
||||
public static void createStorages(ItemStack disk, int slot, IStorageDisk<ItemStack>[] itemStorages, IStorageDisk<FluidStack>[] fluidStorages, Function<IStorageDisk<ItemStack>, IStorageDisk> itemStorageWrapper, Function<IStorageDisk<FluidStack>, IStorageDisk> fluidStorageWrapper) {
|
||||
if (disk.isEmpty()) {
|
||||
itemStorages[slot] = null;
|
||||
fluidStorages[slot] = null;
|
||||
|
@@ -50,9 +50,7 @@ public interface IStorage<T> {
|
||||
/**
|
||||
* @return the access type of this storage
|
||||
*/
|
||||
default AccessType getAccessType() {
|
||||
return AccessType.INSERT_EXTRACT;
|
||||
}
|
||||
AccessType getAccessType();
|
||||
|
||||
/**
|
||||
* Returns the delta that needs to be added to the item or fluid storage cache AFTER insertion of the stack.
|
||||
|
@@ -2,6 +2,8 @@ package com.raoulvdberge.refinedstorage.api.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Represents a storage disk.
|
||||
*
|
||||
@@ -13,11 +15,6 @@ public interface IStorageDisk<T> extends IStorage<T> {
|
||||
*/
|
||||
int getCapacity();
|
||||
|
||||
/**
|
||||
* @return whether this storage voids excess stacks
|
||||
*/
|
||||
boolean isVoiding();
|
||||
|
||||
/**
|
||||
* Returns whether the storage disk is valid.
|
||||
* Determines if it can be inserted in a disk drive.
|
||||
@@ -28,11 +25,14 @@ public interface IStorageDisk<T> extends IStorage<T> {
|
||||
boolean isValid(ItemStack stack);
|
||||
|
||||
/**
|
||||
* Sets a listener that is called when the storage changes.
|
||||
* When this storage disk is inserted into a storage disk container, it has to adjust to the container's settings
|
||||
* and use the following parameters instead.
|
||||
*
|
||||
* @param listener the listener
|
||||
* @param listener the listener to be called when the storage changes
|
||||
* @param voidExcess a supplier whether this storage should void excess stacks
|
||||
* @param accessType the access type of the container
|
||||
*/
|
||||
void setListener(Runnable listener);
|
||||
void onPassContainerContext(Runnable listener, Supplier<Boolean> voidExcess, Supplier<AccessType> accessType);
|
||||
|
||||
/**
|
||||
* Reads the storage from NBT.
|
||||
|
@@ -28,10 +28,14 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
public static final String ID = "fluid_storage";
|
||||
|
||||
class StorageFluid extends StorageDiskFluid {
|
||||
public StorageFluid(NBTTagCompound tag) {
|
||||
StorageFluid(NBTTagCompound tag) {
|
||||
super(tag, NetworkNodeFluidStorage.this.getCapacity());
|
||||
|
||||
this.setListener(NetworkNodeFluidStorage.this::markDirty);
|
||||
this.onPassContainerContext(
|
||||
NetworkNodeFluidStorage.this::markDirty,
|
||||
NetworkNodeFluidStorage.this::getVoidExcess,
|
||||
NetworkNodeFluidStorage.this::getAccessType
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,16 +52,6 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
|
||||
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return voidExcess;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String NBT_STORAGE = "Storage";
|
||||
|
@@ -28,10 +28,14 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
public static final String ID = "storage";
|
||||
|
||||
class StorageItem extends StorageDiskItem {
|
||||
public StorageItem(NBTTagCompound tag) {
|
||||
StorageItem(NBTTagCompound tag) {
|
||||
super(tag, NetworkNodeStorage.this.getCapacity());
|
||||
|
||||
this.setListener(NetworkNodeStorage.this::markDirty);
|
||||
this.onPassContainerContext(
|
||||
NetworkNodeStorage.this::markDirty,
|
||||
NetworkNodeStorage.this::getVoidExcess,
|
||||
NetworkNodeStorage.this::getAccessType
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,16 +51,6 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
|
||||
|
||||
return super.insert(stack, size, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return accessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return voidExcess;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String NBT_STORAGE = "Storage";
|
||||
|
@@ -12,6 +12,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageFluidDiskDrive implements IStorageDisk<FluidStack> {
|
||||
private NetworkNodeDiskDrive diskDrive;
|
||||
@@ -21,17 +22,21 @@ public class StorageFluidDiskDrive implements IStorageDisk<FluidStack> {
|
||||
public StorageFluidDiskDrive(NetworkNodeDiskDrive diskDrive, IStorageDisk<FluidStack> parent) {
|
||||
this.diskDrive = diskDrive;
|
||||
this.parent = parent;
|
||||
this.parent.setListener(() -> {
|
||||
diskDrive.markDirty();
|
||||
this.onPassContainerContext(
|
||||
() -> {
|
||||
diskDrive.markDirty();
|
||||
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
|
||||
RSUtils.updateBlock(diskDrive.getHolder().world(), diskDrive.getHolder().pos());
|
||||
}
|
||||
});
|
||||
RSUtils.updateBlock(diskDrive.getHolder().world(), diskDrive.getHolder().pos());
|
||||
}
|
||||
},
|
||||
diskDrive::getVoidExcess,
|
||||
diskDrive::getAccessType
|
||||
);
|
||||
this.lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
}
|
||||
|
||||
@@ -40,6 +45,11 @@ public class StorageFluidDiskDrive implements IStorageDisk<FluidStack> {
|
||||
return diskDrive.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return parent.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<FluidStack> getStacks() {
|
||||
return parent.getStacks();
|
||||
@@ -66,11 +76,6 @@ public class StorageFluidDiskDrive implements IStorageDisk<FluidStack> {
|
||||
return parent.getStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return diskDrive.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCacheDelta(int storedPreInsertion, int size, @Nullable FluidStack remainder) {
|
||||
return parent.getCacheDelta(storedPreInsertion, size, remainder);
|
||||
@@ -81,19 +86,14 @@ public class StorageFluidDiskDrive implements IStorageDisk<FluidStack> {
|
||||
return parent.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return diskDrive.getVoidExcess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
return parent.isValid(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(Runnable listener) {
|
||||
// NO OP
|
||||
public void onPassContainerContext(Runnable listener, Supplier<Boolean> voidExcess, Supplier<AccessType> accessType) {
|
||||
parent.onPassContainerContext(listener, voidExcess, accessType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -12,6 +12,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageItemDiskDrive implements IStorageDisk<ItemStack> {
|
||||
private NetworkNodeDiskDrive diskDrive;
|
||||
@@ -21,17 +22,21 @@ public class StorageItemDiskDrive implements IStorageDisk<ItemStack> {
|
||||
public StorageItemDiskDrive(NetworkNodeDiskDrive diskDrive, IStorageDisk<ItemStack> parent) {
|
||||
this.diskDrive = diskDrive;
|
||||
this.parent = parent;
|
||||
this.parent.setListener(() -> {
|
||||
diskDrive.markDirty();
|
||||
this.onPassContainerContext(
|
||||
() -> {
|
||||
diskDrive.markDirty();
|
||||
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
|
||||
RSUtils.updateBlock(diskDrive.getHolder().world(), diskDrive.getHolder().pos());
|
||||
}
|
||||
});
|
||||
RSUtils.updateBlock(diskDrive.getHolder().world(), diskDrive.getHolder().pos());
|
||||
}
|
||||
},
|
||||
diskDrive::getVoidExcess,
|
||||
diskDrive::getAccessType
|
||||
);
|
||||
this.lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
}
|
||||
|
||||
@@ -40,6 +45,11 @@ public class StorageItemDiskDrive implements IStorageDisk<ItemStack> {
|
||||
return diskDrive.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return parent.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ItemStack> getStacks() {
|
||||
return parent.getStacks();
|
||||
@@ -66,11 +76,6 @@ public class StorageItemDiskDrive implements IStorageDisk<ItemStack> {
|
||||
return parent.getStored();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return diskDrive.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCacheDelta(int storedPreInsertion, int size, @Nullable ItemStack remainder) {
|
||||
return parent.getCacheDelta(storedPreInsertion, size, remainder);
|
||||
@@ -81,19 +86,14 @@ public class StorageItemDiskDrive implements IStorageDisk<ItemStack> {
|
||||
return parent.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return diskDrive.getVoidExcess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
return parent.isValid(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(Runnable listener) {
|
||||
// NO OP
|
||||
public void onPassContainerContext(Runnable listener, Supplier<Boolean> voidExcess, Supplier<AccessType> accessType) {
|
||||
parent.onPassContainerContext(listener, voidExcess, accessType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node.diskmanipulator;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.StorageDiskType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
|
||||
@@ -11,6 +12,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageFluidDiskManipulator implements IStorageDisk<FluidStack> {
|
||||
private NetworkNodeDiskManipulator diskManipulator;
|
||||
@@ -20,17 +22,21 @@ public class StorageFluidDiskManipulator implements IStorageDisk<FluidStack> {
|
||||
public StorageFluidDiskManipulator(NetworkNodeDiskManipulator diskManipulator, IStorageDisk<FluidStack> parent) {
|
||||
this.diskManipulator = diskManipulator;
|
||||
this.parent = parent;
|
||||
this.parent.setListener(() -> {
|
||||
diskManipulator.markDirty();
|
||||
this.onPassContainerContext(
|
||||
() -> {
|
||||
diskManipulator.markDirty();
|
||||
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
|
||||
RSUtils.updateBlock(diskManipulator.getHolder().world(), diskManipulator.getHolder().pos());
|
||||
}
|
||||
});
|
||||
RSUtils.updateBlock(diskManipulator.getHolder().world(), diskManipulator.getHolder().pos());
|
||||
}
|
||||
},
|
||||
() -> false,
|
||||
() -> AccessType.INSERT_EXTRACT
|
||||
);
|
||||
this.lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
}
|
||||
|
||||
@@ -39,19 +45,14 @@ public class StorageFluidDiskManipulator implements IStorageDisk<FluidStack> {
|
||||
return parent.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return parent.isVoiding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
return parent.isValid(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(Runnable listener) {
|
||||
// NO OP
|
||||
public void onPassContainerContext(Runnable listener, Supplier<Boolean> voidExcess, Supplier<AccessType> accessType) {
|
||||
parent.onPassContainerContext(listener, voidExcess, accessType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +105,11 @@ public class StorageFluidDiskManipulator implements IStorageDisk<FluidStack> {
|
||||
return parent.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return parent.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCacheDelta(int storedPreInsertion, int size, @Nullable FluidStack remainder) {
|
||||
return parent.getCacheDelta(storedPreInsertion, size, remainder);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.raoulvdberge.refinedstorage.apiimpl.network.node.diskmanipulator;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.StorageDiskType;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileDiskDrive;
|
||||
@@ -11,6 +12,7 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageItemDiskManipulator implements IStorageDisk<ItemStack> {
|
||||
private NetworkNodeDiskManipulator diskManipulator;
|
||||
@@ -20,17 +22,21 @@ public class StorageItemDiskManipulator implements IStorageDisk<ItemStack> {
|
||||
public StorageItemDiskManipulator(NetworkNodeDiskManipulator diskManipulator, IStorageDisk<ItemStack> parent) {
|
||||
this.diskManipulator = diskManipulator;
|
||||
this.parent = parent;
|
||||
this.parent.setListener(() -> {
|
||||
diskManipulator.markDirty();
|
||||
this.onPassContainerContext(
|
||||
() -> {
|
||||
diskManipulator.markDirty();
|
||||
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
int currentState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
if (lastState != currentState) {
|
||||
lastState = currentState;
|
||||
|
||||
RSUtils.updateBlock(diskManipulator.getHolder().world(), diskManipulator.getHolder().pos());
|
||||
}
|
||||
});
|
||||
RSUtils.updateBlock(diskManipulator.getHolder().world(), diskManipulator.getHolder().pos());
|
||||
}
|
||||
},
|
||||
() -> false,
|
||||
() -> AccessType.INSERT_EXTRACT
|
||||
);
|
||||
this.lastState = TileDiskDrive.getDiskState(getStored(), getCapacity());
|
||||
}
|
||||
|
||||
@@ -39,19 +45,14 @@ public class StorageItemDiskManipulator implements IStorageDisk<ItemStack> {
|
||||
return parent.getCapacity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return parent.isVoiding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid(ItemStack stack) {
|
||||
return parent.isValid(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(Runnable listener) {
|
||||
// NO OP
|
||||
public void onPassContainerContext(Runnable listener, Supplier<Boolean> voidExcess, Supplier<AccessType> accessType) {
|
||||
parent.onPassContainerContext(listener, voidExcess, accessType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,6 +105,11 @@ public class StorageItemDiskManipulator implements IStorageDisk<ItemStack> {
|
||||
return parent.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return parent.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCacheDelta(int storedPreInsertion, int size, @Nullable ItemStack remainder) {
|
||||
return parent.getCacheDelta(storedPreInsertion, size, remainder);
|
||||
|
@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.node.externalstorage;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.integration.cyclopscore.SlotlessItemHandlerHelper;
|
||||
import com.raoulvdberge.refinedstorage.tile.config.IFilterable;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -65,6 +66,11 @@ public class StorageItemCyclops extends StorageItemExternal {
|
||||
return this.externalStorage.getPriority();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessType getAccessType() {
|
||||
return this.externalStorage.getAccessType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
InventoryTileEntityBase inv = cyclopsInv.get();
|
||||
|
@@ -16,6 +16,7 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
private static final int PROTOCOL = 1;
|
||||
@@ -32,6 +33,8 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
|
||||
private Runnable listener = () -> {
|
||||
};
|
||||
private Supplier<Boolean> voidExcess;
|
||||
private Supplier<AccessType> accessType;
|
||||
|
||||
public StorageDiskFluid(NBTTagCompound tag, int capacity) {
|
||||
this.tag = tag;
|
||||
@@ -86,7 +89,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
int remainingSpace = getCapacity() - getStored();
|
||||
|
||||
if (remainingSpace <= 0) {
|
||||
if (isVoiding()) {
|
||||
if (voidExcess.get()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -101,7 +104,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
listener.run();
|
||||
}
|
||||
|
||||
return isVoiding() ? null : RSUtils.copyStackWithSize(otherStack, size - remainingSpace);
|
||||
return voidExcess.get() ? null : RSUtils.copyStackWithSize(otherStack, size - remainingSpace);
|
||||
} else {
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + size);
|
||||
@@ -120,7 +123,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
int remainingSpace = getCapacity() - getStored();
|
||||
|
||||
if (remainingSpace <= 0) {
|
||||
if (isVoiding()) {
|
||||
if (voidExcess.get()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -135,7 +138,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
listener.run();
|
||||
}
|
||||
|
||||
return isVoiding() ? null : RSUtils.copyStackWithSize(stack, size - remainingSpace);
|
||||
return voidExcess.get() ? null : RSUtils.copyStackWithSize(stack, size - remainingSpace);
|
||||
} else {
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + size);
|
||||
@@ -188,13 +191,13 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
public AccessType getAccessType() {
|
||||
return accessType.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return false;
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,7 +208,7 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
|
||||
int inserted = remainder == null ? size : (size - remainder.amount);
|
||||
|
||||
if (isVoiding() && storedPreInsertion + inserted > getCapacity()) {
|
||||
if (voidExcess.get() && storedPreInsertion + inserted > getCapacity()) {
|
||||
inserted = getCapacity() - storedPreInsertion;
|
||||
}
|
||||
|
||||
@@ -218,8 +221,10 @@ public class StorageDiskFluid implements IStorageDisk<FluidStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(Runnable listener) {
|
||||
public void onPassContainerContext(Runnable listener, Supplier<Boolean> voidExcess, Supplier<AccessType> accessType) {
|
||||
this.listener = listener;
|
||||
this.voidExcess = voidExcess;
|
||||
this.accessType = accessType;
|
||||
}
|
||||
|
||||
public static NBTTagCompound getShareTag(NBTTagCompound tag) {
|
||||
|
@@ -3,7 +3,6 @@ package com.raoulvdberge.refinedstorage.apiimpl.storage;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.AccessType;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorage;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.IStorageDisk;
|
||||
import com.raoulvdberge.refinedstorage.api.storage.StorageDiskType;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
@@ -16,10 +15,8 @@ import net.minecraftforge.items.ItemHandlerHelper;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Collection;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* A implementation of {@link IStorage<ItemStack>} that stores storage items in NBT.
|
||||
*/
|
||||
public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
private static final int PROTOCOL = 1;
|
||||
|
||||
@@ -39,13 +36,11 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
|
||||
private Runnable listener = () -> {
|
||||
};
|
||||
private Supplier<Boolean> voidExcess;
|
||||
private Supplier<AccessType> accessType;
|
||||
|
||||
private Multimap<Item, ItemStack> stacks = ArrayListMultimap.create();
|
||||
|
||||
/**
|
||||
* @param tag The NBT tag we are reading from and writing the amount stored to, has to be initialized with {@link StorageDiskItem#getTag()} if it doesn't exist yet
|
||||
* @param capacity The capacity of this storage, -1 for infinite capacity
|
||||
*/
|
||||
public StorageDiskItem(NBTTagCompound tag, int capacity) {
|
||||
this.tag = tag;
|
||||
this.capacity = capacity;
|
||||
@@ -129,7 +124,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
int remainingSpace = getCapacity() - getStored();
|
||||
|
||||
if (remainingSpace <= 0) {
|
||||
if (isVoiding()) {
|
||||
if (voidExcess.get()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -144,7 +139,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
listener.run();
|
||||
}
|
||||
|
||||
return isVoiding() ? null : ItemHandlerHelper.copyStackWithSize(otherStack, size - remainingSpace);
|
||||
return voidExcess.get() ? null : ItemHandlerHelper.copyStackWithSize(otherStack, size - remainingSpace);
|
||||
} else {
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + size);
|
||||
@@ -163,7 +158,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
int remainingSpace = getCapacity() - getStored();
|
||||
|
||||
if (remainingSpace <= 0) {
|
||||
if (isVoiding()) {
|
||||
if (voidExcess.get()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -178,7 +173,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
listener.run();
|
||||
}
|
||||
|
||||
return isVoiding() ? null : ItemHandlerHelper.copyStackWithSize(stack, size - remainingSpace);
|
||||
return voidExcess.get() ? null : ItemHandlerHelper.copyStackWithSize(stack, size - remainingSpace);
|
||||
} else {
|
||||
if (!simulate) {
|
||||
tag.setInteger(NBT_STORED, getStored() + size);
|
||||
@@ -231,13 +226,13 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
public AccessType getAccessType() {
|
||||
return accessType.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoiding() {
|
||||
return false;
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -246,8 +241,10 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setListener(Runnable listener) {
|
||||
public void onPassContainerContext(Runnable listener, Supplier<Boolean> voidExcess, Supplier<AccessType> accessType) {
|
||||
this.listener = listener;
|
||||
this.voidExcess = voidExcess;
|
||||
this.accessType = accessType;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,7 +255,7 @@ public class StorageDiskItem implements IStorageDisk<ItemStack> {
|
||||
|
||||
int inserted = remainder == null ? size : (size - remainder.getCount());
|
||||
|
||||
if (isVoiding() && storedPreInsertion + inserted > getCapacity()) {
|
||||
if (voidExcess.get() && storedPreInsertion + inserted > getCapacity()) {
|
||||
inserted = getCapacity() - storedPreInsertion;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user