Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
import appeng.api.networking.IGridConnection;
|
||||
|
||||
public class ConnectionWrapper
|
||||
{
|
||||
|
||||
public IGridConnection connection;
|
||||
|
||||
public ConnectionWrapper(IGridConnection gc) {
|
||||
connection = gc;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.parts.p2p.PartP2PTunnelME;
|
||||
|
||||
public class Connections implements Callable
|
||||
{
|
||||
|
||||
final private PartP2PTunnelME me;
|
||||
final public HashMap<IGridNode, TunnelConnection> connections = new HashMap();
|
||||
|
||||
public boolean create = false;
|
||||
public boolean destroy = false;
|
||||
|
||||
public Connections(PartP2PTunnelME o) {
|
||||
me = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object call() throws Exception
|
||||
{
|
||||
me.updateConnections( this );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void markDestroy()
|
||||
{
|
||||
create = false;
|
||||
destroy = true;
|
||||
}
|
||||
|
||||
public void markCreate()
|
||||
{
|
||||
create = true;
|
||||
destroy = false;
|
||||
}
|
||||
|
||||
};
|
||||
@@ -0,0 +1,76 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.ticking.IGridTickable;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.me.cache.TickManagerCache;
|
||||
import appeng.parts.AEBasePart;
|
||||
|
||||
public class TickTracker implements Comparable<TickTracker>
|
||||
{
|
||||
|
||||
public final TickingRequest request;
|
||||
public final IGridTickable gt;
|
||||
public final IGridNode node;
|
||||
public final TickManagerCache host;
|
||||
|
||||
public long LastFiveTicksTime = 0;
|
||||
|
||||
public long lastTick;
|
||||
public int current_rate;
|
||||
|
||||
public TickTracker(TickingRequest req, IGridNode node, IGridTickable gt, long currentTick, TickManagerCache tickManagerCache) {
|
||||
request = req;
|
||||
this.gt = gt;
|
||||
this.node = node;
|
||||
current_rate = (req.minTickRate + req.maxTickRate) / 2;
|
||||
lastTick = currentTick;
|
||||
host = tickManagerCache;
|
||||
}
|
||||
|
||||
public long getAvgNanos()
|
||||
{
|
||||
return (LastFiveTicksTime / 5);
|
||||
}
|
||||
|
||||
public void setRate(int rate)
|
||||
{
|
||||
current_rate = rate;
|
||||
|
||||
if ( current_rate < request.minTickRate )
|
||||
current_rate = request.minTickRate;
|
||||
|
||||
if ( current_rate > request.maxTickRate )
|
||||
current_rate = request.maxTickRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TickTracker t)
|
||||
{
|
||||
int nextTick = (int) ((lastTick - host.getCurrentTick()) + current_rate);
|
||||
int ts_nextTick = (int) ((t.lastTick - host.getCurrentTick()) + t.current_rate);
|
||||
return nextTick - ts_nextTick;
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo(CrashReportCategory crashreportcategory)
|
||||
{
|
||||
if ( gt instanceof AEBasePart )
|
||||
{
|
||||
AEBasePart part = (AEBasePart)gt;
|
||||
part.addEntityCrashInfo( crashreportcategory );
|
||||
}
|
||||
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", current_rate );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", request.minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", request.maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", gt.getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", node.getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", node.getConnectedSides() );
|
||||
|
||||
DimensionalCoord dc = node.getGridBlock().getLocation();
|
||||
if ( dc != null )
|
||||
crashreportcategory.addCrashSection( "Location", dc );
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
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();
|
||||
}
|
||||
|
||||
public boolean matches(Class<? extends PartP2PTunnel> c)
|
||||
{
|
||||
return clz == c;
|
||||
}
|
||||
|
||||
public Class<? extends PartP2PTunnel> getClz()
|
||||
{
|
||||
return clz;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
import appeng.api.networking.IGridConnection;
|
||||
import appeng.parts.p2p.PartP2PTunnelME;
|
||||
|
||||
public class TunnelConnection
|
||||
{
|
||||
|
||||
final public PartP2PTunnelME tunnel;
|
||||
final public IGridConnection c;
|
||||
|
||||
public TunnelConnection(PartP2PTunnelME t, IGridConnection con) {
|
||||
tunnel = t;
|
||||
c = con;
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user