mirror of
https://github.com/GTNewHorizons/Applied-Energistics-2-Unofficial.git
synced 2026-11-28 07:55:57 +00:00
Lazily fill out the ItemList for network delta updates (#363)
* Lazily fill out the ItemList for network delta updates * Implement a new api for looking up a single stored item to optimize network monitor updates * Update buildscript * Add Nonnull annotation to the argument
This commit is contained in:
1 parent
b501e5596a
commit
e6ca9e36ef
28 files changed
+546
-74
No files matched your search
+9
-4
@@ -31,6 +31,7 @@ import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.me.storage.ItemWatcher;
|
||||
import appeng.util.item.LazyItemList;
|
||||
|
||||
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T> {
|
||||
|
||||
@@ -226,9 +227,13 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T> {
|
||||
this.notifyListenersOfChange(changes, src);
|
||||
|
||||
for (final T changedItem : changes) {
|
||||
if (changedItem == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
T difference = changedItem;
|
||||
|
||||
if (!add && changedItem != null) {
|
||||
if (!add) {
|
||||
difference = changedItem.copy();
|
||||
difference.setStackSize(-changedItem.getStackSize());
|
||||
}
|
||||
@@ -237,7 +242,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T> {
|
||||
final Collection<ItemWatcher> list = this.myGridCache.getInterestManager().get(changedItem);
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
IAEStack fullStack = this.getStorageList().findPrecise(changedItem);
|
||||
IAEStack<T> fullStack = this.getHandler().getAvailableItem(changedItem);
|
||||
|
||||
if (fullStack == null) {
|
||||
fullStack = changedItem.copy();
|
||||
@@ -246,9 +251,9 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T> {
|
||||
|
||||
this.myGridCache.getInterestManager().enableTransactions();
|
||||
|
||||
IItemList<T> itemList = new LazyItemList<>(this::getStorageList);
|
||||
for (final ItemWatcher iw : list) {
|
||||
iw.getHost()
|
||||
.onStackChange(this.getStorageList(), fullStack, difference, src, this.getChannel());
|
||||
iw.getHost().onStackChange(itemList, fullStack, difference, src, this.getChannel());
|
||||
}
|
||||
|
||||
this.myGridCache.getInterestManager().disableTransactions();
|
||||
|
||||
Reference in new issue
Block a user