Made all IO blocks have a blacklist instead of a whitelist by default. An empty blacklist now means: accept any item. An empty whitelist now means: don't accept any item (an empty whitelist USED to mean: accept any item).

This commit is contained in:
raoulvdberge
2018-06-01 19:55:04 +02:00
parent 423c1339ad
commit 3433f39698
9 changed files with 17 additions and 27 deletions

View File

@@ -59,7 +59,7 @@ public class NetworkNodeDestructor extends NetworkNode implements IComparable, I
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_SILK_TOUCH, ItemUpgrade.TYPE_FORTUNE_1, ItemUpgrade.TYPE_FORTUNE_2, ItemUpgrade.TYPE_FORTUNE_3);
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int mode = IFilterable.WHITELIST;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private boolean pickupItem = false;

View File

@@ -75,7 +75,7 @@ public class NetworkNodeFluidStorage extends NetworkNode implements IGuiStorage,
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int priority = 0;
private int compare = IComparer.COMPARE_NBT;
private int mode = IFilterable.WHITELIST;
private int mode = IFilterable.BLACKLIST;
private boolean voidExcess = false;
public NetworkNodeFluidStorage(World world, BlockPos pos) {

View File

@@ -37,7 +37,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
private ItemHandlerUpgrade upgrades = new ItemHandlerUpgrade(4, new ItemHandlerListenerNetworkNode(this), ItemUpgrade.TYPE_SPEED, ItemUpgrade.TYPE_STACK);
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int mode = IFilterable.WHITELIST;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private int currentSlot;

View File

@@ -74,7 +74,7 @@ public class NetworkNodeStorage extends NetworkNode implements IGuiStorage, ISto
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int priority = 0;
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int mode = IFilterable.WHITELIST;
private int mode = IFilterable.BLACKLIST;
private boolean voidExcess = false;
public NetworkNodeStorage(World world, BlockPos pos) {

View File

@@ -87,7 +87,7 @@ public class NetworkNodeDiskDrive extends NetworkNode implements IGuiStorage, IS
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int priority = 0;
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int mode = IFilterable.WHITELIST;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private boolean voidExcess = false;

View File

@@ -40,7 +40,7 @@ public class NetworkNodeDiskManipulator extends NetworkNode implements IComparab
private static final String NBT_IO_MODE = "IOMode";
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int mode = IFilterable.WHITELIST;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private int ioMode = IO_MODE_INSERT;

View File

@@ -45,7 +45,7 @@ public class NetworkNodeExternalStorage extends NetworkNode implements IStorageP
private int priority = 0;
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int mode = IFilterable.WHITELIST;
private int mode = IFilterable.BLACKLIST;
private int type = IType.ITEMS;
private AccessType accessType = AccessType.INSERT_EXTRACT;
private int networkTicks;

View File

@@ -22,29 +22,22 @@ public interface IFilterable {
});
}
// @todo: Change in 1.13 to be by default blacklist, and accept all on blacklist and none on whitelist when no filter is set
static boolean canTake(IItemHandler filters, int mode, int compare, ItemStack stack) {
if (mode == WHITELIST) {
int slots = 0;
for (int i = 0; i < filters.getSlots(); ++i) {
ItemStack slot = filters.getStackInSlot(i);
if (!slot.isEmpty()) {
slots++;
if (API.instance().getComparer().isEqual(slot, stack, compare)) {
return true;
}
if (API.instance().getComparer().isEqual(slot, stack, compare)) {
return true;
}
}
return slots == 0;
return false;
} else if (mode == BLACKLIST) {
for (int i = 0; i < filters.getSlots(); ++i) {
ItemStack slot = filters.getStackInSlot(i);
if (!slot.isEmpty() && API.instance().getComparer().isEqual(slot, stack, compare)) {
if (API.instance().getComparer().isEqual(slot, stack, compare)) {
return false;
}
}
@@ -57,21 +50,15 @@ public interface IFilterable {
static boolean canTakeFluids(ItemHandlerFluid filters, int mode, int compare, FluidStack stack) {
if (mode == WHITELIST) {
int slots = 0;
for (int i = 0; i < filters.getSlots(); ++i) {
FluidStack slot = filters.getFluidStackInSlot(i);
if (slot != null) {
slots++;
if (API.instance().getComparer().isEqual(slot, stack, compare)) {
return true;
}
if (slot != null && API.instance().getComparer().isEqual(slot, stack, compare)) {
return true;
}
}
return slots == 0;
return false;
} else if (mode == BLACKLIST) {
for (int i = 0; i < filters.getSlots(); ++i) {
FluidStack slot = filters.getFluidStackInSlot(i);
@@ -93,6 +80,7 @@ public interface IFilterable {
return false;
}
}
return true;
}