Fixed using Interfaces for minimum stock levels failing when requester is also an Interface. Fixes #1575

This commit is contained in:
raoulvdberge
2018-07-15 16:00:52 +02:00
parent 6fea7b4bc2
commit bc5fb1f58b
2 changed files with 27 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ NOTE: Worlds that used Refined Storage 1.5.x are fully compatible with Refined S
- Fixed bug where item storage tracker didn't save sometimes (raoulvdberge) - Fixed bug where item storage tracker didn't save sometimes (raoulvdberge)
- Fixed bug where External Storage doesn't detect new inventory when rotating (raoulvdberge) - Fixed bug where External Storage doesn't detect new inventory when rotating (raoulvdberge)
- Fixed JEI recipe transferring in Pattern Grid allowing non-processing recipes in processing mode and vice-versa (raoulvdberge) - Fixed JEI recipe transferring in Pattern Grid allowing non-processing recipes in processing mode and vice-versa (raoulvdberge)
- Fixed using Interfaces for minimum stock levels failing when requester is also an Interface (raoulvdberge)
- Prevent accidental Grid scrollbar click after clicking JEI recipe transfer button (raoulvdberge) - Prevent accidental Grid scrollbar click after clicking JEI recipe transfer button (raoulvdberge)
- Added a missing config option for Crafter Manager energy usage (raoulvdberge) - Added a missing config option for Crafter Manager energy usage (raoulvdberge)
- Added support for Disk Drive / Storage Block storage and capacity to OC integration (zangai) - Added support for Disk Drive / Storage Block storage and capacity to OC integration (zangai)

View File

@@ -1,6 +1,7 @@
package com.raoulvdberge.refinedstorage.apiimpl.network.node; package com.raoulvdberge.refinedstorage.apiimpl.network.node;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import com.raoulvdberge.refinedstorage.api.util.Action; import com.raoulvdberge.refinedstorage.api.util.Action;
import com.raoulvdberge.refinedstorage.api.util.IComparer; import com.raoulvdberge.refinedstorage.api.util.IComparer;
import com.raoulvdberge.refinedstorage.apiimpl.API; import com.raoulvdberge.refinedstorage.apiimpl.API;
@@ -14,6 +15,7 @@ import com.raoulvdberge.refinedstorage.tile.config.IComparable;
import com.raoulvdberge.refinedstorage.util.StackUtils; import com.raoulvdberge.refinedstorage.util.StackUtils;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
@@ -90,7 +92,18 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
int delta = got.isEmpty() ? wanted.getCount() : (wanted.getCount() - got.getCount()); int delta = got.isEmpty() ? wanted.getCount() : (wanted.getCount() - got.getCount());
if (delta > 0) { if (delta > 0) {
ItemStack result = network.extractItem(wanted, delta, compare, Action.PERFORM, s -> !(s instanceof StorageExternalItem) || !((StorageExternalItem) s).isConnectedToInterface()); final boolean actingAsStorage = isActingAsStorage();
ItemStack result = network.extractItem(wanted, delta, compare, Action.PERFORM, s -> {
// If we are not an interface acting as a storage, we can extract from anywhere.
if (!actingAsStorage) {
return true;
}
// If we are an interface acting as a storage, we don't want to extract from other interfaces to
// avoid stealing from each other.
return !(s instanceof StorageExternalItem) || !((StorageExternalItem) s).isConnectedToInterface();
});
if (result != null) { if (result != null) {
if (exportItems.getStackInSlot(i).isEmpty()) { if (exportItems.getStackInSlot(i).isEmpty()) {
@@ -120,6 +133,18 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
} }
} }
private boolean isActingAsStorage() {
for (EnumFacing facing : EnumFacing.VALUES) {
INetworkNode facingNode = API.instance().getNetworkNodeManager(world).getNode(pos.offset(facing));
if (facingNode instanceof NetworkNodeExternalStorage && facingNode.canUpdate() && ((NetworkNodeExternalStorage) facingNode).getDirection() == facing.getOpposite()) {
return true;
}
}
return false;
}
@Override @Override
public int getCompare() { public int getCompare() {
return compare; return compare;