small optimizations
This commit is contained in:
@@ -264,18 +264,19 @@ public class PartFluidStorageBus extends PartSharedStorageBus implements IMEMoni
|
|||||||
@Override
|
@Override
|
||||||
public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source )
|
public void postChange( final IBaseMonitor<IAEFluidStack> monitor, final Iterable<IAEFluidStack> change, final IActionSource source )
|
||||||
{
|
{
|
||||||
try
|
if( source == this.source || source.machine().map( machine -> machine == this ).orElse( false ) )
|
||||||
{
|
{
|
||||||
if( this.getProxy().isActive() )
|
try
|
||||||
{
|
{
|
||||||
this.getProxy()
|
if( this.getProxy().isActive() )
|
||||||
.getStorage()
|
{
|
||||||
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ), change, this.source );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( final GridAccessException e )
|
||||||
|
{
|
||||||
|
// :(
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// :(
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-2
@@ -44,6 +44,8 @@ import appeng.api.storage.IStorageChannel;
|
|||||||
import appeng.api.storage.data.IAEStack;
|
import appeng.api.storage.data.IAEStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
import appeng.api.storage.data.IItemList;
|
||||||
import appeng.me.storage.ItemWatcher;
|
import appeng.me.storage.ItemWatcher;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
|
|
||||||
|
|
||||||
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
||||||
@@ -58,7 +60,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
private final IItemList<T> cachedList;
|
private final IItemList<T> cachedList;
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private final Map<IMEMonitorHandlerReceiver<T>, Object> listeners;
|
private final Object2ObjectMap<IMEMonitorHandlerReceiver<T>, Object> listeners;
|
||||||
|
|
||||||
private boolean sendEvent = false;
|
private boolean sendEvent = false;
|
||||||
private boolean hasChanged = false;
|
private boolean hasChanged = false;
|
||||||
@@ -70,7 +72,7 @@ public class NetworkMonitor<T extends IAEStack<T>> implements IMEMonitor<T>
|
|||||||
this.myGridCache = cache;
|
this.myGridCache = cache;
|
||||||
this.myChannel = chan;
|
this.myChannel = chan;
|
||||||
this.cachedList = chan.createList();
|
this.cachedList = chan.createList();
|
||||||
this.listeners = new HashMap<>();
|
this.listeners = new Object2ObjectOpenHashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ import java.util.*;
|
|||||||
|
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
import appeng.api.config.StorageFilter;
|
import appeng.api.config.StorageFilter;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
@@ -49,7 +51,7 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||||||
*/
|
*/
|
||||||
class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
class ItemHandlerAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
||||||
{
|
{
|
||||||
private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
private final Object2ObjectMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new Object2ObjectOpenHashMap<>();
|
||||||
private IActionSource mySource;
|
private IActionSource mySource;
|
||||||
private final IItemHandler itemHandler;
|
private final IItemHandler itemHandler;
|
||||||
private final IGridProxyable proxyable;
|
private final IGridProxyable proxyable;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import appeng.api.storage.IStorageChannel;
|
|||||||
|
|
||||||
import appeng.core.AELog;
|
import appeng.core.AELog;
|
||||||
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
import com.jaquadro.minecraft.storagedrawers.api.capabilities.IItemRepository;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectMap;
|
||||||
|
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
@@ -33,7 +35,7 @@ import javax.annotation.Nonnull;
|
|||||||
|
|
||||||
class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
class ItemRepositoryAdapter implements IMEInventory<IAEItemStack>, IBaseMonitor<IAEItemStack>, ITickingMonitor
|
||||||
{
|
{
|
||||||
private final Map<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new HashMap<>();
|
private final Object2ObjectMap<IMEMonitorHandlerReceiver<IAEItemStack>, Object> listeners = new Object2ObjectOpenHashMap<>();
|
||||||
private IActionSource mySource;
|
private IActionSource mySource;
|
||||||
private final IItemRepository itemRepository;
|
private final IItemRepository itemRepository;
|
||||||
private final IGridProxyable proxyable;
|
private final IGridProxyable proxyable;
|
||||||
|
|||||||
@@ -258,19 +258,19 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||||||
@Override
|
@Override
|
||||||
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
|
public void postChange( final IBaseMonitor<IAEItemStack> monitor, final Iterable<IAEItemStack> change, final IActionSource source )
|
||||||
{
|
{
|
||||||
try
|
if( source == this.mySrc || source.machine().map( machine -> machine == this ).orElse( false ) )
|
||||||
{
|
{
|
||||||
if( this.getProxy().isActive() )
|
try
|
||||||
{
|
{
|
||||||
this.getProxy()
|
if( this.getProxy().isActive() )
|
||||||
.getStorage()
|
{
|
||||||
.postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change,
|
this.getProxy().getStorage().postAlterationOfStoredItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ), change, this.mySrc );
|
||||||
this.mySrc );
|
}
|
||||||
|
}
|
||||||
|
catch( final GridAccessException e )
|
||||||
|
{
|
||||||
|
// :(
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch( final GridAccessException e )
|
|
||||||
{
|
|
||||||
// :(
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user