diff --git a/me/cache/P2PCache.java b/me/cache/P2PCache.java index 203344d62..e884f030f 100644 --- a/me/cache/P2PCache.java +++ b/me/cache/P2PCache.java @@ -62,8 +62,11 @@ public class P2PCache implements IGridCache public void updateFreq(PartP2PTunnel t, long NewFreq) { - outputs.remove( t.freq, t ); - inputs.remove( t.freq ); + if ( outputs.containsValue( t ) ) + outputs.remove( t.freq, t ); + + if ( inputs.containsValue( t ) ) + inputs.remove( t.freq ); t.freq = NewFreq; @@ -150,7 +153,11 @@ public class P2PCache implements IGridCache if ( in == null ) return NullColl; - return inputs.get( freq ).getCollection( outputs.get( freq ) ); + TunnelCollection out = inputs.get( freq ).getCollection( outputs.get( freq ), c ); + if ( out == null ) + return NullColl; + + return out; } public PartP2PTunnel getInput(long freq) diff --git a/me/cache/helpers/TunnelCollection.java b/me/cache/helpers/TunnelCollection.java index 87a04517a..356e94563 100644 --- a/me/cache/helpers/TunnelCollection.java +++ b/me/cache/helpers/TunnelCollection.java @@ -34,4 +34,14 @@ public class TunnelCollection implements Iterable { return !iterator().hasNext(); } + + public boolean matches(Class c) + { + return clz == c; + } + + public Class getClz() + { + return clz; + } } diff --git a/parts/p2p/PartP2PTunnel.java b/parts/p2p/PartP2PTunnel.java index ba3c93697..c8ea21595 100644 --- a/parts/p2p/PartP2PTunnel.java +++ b/parts/p2p/PartP2PTunnel.java @@ -201,19 +201,19 @@ public class PartP2PTunnel extends PartBasicState NBTTagCompound data = new NBTTagCompound(); long newFreq = freq; + boolean wasOutput = output; output = false; - if ( output || freq == 0 ) - { + if ( wasOutput || freq == 0 ) newFreq = System.currentTimeMillis(); - try - { - proxy.getP2P().updateFreq( this, newFreq ); - } - catch (GridAccessException e) - { - // :P - } + + try + { + proxy.getP2P().updateFreq( this, newFreq ); + } + catch (GridAccessException e) + { + // :P } onTunnelConfigChange(); @@ -243,10 +243,15 @@ public class PartP2PTunnel extends PartBasicState return AEApi.instance().parts().partP2PTunnelME.stack( 1 ); } - public TunnelCollection getCollection(Collection collection) + public TunnelCollection getCollection(Collection collection, Class c) { - type.setSource( collection ); - return type; + if ( type.matches( c ) ) + { + type.setSource( collection ); + return type; + } + + return null; } public T getInput()