Err too much.
This commit is contained in:
@@ -151,12 +151,6 @@ public class Grid implements IGrid
|
||||
// postEventTo( gridNode, networkChanged );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReady()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IReadOnlyCollection<IGridNode> getNodes()
|
||||
{
|
||||
|
||||
+11
-34
@@ -6,80 +6,57 @@ import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IGridStorage;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GridCacheWrapper implements IGridCache
|
||||
{
|
||||
|
||||
final IGridCache myCache;
|
||||
final public boolean isTickHandler;
|
||||
final IGridCache myCache;
|
||||
final String name;
|
||||
|
||||
public long LastFiveTicksTime = 0;
|
||||
public long LastFiveRemoveTime = 0;
|
||||
public long LastFiveAddNode = 0;
|
||||
|
||||
public GridCacheWrapper(IGridCache gc) {
|
||||
public GridCacheWrapper(final IGridCache gc) {
|
||||
myCache = gc;
|
||||
name = myCache.getClass().getName();
|
||||
isTickHandler = myCache instanceof TickManagerCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick(IGrid grid)
|
||||
public void onUpdateTick(final IGrid grid)
|
||||
{
|
||||
long startTime = Platform.nanoTime();
|
||||
|
||||
myCache.onUpdateTick( grid );
|
||||
|
||||
long estimatedTime = Platform.nanoTime() - startTime;
|
||||
|
||||
if ( isTickHandler ) // remove the ticking of tickables from the
|
||||
// equation.
|
||||
estimatedTime -= ((TickManagerCache) myCache).getInnerTime();
|
||||
|
||||
LastFiveTicksTime = ((LastFiveTicksTime * 4) / 5) + estimatedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode(IGrid grid, IGridNode gridNode, IGridHost machine)
|
||||
public void removeNode(final IGrid grid, final IGridNode gridNode, final IGridHost machine)
|
||||
{
|
||||
long startTime = Platform.nanoTime();
|
||||
|
||||
myCache.removeNode( grid, gridNode, machine );
|
||||
|
||||
long estimatedTime = Platform.nanoTime() - startTime;
|
||||
LastFiveRemoveTime = ((LastFiveRemoveTime * 4) / 5) + estimatedTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode(IGrid grid, IGridNode gridNode, IGridHost machine)
|
||||
public void addNode(final IGrid grid, final IGridNode gridNode, final IGridHost machine)
|
||||
{
|
||||
long startTime = Platform.nanoTime();
|
||||
|
||||
myCache.addNode( grid, gridNode, machine );
|
||||
|
||||
long estimatedTime = Platform.nanoTime() - startTime;
|
||||
LastFiveAddNode = ((LastFiveAddNode * 4) / 5) + estimatedTime;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return myCache.getClass().getName();
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSplit(IGridStorage storageB)
|
||||
public void onSplit(final IGridStorage storageB)
|
||||
{
|
||||
myCache.onSplit( storageB );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoin(IGridStorage storageB)
|
||||
public void onJoin(final IGridStorage storageB)
|
||||
{
|
||||
myCache.onJoin( storageB );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populateGridStorage(IGridStorage storage)
|
||||
public void populateGridStorage(final IGridStorage storage)
|
||||
{
|
||||
myCache.populateGridStorage( storage );
|
||||
}
|
||||
|
||||
@@ -485,4 +485,10 @@ public class GridNode implements IGridNode, IPathItem
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFlag(GridFlags flag)
|
||||
{
|
||||
return getGridBlock().getFlags().contains( flag );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Vendored
+85
-69
@@ -51,9 +51,34 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
double prev_extra = 0;
|
||||
double extra = 0;
|
||||
|
||||
IAEPowerStorage lastProvider;
|
||||
Set<IAEPowerStorage> providers = new LinkedHashSet();
|
||||
|
||||
IAEPowerStorage lastRequestor;
|
||||
Set<IAEPowerStorage> requesters = new LinkedHashSet();
|
||||
|
||||
private IAEPowerStorage getFirstRequestor()
|
||||
{
|
||||
if ( lastRequestor == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = requesters.iterator();
|
||||
lastRequestor = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
return lastRequestor;
|
||||
}
|
||||
|
||||
private IAEPowerStorage getFirstProvider()
|
||||
{
|
||||
if ( lastProvider == null )
|
||||
{
|
||||
Iterator<IAEPowerStorage> i = providers.iterator();
|
||||
lastProvider = i.hasNext() ? i.next() : null;
|
||||
}
|
||||
|
||||
return lastProvider;
|
||||
}
|
||||
|
||||
Set<IEnergyGridProvider> gproviders = new LinkedHashSet();
|
||||
|
||||
final IGrid myGrid;
|
||||
@@ -131,11 +156,14 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
{
|
||||
while (i > 0 && !requesters.isEmpty())
|
||||
{
|
||||
IAEPowerStorage node = requesters.iterator().next();
|
||||
IAEPowerStorage node = getFirstRequestor();
|
||||
|
||||
i = node.injectAEPower( i, Actionable.MODULATE );
|
||||
if ( i > 0 )
|
||||
{
|
||||
requesters.remove( node );
|
||||
lastRequestor = null;
|
||||
}
|
||||
}
|
||||
|
||||
extra = i;
|
||||
@@ -145,10 +173,13 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
return i;
|
||||
}
|
||||
|
||||
Set<IEnergyGrid> seen = new HashSet();
|
||||
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, PowerMultiplier pm)
|
||||
{
|
||||
return pm.divide( extractAEPower( pm.multiply( amt ), mode, new HashSet() ) );
|
||||
seen.clear();
|
||||
return pm.divide( extractAEPower( pm.multiply( amt ), mode, seen ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,45 +234,17 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
if ( ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
globalAvailablePower -= ps.getAECurrentPower();
|
||||
|
||||
if ( lastProvider == machine )
|
||||
lastProvider = null;
|
||||
|
||||
if ( lastRequestor == machine )
|
||||
lastRequestor = null;
|
||||
|
||||
providers.remove( machine );
|
||||
requesters.remove( machine );
|
||||
}
|
||||
}
|
||||
|
||||
// recalculate the whole thing?
|
||||
public void reset(IGrid grid)
|
||||
{
|
||||
providers = new LinkedHashSet();
|
||||
requesters = new LinkedHashSet();
|
||||
|
||||
// re-calculate power info
|
||||
for (Class c : grid.getMachinesClasses())
|
||||
{
|
||||
if ( IAEPowerStorage.class.isAssignableFrom( c ) )
|
||||
{
|
||||
for (Object obj : grid.getMachines( c ))
|
||||
{
|
||||
IAEPowerStorage ps = (IAEPowerStorage) obj;
|
||||
if ( ps.isAEPublicPowerStorage() )
|
||||
{
|
||||
double max = ps.getAEMaxPower();
|
||||
double current = ps.getAECurrentPower();
|
||||
|
||||
if ( current > 0 && ps.getPowerFlow() != AccessRestriction.WRITE )
|
||||
{
|
||||
providers.add( ps );
|
||||
globalAvailablePower += ps.getAECurrentPower();
|
||||
}
|
||||
|
||||
if ( current < max && ps.getPowerFlow() != AccessRestriction.READ )
|
||||
requesters.add( ps );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateTick(IGrid grid)
|
||||
{
|
||||
@@ -280,7 +283,6 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
private void publicPowerState(boolean newState, IGrid grid)
|
||||
{
|
||||
|
||||
if ( publicHasPower == newState )
|
||||
return;
|
||||
|
||||
@@ -311,44 +313,18 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
@Override
|
||||
public double extractAEPower(double amt, Actionable mode, Set<IEnergyGrid> seen)
|
||||
{
|
||||
if ( seen.contains( this ) )
|
||||
if ( !seen.add( this ) )
|
||||
return 0;
|
||||
|
||||
seen.add( this );
|
||||
|
||||
double extractedPower = extra;
|
||||
|
||||
if ( mode == Actionable.SIMULATE )
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = providers.iterator();
|
||||
while (extractedPower < amt && it.hasNext())
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
}
|
||||
extractedPower += simulateExtract( extractedPower, amt );
|
||||
return extractedPower;
|
||||
}
|
||||
else
|
||||
{
|
||||
extra = 0;
|
||||
|
||||
while (extractedPower < amt && !providers.isEmpty())
|
||||
{
|
||||
IAEPowerStorage node = providers.iterator().next();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
|
||||
if ( newPower < req )
|
||||
providers.remove( node );
|
||||
}
|
||||
|
||||
// add power used to the current tick.
|
||||
totalDrainPastTicks[0] += extractedPower;
|
||||
}
|
||||
extractedPower += doExtract( extractedPower, amt );
|
||||
|
||||
// got more then we wanted?
|
||||
if ( extractedPower > amt )
|
||||
@@ -361,8 +337,9 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
|
||||
if ( extractedPower < amt )
|
||||
{
|
||||
for (IEnergyGridProvider egp : gproviders)
|
||||
extractedPower += egp.extractAEPower( amt - extractedPower, mode, seen );
|
||||
Iterator<IEnergyGridProvider> i = gproviders.iterator();
|
||||
while (extractedPower < amt && i.hasNext())
|
||||
extractedPower += i.next().extractAEPower( amt - extractedPower, mode, seen );
|
||||
}
|
||||
|
||||
// go less or the correct amount?
|
||||
@@ -370,6 +347,45 @@ public class EnergyGridCache implements IEnergyGrid
|
||||
return extractedPower;
|
||||
}
|
||||
|
||||
private double doExtract(double extractedPower, double amt)
|
||||
{
|
||||
extra = 0;
|
||||
|
||||
while (extractedPower < amt && !providers.isEmpty())
|
||||
{
|
||||
IAEPowerStorage node = getFirstProvider();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
|
||||
if ( newPower < req )
|
||||
{
|
||||
providers.remove( node );
|
||||
lastProvider = null;
|
||||
}
|
||||
}
|
||||
|
||||
totalDrainPastTicks[0] += extractedPower;
|
||||
return extractedPower;
|
||||
}
|
||||
|
||||
private double simulateExtract(double extractedPower, double amt)
|
||||
{
|
||||
Iterator<IAEPowerStorage> it = providers.iterator();
|
||||
|
||||
while (extractedPower < amt && it.hasNext())
|
||||
{
|
||||
IAEPowerStorage node = it.next();
|
||||
|
||||
double req = amt - extractedPower;
|
||||
double newPower = node.extractAEPower( req, Actionable.SIMULATE, PowerMultiplier.ONE );
|
||||
extractedPower += newPower;
|
||||
}
|
||||
|
||||
return extractedPower;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkPowered()
|
||||
{
|
||||
|
||||
Vendored
+1
-14
@@ -33,19 +33,6 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
|
||||
final static public LinkedList depth = new LinkedList();
|
||||
|
||||
private BaseActionSource src;
|
||||
|
||||
public void setSource(BaseActionSource src)
|
||||
{
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BaseActionSource getSource()
|
||||
{
|
||||
return src;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void postChange(T diff, BaseActionSource src)
|
||||
{
|
||||
@@ -86,7 +73,7 @@ public class NetworkMonitor<T extends IAEStack<T>> extends MEMonitorHandler<T>
|
||||
if ( sendEvent )
|
||||
{
|
||||
sendEvent = false;
|
||||
myGridCache.myGrid.postEvent( new MENetworkStorageEvent( getStorageList(), myChannel ) );
|
||||
myGridCache.myGrid.postEvent( new MENetworkStorageEvent( this, myChannel ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+63
-33
@@ -1,6 +1,5 @@
|
||||
package appeng.me.cache;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
import appeng.api.networking.IGrid;
|
||||
@@ -8,7 +7,9 @@ import appeng.api.networking.IGridCache;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.IGridStorage;
|
||||
import appeng.parts.misc.PartP2PTunnel;
|
||||
import appeng.core.AELog;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
@@ -16,8 +17,9 @@ import com.google.common.collect.Multimap;
|
||||
public class P2PCache implements IGridCache
|
||||
{
|
||||
|
||||
private HashMap<Long, PartP2PTunnel> inputs = new HashMap();
|
||||
private Multimap<Long, PartP2PTunnel> Tunnels = LinkedHashMultimap.create();
|
||||
final private HashMap<Long, PartP2PTunnel> inputs = new HashMap();
|
||||
final private Multimap<Long, PartP2PTunnel> outputs = LinkedHashMultimap.create();
|
||||
final private TunnelCollection NullColl = new TunnelCollection<PartP2PTunnel>( null, null );
|
||||
|
||||
final IGrid myGrid;
|
||||
|
||||
@@ -25,50 +27,78 @@ public class P2PCache implements IGridCache
|
||||
myGrid = g;
|
||||
}
|
||||
|
||||
public void updateFreq(PartP2PTunnel t, long NewFreq)
|
||||
{
|
||||
outputs.remove( t.freq, t );
|
||||
inputs.remove( t.freq );
|
||||
|
||||
t.freq = NewFreq;
|
||||
|
||||
if ( t.output )
|
||||
outputs.put( t.freq, t );
|
||||
else
|
||||
inputs.put( t.freq, t );
|
||||
|
||||
AELog.info( "update-" + (t.output ? "output: " : "input: ") + t.freq );
|
||||
updateTunnel( t.freq, t.output );
|
||||
updateTunnel( t.freq, !t.output );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNode(IGrid grid, IGridNode node, IGridHost machine)
|
||||
{
|
||||
if ( machine instanceof PartP2PTunnel )
|
||||
reset( grid );
|
||||
{
|
||||
PartP2PTunnel t = (PartP2PTunnel) machine;
|
||||
AELog.info( "add-" + (t.output ? "output: " : "input: ") + t.freq );
|
||||
|
||||
if ( t.output )
|
||||
outputs.put( t.freq, t );
|
||||
else
|
||||
inputs.put( t.freq, t );
|
||||
|
||||
updateTunnel( t.freq, !t.output );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeNode(IGrid grid, IGridNode node, IGridHost machine)
|
||||
{
|
||||
if ( machine instanceof PartP2PTunnel )
|
||||
reset( grid );
|
||||
}
|
||||
|
||||
public void reset(IGrid grid)
|
||||
{
|
||||
|
||||
Tunnels.clear();
|
||||
inputs.clear();
|
||||
|
||||
for (IGridNode n : grid.getMachines( PartP2PTunnel.class ))
|
||||
{
|
||||
PartP2PTunnel p = (PartP2PTunnel) n.getMachine();
|
||||
if ( p.freq > 0 )
|
||||
{
|
||||
if ( p.output )
|
||||
Tunnels.put( p.freq, p );
|
||||
else if ( inputs.containsKey( p.freq ) )
|
||||
p.output = true;
|
||||
else
|
||||
inputs.put( p.freq, p );
|
||||
}
|
||||
PartP2PTunnel t = (PartP2PTunnel) machine;
|
||||
AELog.info( "rmv-" + (t.output ? "output: " : "input: ") + t.freq );
|
||||
|
||||
if ( t.output )
|
||||
outputs.remove( t.freq, t );
|
||||
else
|
||||
inputs.remove( t.freq );
|
||||
|
||||
updateTunnel( t.freq, !t.output );
|
||||
}
|
||||
|
||||
for (PartP2PTunnel p : inputs.values())
|
||||
p.onChange();
|
||||
|
||||
for (PartP2PTunnel p : Tunnels.values())
|
||||
p.onChange();
|
||||
}
|
||||
|
||||
public Collection<PartP2PTunnel> getOutputs(long freq)
|
||||
private void updateTunnel(long freq, boolean updateOutputs)
|
||||
{
|
||||
return Tunnels.get( freq );
|
||||
if ( updateOutputs )
|
||||
{
|
||||
for (PartP2PTunnel p : outputs.values())
|
||||
p.onChange();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (PartP2PTunnel p : inputs.values())
|
||||
p.onChange();
|
||||
}
|
||||
}
|
||||
|
||||
public TunnelCollection<PartP2PTunnel> getOutputs(long freq, Class<? extends PartP2PTunnel> c)
|
||||
{
|
||||
PartP2PTunnel in = inputs.get( freq );
|
||||
if ( in == null )
|
||||
return NullColl;
|
||||
|
||||
return inputs.get( freq ).getCollection( outputs.get( freq ) );
|
||||
}
|
||||
|
||||
public PartP2PTunnel getInput(long freq)
|
||||
|
||||
Vendored
-13
@@ -14,13 +14,11 @@ import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.core.AELog;
|
||||
import appeng.me.cache.helpers.TickTracker;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class TickManagerCache implements ITickManager
|
||||
{
|
||||
|
||||
private long currentTick = 0;
|
||||
private long lastInnerTime = 0;
|
||||
|
||||
final IGrid myGrid;
|
||||
|
||||
@@ -40,11 +38,6 @@ public class TickManagerCache implements ITickManager
|
||||
return currentTick;
|
||||
}
|
||||
|
||||
public long getInnerTime()
|
||||
{
|
||||
return lastInnerTime;
|
||||
}
|
||||
|
||||
public long getAvgNanoTime(IGridNode node)
|
||||
{
|
||||
TickTracker tt = awake.get( node );
|
||||
@@ -70,13 +63,7 @@ public class TickManagerCache implements ITickManager
|
||||
{
|
||||
// remove tt..
|
||||
upcomingTicks.poll();
|
||||
|
||||
long startTime = Platform.nanoTime();
|
||||
TickRateModulation mod = tt.gt.tickingRequest( tt.node, diff );
|
||||
long estimatedTime = Platform.nanoTime() - startTime;
|
||||
lastInnerTime += estimatedTime;
|
||||
|
||||
tt.LastFiveTicksTime = ((tt.LastFiveTicksTime * 4) / 5) + estimatedTime;
|
||||
|
||||
switch (mod)
|
||||
{
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
|
||||
public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
|
||||
{
|
||||
|
||||
final Class clz;
|
||||
Collection<T> tunnelsource;
|
||||
|
||||
public TunnelCollection(Collection<T> src, Class c) {
|
||||
tunnelsource = src;
|
||||
clz = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
if ( tunnelsource == null )
|
||||
return new NullIterator();
|
||||
return new TunnelIterator( tunnelsource, clz );
|
||||
}
|
||||
|
||||
public void setSource(Collection<T> c)
|
||||
{
|
||||
tunnelsource = c;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return iterator().hasNext();
|
||||
}
|
||||
}
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
|
||||
public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
|
||||
{
|
||||
|
||||
Iterator<T> wrapped;
|
||||
Class targetType;
|
||||
T Next;
|
||||
|
||||
private void findNext()
|
||||
{
|
||||
while (Next == null && wrapped.hasNext())
|
||||
{
|
||||
Next = wrapped.next();
|
||||
if ( !targetType.isInstance( Next ) )
|
||||
Next = null;
|
||||
}
|
||||
}
|
||||
|
||||
public TunnelIterator(Collection<T> tunnelsource, Class clz) {
|
||||
wrapped = tunnelsource.iterator();
|
||||
targetType = clz;
|
||||
findNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
findNext();
|
||||
return Next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
T tmp = Next;
|
||||
Next = null;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
// no.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,24 +56,24 @@ public class QuantumCalculator extends MBCalculator
|
||||
{
|
||||
TileQuantumBridge te = (TileQuantumBridge) w.getBlockTileEntity( x, y, z );
|
||||
|
||||
byte Fish = 0;
|
||||
byte flags = 0;
|
||||
|
||||
num++;
|
||||
if ( num == 5 )
|
||||
{
|
||||
Fish = (byte) (num);
|
||||
flags = (byte) (num);
|
||||
c.setCenter( te );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( num == 1 || num == 3 || num == 7 || num == 9 )
|
||||
Fish = (byte) (tqb.corner | num);
|
||||
flags = (byte) (tqb.corner | num);
|
||||
else
|
||||
Fish = (byte) (num);
|
||||
flags = (byte) (num);
|
||||
c.Ring[ringNum++] = te;
|
||||
}
|
||||
|
||||
te.updateStatus( c, Fish );
|
||||
te.updateStatus( c, flags );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,12 +112,12 @@ public class QuantumCalculator extends MBCalculator
|
||||
num++;
|
||||
if ( num == 5 )
|
||||
{
|
||||
if ( Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumLink ) )
|
||||
if ( !Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumLink ) )
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumRing ) )
|
||||
if ( !Platform.blockAtLocationIs( w, x, y, z, AEApi.instance().blocks().blockQuantumRing ) )
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package appeng.me.cluster.implementations;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.world.WorldEvent;
|
||||
@@ -10,8 +11,9 @@ import appeng.api.AEApi;
|
||||
import appeng.api.events.LocatableEventAnnounce;
|
||||
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
||||
import appeng.api.features.ILocatable;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.me.cluster.IAECluster;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
@@ -20,6 +22,13 @@ import appeng.util.iterators.ChainedIterator;
|
||||
public class QuantumCluster implements ILocatable, IAECluster
|
||||
{
|
||||
|
||||
class QuantumLeap
|
||||
{
|
||||
|
||||
IGridConnection connection;
|
||||
|
||||
};
|
||||
|
||||
public WorldCoord min;
|
||||
public WorldCoord max;
|
||||
public boolean isDestroyed = false;
|
||||
@@ -28,6 +37,8 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
private long thisSide;
|
||||
private long otherSide;
|
||||
|
||||
QuantumLeap connection;
|
||||
|
||||
public TileQuantumBridge Ring[];
|
||||
private TileQuantumBridge center;
|
||||
|
||||
@@ -53,7 +64,7 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
public boolean canUseNode(long qe)
|
||||
{
|
||||
QuantumCluster qc = (QuantumCluster) AEApi.instance().registries().locateable().findLocateableBySerial( qe );
|
||||
if ( qc.center instanceof TileQuantumBridge )
|
||||
if ( qc != null && qc.center instanceof TileQuantumBridge )
|
||||
{
|
||||
if ( !qc.isDestroyed )
|
||||
{
|
||||
@@ -77,7 +88,6 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
@Override
|
||||
public void updateStatus(boolean updateGrid)
|
||||
{
|
||||
long oldOtherSide = otherSide;
|
||||
long qe;
|
||||
|
||||
qe = center.getQEDest();
|
||||
@@ -111,31 +121,47 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
}
|
||||
}
|
||||
|
||||
if ( updateGrid )
|
||||
Object myOtherSide = otherSide == 0 ? null : AEApi.instance().registries().locateable().findLocateableBySerial( otherSide );
|
||||
|
||||
boolean shutdown = false;
|
||||
|
||||
if ( myOtherSide instanceof QuantumCluster )
|
||||
{
|
||||
updateGrid( this );
|
||||
Object myOtherSide = otherSide == 0 ? null : AEApi.instance().registries().locateable().findLocateableBySerial( otherSide );
|
||||
Object oldMyOtherSide = oldOtherSide == 0 ? null : AEApi.instance().registries().locateable().findLocateableBySerial( oldOtherSide );
|
||||
if ( myOtherSide instanceof QuantumCluster )
|
||||
updateGrid( (QuantumCluster) myOtherSide );
|
||||
if ( oldMyOtherSide instanceof QuantumCluster )
|
||||
updateGrid( (QuantumCluster) oldMyOtherSide );
|
||||
}
|
||||
}
|
||||
QuantumCluster sideA = (QuantumCluster) this;
|
||||
QuantumCluster sideB = (QuantumCluster) myOtherSide;
|
||||
|
||||
public void updateRender()
|
||||
{
|
||||
for (int x = 0; x < Ring.length; x++)
|
||||
if ( sideA.isActive() && sideB.isActive() )
|
||||
{
|
||||
if ( connection != null && connection.connection != null )
|
||||
{
|
||||
IGridNode a = connection.connection.a();
|
||||
IGridNode b = connection.connection.b();
|
||||
IGridNode sa = sideA.getNode();
|
||||
IGridNode sb = sideB.getNode();
|
||||
if ( (a == sa || b == sa) && (a == sb || b == sb) )
|
||||
return;
|
||||
}
|
||||
|
||||
QuantumLeap ql = sideA.connection = sideB.connection = new QuantumLeap();
|
||||
ql.connection = AEApi.instance().createGridConnection( sideA.getNode(), sideB.getNode() );
|
||||
}
|
||||
else
|
||||
shutdown = true;
|
||||
}
|
||||
else
|
||||
shutdown = true;
|
||||
|
||||
if ( shutdown && connection != null )
|
||||
{
|
||||
|
||||
if ( connection.connection != null )
|
||||
{
|
||||
connection.connection.destroy();
|
||||
connection.connection = null;
|
||||
connection = new QuantumLeap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateGrid(QuantumCluster c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy()
|
||||
{
|
||||
@@ -151,16 +177,10 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
|
||||
if ( getLocatableSerial() != 0 )
|
||||
{
|
||||
updateGrid( this );
|
||||
Object myOtherSide = otherSide == 0 ? null : AEApi.instance().registries().locateable().findLocateableBySerial( otherSide );
|
||||
if ( myOtherSide instanceof QuantumCluster )
|
||||
updateGrid( (QuantumCluster) myOtherSide );
|
||||
|
||||
updateStatus( true );
|
||||
MinecraftForge.EVENT_BUS.post( new LocatableEventAnnounce( this, LocatableEvent.Unregister ) );
|
||||
}
|
||||
|
||||
// updateStatus( true );
|
||||
|
||||
center.updateStatus( null, (byte) -1 );
|
||||
|
||||
for (TileQuantumBridge r : Ring)
|
||||
@@ -175,29 +195,6 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
public boolean isCorner(TileQuantumBridge tileQuantumBridge)
|
||||
{
|
||||
return Ring[0] == tileQuantumBridge || Ring[2] == tileQuantumBridge || Ring[4] == tileQuantumBridge || Ring[6] == tileQuantumBridge;
|
||||
|
||||
}
|
||||
|
||||
public DimensionalCoord[] getOtherSide()
|
||||
{
|
||||
Object myOtherSide = AEApi.instance().registries().locateable().findLocateableBySerial( otherSide );
|
||||
if ( myOtherSide != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
QuantumCluster qc = (QuantumCluster) myOtherSide;
|
||||
DimensionalCoord[] out = new DimensionalCoord[4];
|
||||
out[0] = new DimensionalCoord( qc.Ring[1] );
|
||||
out[1] = new DimensionalCoord( qc.Ring[3] );
|
||||
out[2] = new DimensionalCoord( qc.Ring[4] );
|
||||
out[3] = new DimensionalCoord( qc.Ring[6] );
|
||||
return out;
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
}
|
||||
}
|
||||
return new DimensionalCoord[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,11 +203,6 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
return thisSide;
|
||||
}
|
||||
|
||||
public boolean hasPower()
|
||||
{
|
||||
return center.bridgePowered;
|
||||
}
|
||||
|
||||
public TileQuantumBridge getCenter()
|
||||
{
|
||||
return center;
|
||||
@@ -221,4 +213,17 @@ public class QuantumCluster implements ILocatable, IAECluster
|
||||
return getLocatableSerial() != 0;
|
||||
}
|
||||
|
||||
private IGridNode getNode()
|
||||
{
|
||||
return center.getGridNode( ForgeDirection.UNKNOWN );
|
||||
}
|
||||
|
||||
private boolean isActive()
|
||||
{
|
||||
if ( isDestroyed || !registered )
|
||||
return false;
|
||||
|
||||
return center.isPowered() && hasQES();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IOrientable;
|
||||
import appeng.helpers.TickHandler;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.P2PCache;
|
||||
import appeng.parts.networking.PartCable;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import appeng.util.Platform;
|
||||
@@ -97,15 +98,6 @@ public class AENetworkProxy implements IGridBlock
|
||||
return validSides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetworkMachineActive()
|
||||
{
|
||||
if ( node == null )
|
||||
return false;
|
||||
|
||||
return node.getGrid().isReady();
|
||||
}
|
||||
|
||||
public void setValidSides(EnumSet<ForgeDirection> validSides)
|
||||
{
|
||||
this.validSides = validSides;
|
||||
@@ -231,6 +223,20 @@ public class AENetworkProxy implements IGridBlock
|
||||
return pg;
|
||||
}
|
||||
|
||||
public P2PCache getP2P() throws GridAccessException
|
||||
{
|
||||
IGrid grid = getGrid();
|
||||
if ( grid == null )
|
||||
throw new GridAccessException();
|
||||
|
||||
P2PCache pg = grid.getCache( P2PCache.class );
|
||||
|
||||
if ( pg == null )
|
||||
throw new GridAccessException();
|
||||
|
||||
return pg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldAccessable()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ package appeng.me.storage;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
@@ -11,8 +12,10 @@ import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.nbt.NBTTagShort;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.implementations.IStorageCell;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
@@ -335,7 +338,7 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( input == null )
|
||||
return null;
|
||||
@@ -422,7 +425,7 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( request == null )
|
||||
return null;
|
||||
@@ -482,4 +485,28 @@ public class CellInventory implements IMEInventory<IAEItemStack>
|
||||
return CellType.getIdleDrain();
|
||||
}
|
||||
|
||||
public FuzzyMode getFuzzyMode()
|
||||
{
|
||||
return CellType.getFuzzyMode( this.i );
|
||||
}
|
||||
|
||||
public IInventory getConfigInventory()
|
||||
{
|
||||
return CellType.getConfigInventory( this.i );
|
||||
}
|
||||
|
||||
public IInventory getUpgradesInventory()
|
||||
{
|
||||
return CellType.getUpgradesInventory( this.i );
|
||||
}
|
||||
|
||||
public int getStatusForCell()
|
||||
{
|
||||
if ( canHoldNewItem() )
|
||||
return 1;
|
||||
if ( remainingItemCount() > 0 )
|
||||
return 2;
|
||||
return 3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.IUpgradeModule;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.ItemList;
|
||||
import appeng.util.prioitylist.FuzzyPriorityList;
|
||||
import appeng.util.prioitylist.PrecisePriorityList;
|
||||
|
||||
public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
@@ -15,11 +26,67 @@ public class CellInventoryHandler extends MEInventoryHandler<IAEItemStack>
|
||||
|
||||
public CellInventory getCellInv()
|
||||
{
|
||||
return (CellInventory) (this.internal instanceof CellInventory ? this.internal : null);
|
||||
Object o = this.internal;
|
||||
|
||||
if ( o instanceof MEPassthru )
|
||||
o = ((MEPassthru) o).getInternal();
|
||||
|
||||
return (CellInventory) (o instanceof CellInventory ? o : null);
|
||||
}
|
||||
|
||||
CellInventoryHandler(IMEInventory c) {
|
||||
super( c );
|
||||
}
|
||||
|
||||
CellInventory ci = getCellInv();
|
||||
if ( ci != null )
|
||||
{
|
||||
IItemList priorityList = new ItemList();
|
||||
|
||||
IInventory upgrades = ci.getUpgradesInventory();
|
||||
IInventory config = ci.getConfigInventory();
|
||||
FuzzyMode fzMode = ci.getFuzzyMode();
|
||||
|
||||
boolean hasInverter = false;
|
||||
boolean hasFuzzy = false;
|
||||
|
||||
for (int x = 0; x < upgrades.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack is = upgrades.getStackInSlot( x );
|
||||
if ( is != null && is.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
Upgrades u = ((IUpgradeModule) is.getItem()).getType( is );
|
||||
if ( u != null )
|
||||
{
|
||||
switch (u)
|
||||
{
|
||||
case FUZZY:
|
||||
hasFuzzy = true;
|
||||
break;
|
||||
case INVERTER:
|
||||
hasInverter = true;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < config.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack is = config.getStackInSlot( x );
|
||||
if ( is != null )
|
||||
priorityList.add( AEItemStack.create( is ) );
|
||||
}
|
||||
|
||||
myWhitelist = hasInverter ? IncludeExclude.BLACKLIST : IncludeExclude.WHITELIST;
|
||||
|
||||
if ( !priorityList.isEmpty() )
|
||||
{
|
||||
if ( hasFuzzy )
|
||||
myPartitionList = new FuzzyPriorityList<IAEItemStack>( priorityList, fzMode );
|
||||
else
|
||||
myPartitionList = new PrecisePriorityList<IAEItemStack>( priorityList );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.exceptions.AppEngException;
|
||||
import appeng.api.implementations.IStorageCell;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.util.Platform;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.items.storage.CellConfig;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import appeng.util.item.ItemList;
|
||||
|
||||
public class CreativeCellInventory extends CellInventory implements IStorageCell
|
||||
public class CreativeCellInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
{
|
||||
|
||||
ItemList itemListCache;
|
||||
ItemList<IAEItemStack> itemListCache = new ItemList();
|
||||
|
||||
public static IMEInventoryHandler getCell(ItemStack o)
|
||||
{
|
||||
@@ -28,58 +32,20 @@ public class CreativeCellInventory extends CellInventory implements IStorageCell
|
||||
}
|
||||
|
||||
protected CreativeCellInventory(ItemStack o) throws AppEngException {
|
||||
super( Platform.openNbtData( o ) );
|
||||
|
||||
if ( MAX_ITEM_TYPES > 63 )
|
||||
MAX_ITEM_TYPES = 63;
|
||||
if ( MAX_ITEM_TYPES < 1 )
|
||||
MAX_ITEM_TYPES = 1;
|
||||
|
||||
storedItems = tagCompound.getShort( ITEM_TYPE_TAG );
|
||||
storedItemCount = tagCompound.getInteger( ITEM_COUNT_TAG );
|
||||
cellItems = null;
|
||||
CellConfig cc = new CellConfig( o );
|
||||
for (ItemStack is : cc)
|
||||
if ( is != null )
|
||||
{
|
||||
IAEItemStack i = AEItemStack.create( is );
|
||||
i.setStackSize( Integer.MAX_VALUE );
|
||||
itemListCache.add( i );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStorageCell(ItemStack i)
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBytes(ItemStack cellItem)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int BytePerType(ItemStack iscellItem)
|
||||
{
|
||||
return 8;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalTypes(ItemStack cellItem)
|
||||
{
|
||||
return 63;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlackListed(ItemStack cellItem, IAEItemStack requsetedAddition)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean storableInStorageCell()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
{
|
||||
IAEItemStack local = getCellItems().findPrecise( input );
|
||||
IAEItemStack local = itemListCache.findPrecise( input );
|
||||
if ( local == null )
|
||||
return input;
|
||||
|
||||
@@ -87,9 +53,9 @@ public class CreativeCellInventory extends CellInventory implements IStorageCell
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
IAEItemStack local = getCellItems().findPrecise( request );
|
||||
IAEItemStack local = itemListCache.findPrecise( request );
|
||||
if ( local == null )
|
||||
return null;
|
||||
|
||||
@@ -97,22 +63,47 @@ public class CreativeCellInventory extends CellInventory implements IStorageCell
|
||||
}
|
||||
|
||||
@Override
|
||||
ItemList<IAEItemStack> getCellItems()
|
||||
public IItemList<IAEItemStack> getAvailableItems(IItemList out)
|
||||
{
|
||||
if ( itemListCache != null )
|
||||
return itemListCache;
|
||||
for (IAEItemStack ais : itemListCache)
|
||||
out.add( ais );
|
||||
return out;
|
||||
}
|
||||
|
||||
ItemList list = new ItemList();
|
||||
CellInventoryHandler handler = new CellInventoryHandler( this );
|
||||
@Override
|
||||
public StorageChannel getChannel()
|
||||
{
|
||||
return StorageChannel.ITEMS;
|
||||
}
|
||||
|
||||
for (IAEItemStack is : handler.myPartitionList.getItems())
|
||||
{
|
||||
IAEItemStack b = is.copy();
|
||||
b.setStackSize( Integer.MAX_VALUE );
|
||||
list.add( b );
|
||||
}
|
||||
@Override
|
||||
public AccessRestriction getAccess()
|
||||
{
|
||||
return AccessRestriction.READ_WRITE;
|
||||
}
|
||||
|
||||
return itemListCache = list;
|
||||
@Override
|
||||
public boolean isPrioritized(IAEItemStack input)
|
||||
{
|
||||
return itemListCache.findPrecise( input ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccept(IAEItemStack input)
|
||||
{
|
||||
return itemListCache.findPrecise( input ) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPriority()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlot()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.implementations.IChestOrDrive;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
|
||||
public class DriveWatcher<T extends IAEStack<T>> extends MEInventoryHandler<T>
|
||||
{
|
||||
|
||||
int oldStatus = 0;
|
||||
final ItemStack is;
|
||||
final ICellHandler handler;
|
||||
final IChestOrDrive cord;
|
||||
|
||||
public DriveWatcher(IMEInventory<T> i, ItemStack is, ICellHandler han, IChestOrDrive cod) {
|
||||
super( i );
|
||||
this.is = is;
|
||||
handler = han;
|
||||
cord = cod;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T injectItems(T input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
long size = input.getStackSize();
|
||||
|
||||
T a = super.injectItems( input, type, src );
|
||||
|
||||
if ( a == null || a.getStackSize() != size )
|
||||
{
|
||||
int newStatus = handler.getStatusForCell( is, getInternal() );
|
||||
|
||||
if ( newStatus != oldStatus )
|
||||
{
|
||||
cord.blinkCell( getSlot() );
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(T request, Actionable type, BaseActionSource src)
|
||||
{
|
||||
T a = super.extractItems( request, type, src );
|
||||
|
||||
if ( a != null )
|
||||
{
|
||||
int newStatus = handler.getStatusForCell( is, getInternal() );
|
||||
|
||||
if ( newStatus != oldStatus )
|
||||
{
|
||||
cord.blinkCell( getSlot() );
|
||||
}
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
}
|
||||
+171
-171
@@ -1,171 +1,171 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.api.networking.storage.IStackWatcher;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
|
||||
/**
|
||||
* Maintain my interests, and a global watch list, they should always be fully synchronized.
|
||||
*/
|
||||
public class ItemWatcher implements IStackWatcher
|
||||
{
|
||||
|
||||
class ItemWatcherIterator implements Iterator<IAEStack>
|
||||
{
|
||||
|
||||
final ItemWatcher watcher;
|
||||
final Iterator<IAEStack> interestIterator;
|
||||
IAEStack myLast;
|
||||
|
||||
public ItemWatcherIterator(ItemWatcher parent, Iterator<IAEStack> i) {
|
||||
watcher = parent;
|
||||
interestIterator = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return interestIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack next()
|
||||
{
|
||||
return myLast = interestIterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
gsc.interests.remove( myLast, watcher );
|
||||
interestIterator.remove();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GridStorageCache gsc;
|
||||
IStackWatcherHost myObject;
|
||||
HashSet<IAEStack> myInterests = new HashSet();
|
||||
|
||||
public ItemWatcher(GridStorageCache cache, IStackWatcherHost host) {
|
||||
gsc = cache;
|
||||
myObject = host;
|
||||
}
|
||||
|
||||
public IStackWatcherHost getHost()
|
||||
{
|
||||
return myObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(IAEStack e)
|
||||
{
|
||||
if ( myInterests.contains( e ) )
|
||||
return false;
|
||||
|
||||
return myInterests.add( e.copy() ) && gsc.interests.put( e, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends IAEStack> c)
|
||||
{
|
||||
boolean didChange = false;
|
||||
|
||||
for (IAEStack o : c)
|
||||
didChange = add( o ) || didChange;
|
||||
|
||||
return didChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
Iterator<IAEStack> i = myInterests.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
gsc.interests.remove( i.next(), this );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
return myInterests.contains( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c)
|
||||
{
|
||||
return myInterests.containsAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return myInterests.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEStack> iterator()
|
||||
{
|
||||
return new ItemWatcherIterator( this, myInterests.iterator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o)
|
||||
{
|
||||
return myInterests.remove( o ) && gsc.interests.remove( o, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c)
|
||||
{
|
||||
boolean didSomething = false;
|
||||
for (Object o : c)
|
||||
didSomething = remove( o ) || didSomething;
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c)
|
||||
{
|
||||
boolean changed = false;
|
||||
Iterator<IAEStack> i = iterator();
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
if ( !c.contains( i.next() ) )
|
||||
{
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return myInterests.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray()
|
||||
{
|
||||
return myInterests.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a)
|
||||
{
|
||||
return myInterests.toArray( a );
|
||||
}
|
||||
|
||||
}
|
||||
package appeng.me.storage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.api.networking.storage.IStackWatcher;
|
||||
import appeng.api.networking.storage.IStackWatcherHost;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.me.cache.GridStorageCache;
|
||||
|
||||
/**
|
||||
* Maintain my interests, and a global watch list, they should always be fully synchronized.
|
||||
*/
|
||||
public class ItemWatcher implements IStackWatcher
|
||||
{
|
||||
|
||||
class ItemWatcherIterator implements Iterator<IAEStack>
|
||||
{
|
||||
|
||||
final ItemWatcher watcher;
|
||||
final Iterator<IAEStack> interestIterator;
|
||||
IAEStack myLast;
|
||||
|
||||
public ItemWatcherIterator(ItemWatcher parent, Iterator<IAEStack> i) {
|
||||
watcher = parent;
|
||||
interestIterator = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
return interestIterator.hasNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEStack next()
|
||||
{
|
||||
return myLast = interestIterator.next();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
gsc.interests.remove( myLast, watcher );
|
||||
interestIterator.remove();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
GridStorageCache gsc;
|
||||
IStackWatcherHost myObject;
|
||||
HashSet<IAEStack> myInterests = new HashSet();
|
||||
|
||||
public ItemWatcher(GridStorageCache cache, IStackWatcherHost host) {
|
||||
gsc = cache;
|
||||
myObject = host;
|
||||
}
|
||||
|
||||
public IStackWatcherHost getHost()
|
||||
{
|
||||
return myObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(IAEStack e)
|
||||
{
|
||||
if ( myInterests.contains( e ) )
|
||||
return false;
|
||||
|
||||
return myInterests.add( e.copy() ) && gsc.interests.put( e, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection<? extends IAEStack> c)
|
||||
{
|
||||
boolean didChange = false;
|
||||
|
||||
for (IAEStack o : c)
|
||||
didChange = add( o ) || didChange;
|
||||
|
||||
return didChange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
Iterator<IAEStack> i = myInterests.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
gsc.interests.remove( i.next(), this );
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o)
|
||||
{
|
||||
return myInterests.contains( o );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection<?> c)
|
||||
{
|
||||
return myInterests.containsAll( c );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return myInterests.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<IAEStack> iterator()
|
||||
{
|
||||
return new ItemWatcherIterator( this, myInterests.iterator() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o)
|
||||
{
|
||||
return myInterests.remove( o ) && gsc.interests.remove( o, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection<?> c)
|
||||
{
|
||||
boolean didSomething = false;
|
||||
for (Object o : c)
|
||||
didSomething = remove( o ) || didSomething;
|
||||
return didSomething;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection<?> c)
|
||||
{
|
||||
boolean changed = false;
|
||||
Iterator<IAEStack> i = iterator();
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
if ( !c.contains( i.next() ) )
|
||||
{
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size()
|
||||
{
|
||||
return myInterests.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray()
|
||||
{
|
||||
return myInterests.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T[] toArray(T[] a)
|
||||
{
|
||||
return myInterests.toArray( a );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package appeng.me.storage;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -29,7 +30,7 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack iox, Actionable mode)
|
||||
public IAEItemStack injectItems(IAEItemStack iox, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
ItemStack input = iox.getItemStack();
|
||||
|
||||
@@ -105,7 +106,7 @@ public class MEIInventoryWrapper implements IMEInventory<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
ItemStack Gathered = null;
|
||||
ItemStack Req = request.getItemStack();
|
||||
|
||||
@@ -3,6 +3,7 @@ package appeng.me.storage;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
@@ -33,18 +34,18 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
}
|
||||
|
||||
@Override
|
||||
public T injectItems(T input, Actionable type)
|
||||
public T injectItems(T input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
if ( !this.canAccept( input ) )
|
||||
return input;
|
||||
|
||||
return internal.injectItems( input, type );
|
||||
return internal.injectItems( input, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(T request, Actionable type)
|
||||
public T extractItems(T request, Actionable type, BaseActionSource src)
|
||||
{
|
||||
return internal.extractItems( request, type );
|
||||
return internal.extractItems( request, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,4 +100,9 @@ public class MEInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHa
|
||||
return internal.getSlot();
|
||||
}
|
||||
|
||||
public IMEInventory getInternal()
|
||||
{
|
||||
return internal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable type)
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
ItemStack out = null;
|
||||
|
||||
@@ -142,7 +142,7 @@ public class MEMonitorIInventory implements IMEInventory<IAEItemStack>, IMEMonit
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable type)
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable type, BaseActionSource src)
|
||||
{
|
||||
ItemStack out = null;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package appeng.me.storage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
@@ -28,15 +29,15 @@ public class MEPassthru<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
||||
}
|
||||
|
||||
@Override
|
||||
public T injectItems(T input, Actionable type)
|
||||
public T injectItems(T input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
return internal.injectItems( input, type );
|
||||
return internal.injectItems( input, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(T request, Actionable type)
|
||||
public T extractItems(T request, Actionable type, BaseActionSource src)
|
||||
{
|
||||
return internal.extractItems( request, type );
|
||||
return internal.extractItems( request, type, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package appeng.me.storage;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
|
||||
import com.google.common.collect.TreeMultimap;
|
||||
|
||||
public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInventoryHandler<T>
|
||||
{
|
||||
|
||||
@@ -28,27 +28,23 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
|
||||
};
|
||||
|
||||
private final static Comparator hashSorter = new Comparator<IMEInventoryHandler>() {
|
||||
|
||||
@Override
|
||||
public int compare(IMEInventoryHandler o1, IMEInventoryHandler o2)
|
||||
{
|
||||
return o1.hashCode() - o2.hashCode();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
final StorageChannel myChannel;
|
||||
final TreeMultimap<Integer, IMEInventoryHandler<T>> prorityInventory;
|
||||
// final TreeMultimap<Integer, IMEInventoryHandler<T>> prorityInventory;
|
||||
final TreeMap<Integer, List<IMEInventoryHandler<T>>> prorityInventory;
|
||||
|
||||
public NetworkInventoryHandler(StorageChannel chan) {
|
||||
myChannel = chan;
|
||||
prorityInventory = TreeMultimap.create( prioritySorter, hashSorter );
|
||||
prorityInventory = new TreeMap( prioritySorter ); // TreeMultimap.create( prioritySorter, hashSorter );
|
||||
}
|
||||
|
||||
public void addNewStorage(IMEInventoryHandler<T> h)
|
||||
{
|
||||
prorityInventory.put( h.getPriority(), h );
|
||||
int priority = h.getPriority();
|
||||
List<IMEInventoryHandler<T>> list = prorityInventory.get( priority );
|
||||
if ( list == null )
|
||||
prorityInventory.put( priority, list = new ArrayList() );
|
||||
|
||||
list.add( h );
|
||||
}
|
||||
|
||||
static int currentPass = 0;
|
||||
@@ -91,32 +87,32 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public T injectItems(T input, Actionable type)
|
||||
public T injectItems(T input, Actionable type, BaseActionSource src)
|
||||
{
|
||||
if ( diveList( this ) )
|
||||
return input;
|
||||
|
||||
Iterator<Entry<Integer, Collection<IMEInventoryHandler<T>>>> i = prorityInventory.asMap().entrySet().iterator();
|
||||
Iterator<List<IMEInventoryHandler<T>>> i = prorityInventory.values().iterator();// asMap().entrySet().iterator();
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<Integer, Collection<IMEInventoryHandler<T>>> invList = i.next();
|
||||
List<IMEInventoryHandler<T>> invList = i.next();
|
||||
|
||||
Iterator<IMEInventoryHandler<T>> ii = invList.getValue().iterator();
|
||||
Iterator<IMEInventoryHandler<T>> ii = invList.iterator();
|
||||
while (ii.hasNext() && input != null)
|
||||
{
|
||||
IMEInventoryHandler<T> inv = ii.next();
|
||||
|
||||
if ( inv.canAccept( input ) && (inv.extractItems( input, Actionable.SIMULATE ) != null || inv.isPrioritized( input )) )
|
||||
input = inv.injectItems( input, type );
|
||||
if ( inv.canAccept( input ) && (inv.extractItems( input, Actionable.SIMULATE, src ) != null || inv.isPrioritized( input )) )
|
||||
input = inv.injectItems( input, type, src );
|
||||
}
|
||||
|
||||
ii = invList.getValue().iterator();
|
||||
ii = invList.iterator();
|
||||
while (ii.hasNext() && input != null)
|
||||
{
|
||||
IMEInventoryHandler<T> inv = ii.next();
|
||||
if ( inv.canAccept( input ) )
|
||||
input = inv.injectItems( input, type );
|
||||
input = inv.injectItems( input, type, src );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,12 +122,12 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(T request, Actionable mode)
|
||||
public T extractItems(T request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( diveList( this ) )
|
||||
return null;
|
||||
|
||||
Iterator<Entry<Integer, Collection<IMEInventoryHandler<T>>>> i = prorityInventory.asMap().descendingMap().entrySet().iterator();
|
||||
Iterator<List<IMEInventoryHandler<T>>> i = prorityInventory.descendingMap().values().iterator();// prorityInventory.asMap().descendingMap().entrySet().iterator();
|
||||
|
||||
T output = request.copy();
|
||||
request = request.copy();
|
||||
@@ -140,15 +136,15 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
Entry<Integer, Collection<IMEInventoryHandler<T>>> invList = i.next();
|
||||
List<IMEInventoryHandler<T>> invList = i.next();
|
||||
|
||||
Iterator<IMEInventoryHandler<T>> ii = invList.getValue().iterator();
|
||||
Iterator<IMEInventoryHandler<T>> ii = invList.iterator();
|
||||
while (ii.hasNext() && output.getStackSize() < req)
|
||||
{
|
||||
IMEInventoryHandler<T> inv = ii.next();
|
||||
|
||||
request.setStackSize( req - output.getStackSize() );
|
||||
output.add( inv.extractItems( request, mode ) );
|
||||
output.add( inv.extractItems( request, mode, src ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,8 +162,10 @@ public class NetworkInventoryHandler<T extends IAEStack<T>> implements IMEInvent
|
||||
if ( diveIteration( this ) )
|
||||
return out;
|
||||
|
||||
for (Entry<Integer, IMEInventoryHandler<T>> h : prorityInventory.entries())
|
||||
out = h.getValue().getAvailableItems( out );
|
||||
// for (Entry<Integer, IMEInventoryHandler<T>> h : prorityInventory.entries())
|
||||
for (List<IMEInventoryHandler<T>> i : prorityInventory.values())
|
||||
for (IMEInventoryHandler<T> j : i)
|
||||
out = j.getAvailableItems( out );
|
||||
|
||||
surface( this );
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package appeng.me.storage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
@@ -17,13 +18,13 @@ public class NullInventory<T extends IAEStack<T>> implements IMEInventoryHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public T injectItems(T input, Actionable mode)
|
||||
public T injectItems(T input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T extractItems(T request, Actionable mode)
|
||||
public T extractItems(T request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package appeng.me.storage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
@@ -18,7 +19,7 @@ public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode)
|
||||
public IAEFluidStack injectItems(IAEFluidStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( input != null )
|
||||
target.addPower( (double) input.getStackSize() / 1000.0 );
|
||||
@@ -32,7 +33,7 @@ public class VoidFluidInventory implements IMEInventoryHandler<IAEFluidStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode)
|
||||
public IAEFluidStack extractItems(IAEFluidStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package appeng.me.storage;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.security.BaseActionSource;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
@@ -18,7 +19,7 @@ public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode)
|
||||
public IAEItemStack injectItems(IAEItemStack input, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
if ( input != null )
|
||||
target.addPower( input.getStackSize() );
|
||||
@@ -32,7 +33,7 @@ public class VoidItemInventory implements IMEInventoryHandler<IAEItemStack>
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode)
|
||||
public IAEItemStack extractItems(IAEItemStack request, Actionable mode, BaseActionSource src)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user