Forgot fluid voiding
This commit is contained in:
@@ -689,19 +689,27 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate) {
|
public FluidStack insertFluid(@Nonnull FluidStack stack, int size, boolean simulate) {
|
||||||
if (stack == null || fluidStorage.getStorages().isEmpty()) {
|
if (fluidStorage.getStorages().isEmpty()) {
|
||||||
return RSUtils.copyStackWithSize(stack, size);
|
return RSUtils.copyStackWithSize(stack, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
int orginalSize = size;
|
int originalSize = size;
|
||||||
AccessType accessType = AccessType.INSERT_EXTRACT;
|
AccessType accessType = AccessType.INSERT_EXTRACT;
|
||||||
FluidStack remainder = stack;
|
FluidStack remainder = stack;
|
||||||
|
|
||||||
|
int insertedToIgnore = 0;
|
||||||
|
|
||||||
for (IFluidStorage storage : this.fluidStorage.getStorages()) {
|
for (IFluidStorage storage : this.fluidStorage.getStorages()) {
|
||||||
accessType = storage.getAccessType();
|
accessType = storage.getAccessType();
|
||||||
|
|
||||||
if (accessType != AccessType.EXTRACT) {
|
if (accessType != AccessType.EXTRACT) {
|
||||||
remainder = storage.insertFluid(remainder, size, simulate);
|
remainder = storage.insertFluid(remainder, size, simulate);
|
||||||
|
|
||||||
|
if (remainder != null && storage.isVoiding() && !simulate) {
|
||||||
|
insertedToIgnore += remainder.amount;
|
||||||
|
|
||||||
|
remainder = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (storage instanceof FluidStorageExternal && !simulate) {
|
if (storage instanceof FluidStorageExternal && !simulate) {
|
||||||
@@ -715,20 +723,14 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the stack size of the remainder is negative, it means of the original size abs(remainder.amount) fluids have been voided
|
if (!simulate) {
|
||||||
int inserted;
|
int inserted = remainder == null ? originalSize : (originalSize - remainder.amount);
|
||||||
|
|
||||||
if (remainder == null) {
|
inserted -= insertedToIgnore;
|
||||||
inserted = orginalSize;
|
|
||||||
} else if (remainder.amount < 0) {
|
|
||||||
inserted = orginalSize + remainder.amount;
|
|
||||||
remainder = null;
|
|
||||||
} else {
|
|
||||||
inserted = orginalSize - remainder.amount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!simulate && inserted > 0 && accessType != AccessType.INSERT) {
|
if (inserted > 0 && accessType != AccessType.INSERT) {
|
||||||
fluidStorage.add(RSUtils.copyStackWithSize(stack, inserted), false);
|
fluidStorage.add(RSUtils.copyStackWithSize(stack, inserted), false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return remainder;
|
return remainder;
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ public class TileStorage extends TileNode implements IItemStorageProvider, IStor
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
public ItemStack insertItem(ItemStack stack, int size, boolean simulate) {
|
||||||
|
// @todo: this doesn't work with the item voiding system!
|
||||||
if (!IFilterable.canTake(filters, mode, compare, stack)) {
|
if (!IFilterable.canTake(filters, mode, compare, stack)) {
|
||||||
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
return ItemHandlerHelper.copyStackWithSize(stack, size);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user