Skip to content

Commit

Permalink
Fix #1583
Browse files Browse the repository at this point in the history
  • Loading branch information
josephcsible committed Nov 22, 2018
1 parent 8112ca6 commit 1b476ea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
7.59:
- Joseph fixed the storage scanner double-counting the contents of double chests.

7.58:
- This release requires that you also upgrade all other mods that add screen modules (RFTools Control, RFTools Dimensions, Deep Resonance)
- Fully fixed the bug where the screen block could let players set arbitrary NBT on items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,14 +682,18 @@ public Stream<BlockPos> findInventories() {
// First remove all inventories that are either out of range or no longer an inventory:
List<BlockPos> old = inventories;
Set<BlockPos> oldAdded = new HashSet<>();
Set<IItemHandler> seenItemHandlers = new HashSet<>();
inventories = new ArrayList<>();

for (BlockPos p : old) {
if (xnetAccess.containsKey(p) || inRange(p)) {
TileEntity te = getWorld().getTileEntity(p);
if (InventoryHelper.isInventory(te) && !(te instanceof StorageScannerTileEntity)) {
inventories.add(p);
oldAdded.add(p);
IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (handler == null || seenItemHandlers.add(handler)) {
inventories.add(p);
oldAdded.add(p);
}
}
}
}
Expand All @@ -699,12 +703,12 @@ public Stream<BlockPos> findInventories() {
for (int z = getPos().getZ() - radius; z <= getPos().getZ() + radius; z++) {
for (int y = getPos().getY() - radius; y <= getPos().getY() + radius; y++) {
BlockPos p = new BlockPos(x, y, z);
inventoryAddNew(oldAdded, p);
inventoryAddNew(oldAdded, seenItemHandlers, p);
}
}
}
for (BlockPos p : xnetAccess.keySet()) {
inventoryAddNew(oldAdded, p);
inventoryAddNew(oldAdded, seenItemHandlers, p);
inventoriesFromXNet.add(p);
}

Expand All @@ -716,12 +720,15 @@ public Stream<BlockPos> getAllInventories() {
.filter(this::isValid);
}

private void inventoryAddNew(Set<BlockPos> oldAdded, BlockPos p) {
private void inventoryAddNew(Set<BlockPos> oldAdded, Set<IItemHandler> seenItemHandlers, BlockPos p) {
if (!oldAdded.contains(p)) {
TileEntity te = getWorld().getTileEntity(p);
if (InventoryHelper.isInventory(te) && !(te instanceof StorageScannerTileEntity)) {
if (!inventories.contains(p)) {
inventories.add(p);
IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (handler == null || seenItemHandlers.add(handler)) {
inventories.add(p);
}
}
}
}
Expand Down

0 comments on commit 1b476ea

Please sign in to comment.