* Use mutable list to allow updates even when grid is inactive

I don't think this should happen but it does, so this makes it continue
silently instead of crashing.

Fix refinedmods/refinedstorage#2811

* Do not show updated items if there is no full inventory yet

* Ensure gridview list implementation is ArrayList

The update code relies on an indexed mutable list, so that should be
made explicit here.
This commit is contained in:
score
2021-01-30 21:16:28 +00:00
committed by GitHub
parent b0ed3bed4d
commit dc196b8993

View File

@@ -16,6 +16,7 @@ import java.util.stream.Stream;
public class GridViewImpl implements IGridView {
private final GridScreen screen;
private boolean canCraft;
private boolean active = false;
private final IGridSorter defaultSorter;
private final List<IGridSorter> sorters;
@@ -55,9 +56,11 @@ public class GridViewImpl implements IGridView {
this.stacks = map.values().stream()
.filter(getActiveFilters())
.sorted(getActiveSort())
.collect(Collectors.toList());
.collect(Collectors.toCollection(ArrayList::new));
this.active = true;
} else {
this.stacks = Collections.emptyList();
this.stacks = new ArrayList<>();
this.active = false;
}
this.screen.updateScrollbar();
@@ -111,6 +114,9 @@ public class GridViewImpl implements IGridView {
@Override
public void postChange(IGridStack stack, int delta) {
if (!this.active) {
return;
}
// COMMENT 1 (about this if check in general)
// Update the other id reference if needed.
// Taking a stack out - and then re-inserting it - gives the new stack a new ID