reformatted all src files (#141)
This commit is contained in:
+11
-15
@@ -22,23 +22,19 @@ package appeng.me.cache.helpers;
|
||||
import appeng.api.networking.IGridConnection;
|
||||
|
||||
|
||||
public class ConnectionWrapper
|
||||
{
|
||||
public class ConnectionWrapper {
|
||||
|
||||
private IGridConnection connection;
|
||||
private IGridConnection connection;
|
||||
|
||||
public ConnectionWrapper( final IGridConnection gc )
|
||||
{
|
||||
this.setConnection( gc );
|
||||
}
|
||||
public ConnectionWrapper(final IGridConnection gc) {
|
||||
this.setConnection(gc);
|
||||
}
|
||||
|
||||
public IGridConnection getConnection()
|
||||
{
|
||||
return this.connection;
|
||||
}
|
||||
public IGridConnection getConnection() {
|
||||
return this.connection;
|
||||
}
|
||||
|
||||
public void setConnection( final IGridConnection connection )
|
||||
{
|
||||
this.connection = connection;
|
||||
}
|
||||
public void setConnection(final IGridConnection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
}
|
||||
+39
-50
@@ -19,70 +19,59 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.parts.p2p.PartP2PTunnelME;
|
||||
import appeng.util.IWorldCallable;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
|
||||
public class Connections implements IWorldCallable<Void>
|
||||
{
|
||||
public class Connections implements IWorldCallable<Void> {
|
||||
|
||||
private final HashMap<IGridNode, TunnelConnection> connections = new HashMap<>();
|
||||
private final PartP2PTunnelME me;
|
||||
private boolean create = false;
|
||||
private boolean destroy = false;
|
||||
private final HashMap<IGridNode, TunnelConnection> connections = new HashMap<>();
|
||||
private final PartP2PTunnelME me;
|
||||
private boolean create = false;
|
||||
private boolean destroy = false;
|
||||
|
||||
public Connections( final PartP2PTunnelME o )
|
||||
{
|
||||
this.me = o;
|
||||
}
|
||||
public Connections(final PartP2PTunnelME o) {
|
||||
this.me = o;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void call( final World world ) throws Exception
|
||||
{
|
||||
this.me.updateConnections( this );
|
||||
@Override
|
||||
public Void call(final World world) throws Exception {
|
||||
this.me.updateConnections(this);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void markDestroy()
|
||||
{
|
||||
this.setCreate( false );
|
||||
this.setDestroy( true );
|
||||
}
|
||||
public void markDestroy() {
|
||||
this.setCreate(false);
|
||||
this.setDestroy(true);
|
||||
}
|
||||
|
||||
public void markCreate()
|
||||
{
|
||||
this.setCreate( true );
|
||||
this.setDestroy( false );
|
||||
}
|
||||
public void markCreate() {
|
||||
this.setCreate(true);
|
||||
this.setDestroy(false);
|
||||
}
|
||||
|
||||
public HashMap<IGridNode, TunnelConnection> getConnections()
|
||||
{
|
||||
return this.connections;
|
||||
}
|
||||
public HashMap<IGridNode, TunnelConnection> getConnections() {
|
||||
return this.connections;
|
||||
}
|
||||
|
||||
public boolean isCreate()
|
||||
{
|
||||
return this.create;
|
||||
}
|
||||
public boolean isCreate() {
|
||||
return this.create;
|
||||
}
|
||||
|
||||
private void setCreate( final boolean create )
|
||||
{
|
||||
this.create = create;
|
||||
}
|
||||
private void setCreate(final boolean create) {
|
||||
this.create = create;
|
||||
}
|
||||
|
||||
public boolean isDestroy()
|
||||
{
|
||||
return this.destroy;
|
||||
}
|
||||
public boolean isDestroy() {
|
||||
return this.destroy;
|
||||
}
|
||||
|
||||
private void setDestroy( final boolean destroy )
|
||||
{
|
||||
this.destroy = destroy;
|
||||
}
|
||||
private void setDestroy(final boolean destroy) {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
}
|
||||
|
||||
+72
-90
@@ -19,124 +19,106 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
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;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
public class TickTracker implements Comparable<TickTracker>
|
||||
{
|
||||
public class TickTracker implements Comparable<TickTracker> {
|
||||
|
||||
private final TickingRequest request;
|
||||
private final IGridTickable gt;
|
||||
private final IGridNode node;
|
||||
private final TickingRequest request;
|
||||
private final IGridTickable gt;
|
||||
private final IGridNode node;
|
||||
|
||||
private final long LastFiveTicksTime = 0;
|
||||
private final long LastFiveTicksTime = 0;
|
||||
|
||||
private long lastTick;
|
||||
private int currentRate;
|
||||
private long lastTick;
|
||||
private int currentRate;
|
||||
|
||||
public TickTracker( final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick, final TickManagerCache tickManagerCache )
|
||||
{
|
||||
this.request = req;
|
||||
this.gt = gt;
|
||||
this.node = node;
|
||||
this.setCurrentRate( ( req.minTickRate + req.maxTickRate ) / 2 );
|
||||
this.setLastTick( currentTick );
|
||||
}
|
||||
public TickTracker(final TickingRequest req, final IGridNode node, final IGridTickable gt, final long currentTick, final TickManagerCache tickManagerCache) {
|
||||
this.request = req;
|
||||
this.gt = gt;
|
||||
this.node = node;
|
||||
this.setCurrentRate((req.minTickRate + req.maxTickRate) / 2);
|
||||
this.setLastTick(currentTick);
|
||||
}
|
||||
|
||||
public long getAvgNanos()
|
||||
{
|
||||
return( this.LastFiveTicksTime / 5 );
|
||||
}
|
||||
public long getAvgNanos() {
|
||||
return (this.LastFiveTicksTime / 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo( @Nonnull final TickTracker t )
|
||||
{
|
||||
int next = Long.compare( this.getNextTick(), t.getNextTick() );
|
||||
@Override
|
||||
public int compareTo(@Nonnull final TickTracker t) {
|
||||
int next = Long.compare(this.getNextTick(), t.getNextTick());
|
||||
|
||||
if( next != 0 )
|
||||
{
|
||||
return next;
|
||||
}
|
||||
if (next != 0) {
|
||||
return next;
|
||||
}
|
||||
|
||||
int last = Long.compare( this.getLastTick(), t.getLastTick() );
|
||||
int last = Long.compare(this.getLastTick(), t.getLastTick());
|
||||
|
||||
if( last != 0 )
|
||||
{
|
||||
return last;
|
||||
}
|
||||
if (last != 0) {
|
||||
return last;
|
||||
}
|
||||
|
||||
return Integer.compare( this.getCurrentRate(), t.getCurrentRate() );
|
||||
return Integer.compare(this.getCurrentRate(), t.getCurrentRate());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void addEntityCrashInfo( final CrashReportCategory crashreportcategory )
|
||||
{
|
||||
if( this.getGridTickable() instanceof AEBasePart )
|
||||
{
|
||||
final AEBasePart part = (AEBasePart) this.getGridTickable();
|
||||
part.addEntityCrashInfo( crashreportcategory );
|
||||
}
|
||||
public void addEntityCrashInfo(final CrashReportCategory crashreportcategory) {
|
||||
if (this.getGridTickable() instanceof AEBasePart) {
|
||||
final AEBasePart part = (AEBasePart) this.getGridTickable();
|
||||
part.addEntityCrashInfo(crashreportcategory);
|
||||
}
|
||||
|
||||
crashreportcategory.addCrashSection( "CurrentTickRate", this.getCurrentRate() );
|
||||
crashreportcategory.addCrashSection( "MinTickRate", this.getRequest().minTickRate );
|
||||
crashreportcategory.addCrashSection( "MaxTickRate", this.getRequest().maxTickRate );
|
||||
crashreportcategory.addCrashSection( "MachineType", this.getGridTickable().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "GridBlockType", this.getNode().getGridBlock().getClass().getName() );
|
||||
crashreportcategory.addCrashSection( "ConnectedSides", this.getNode().getConnectedSides() );
|
||||
crashreportcategory.addCrashSection("CurrentTickRate", this.getCurrentRate());
|
||||
crashreportcategory.addCrashSection("MinTickRate", this.getRequest().minTickRate);
|
||||
crashreportcategory.addCrashSection("MaxTickRate", this.getRequest().maxTickRate);
|
||||
crashreportcategory.addCrashSection("MachineType", this.getGridTickable().getClass().getName());
|
||||
crashreportcategory.addCrashSection("GridBlockType", this.getNode().getGridBlock().getClass().getName());
|
||||
crashreportcategory.addCrashSection("ConnectedSides", this.getNode().getConnectedSides());
|
||||
|
||||
final DimensionalCoord dc = this.getNode().getGridBlock().getLocation();
|
||||
if( dc != null )
|
||||
{
|
||||
crashreportcategory.addCrashSection( "Location", dc );
|
||||
}
|
||||
}
|
||||
final DimensionalCoord dc = this.getNode().getGridBlock().getLocation();
|
||||
if (dc != null) {
|
||||
crashreportcategory.addCrashSection("Location", dc);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentRate()
|
||||
{
|
||||
return this.currentRate;
|
||||
}
|
||||
public int getCurrentRate() {
|
||||
return this.currentRate;
|
||||
}
|
||||
|
||||
public void setCurrentRate( final int currentRate )
|
||||
{
|
||||
this.currentRate = Math.min( this.getRequest().maxTickRate, Math.max( this.getRequest().minTickRate, currentRate ) );
|
||||
}
|
||||
public void setCurrentRate(final int currentRate) {
|
||||
this.currentRate = Math.min(this.getRequest().maxTickRate, Math.max(this.getRequest().minTickRate, currentRate));
|
||||
}
|
||||
|
||||
public long getNextTick()
|
||||
{
|
||||
return this.lastTick + this.currentRate;
|
||||
}
|
||||
public long getNextTick() {
|
||||
return this.lastTick + this.currentRate;
|
||||
}
|
||||
|
||||
public long getLastTick()
|
||||
{
|
||||
return this.lastTick;
|
||||
}
|
||||
public long getLastTick() {
|
||||
return this.lastTick;
|
||||
}
|
||||
|
||||
public void setLastTick( final long lastTick )
|
||||
{
|
||||
this.lastTick = lastTick;
|
||||
}
|
||||
public void setLastTick(final long lastTick) {
|
||||
this.lastTick = lastTick;
|
||||
}
|
||||
|
||||
public IGridNode getNode()
|
||||
{
|
||||
return this.node;
|
||||
}
|
||||
public IGridNode getNode() {
|
||||
return this.node;
|
||||
}
|
||||
|
||||
public IGridTickable getGridTickable()
|
||||
{
|
||||
return this.gt;
|
||||
}
|
||||
public IGridTickable getGridTickable() {
|
||||
return this.gt;
|
||||
}
|
||||
|
||||
public TickingRequest getRequest()
|
||||
{
|
||||
return this.request;
|
||||
}
|
||||
public TickingRequest getRequest() {
|
||||
return this.request;
|
||||
}
|
||||
}
|
||||
|
||||
+32
-41
@@ -19,58 +19,49 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
import appeng.util.iterators.NullIterator;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T>
|
||||
{
|
||||
|
||||
private final Class clz;
|
||||
private Collection<T> tunnelSources;
|
||||
public class TunnelCollection<T extends PartP2PTunnel> implements Iterable<T> {
|
||||
|
||||
public TunnelCollection( final Collection<T> src, final Class c )
|
||||
{
|
||||
this.tunnelSources = src;
|
||||
this.clz = c;
|
||||
}
|
||||
private final Class clz;
|
||||
private Collection<T> tunnelSources;
|
||||
|
||||
public void setSource( final Collection<T> c )
|
||||
{
|
||||
this.tunnelSources = c;
|
||||
}
|
||||
public TunnelCollection(final Collection<T> src, final Class c) {
|
||||
this.tunnelSources = src;
|
||||
this.clz = c;
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
public void setSource(final Collection<T> c) {
|
||||
this.tunnelSources = c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator()
|
||||
{
|
||||
if( this.tunnelSources == null )
|
||||
{
|
||||
return new NullIterator<>();
|
||||
}
|
||||
return new TunnelIterator<>( this.tunnelSources, this.clz );
|
||||
}
|
||||
public boolean isEmpty() {
|
||||
return !this.iterator().hasNext();
|
||||
}
|
||||
|
||||
public boolean matches( final Class<? extends PartP2PTunnel> c )
|
||||
{
|
||||
return this.clz == c;
|
||||
}
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
if (this.tunnelSources == null) {
|
||||
return new NullIterator<>();
|
||||
}
|
||||
return new TunnelIterator<>(this.tunnelSources, this.clz);
|
||||
}
|
||||
|
||||
public Class<? extends PartP2PTunnel> getClz()
|
||||
{
|
||||
return this.clz;
|
||||
}
|
||||
public boolean matches(final Class<? extends PartP2PTunnel> c) {
|
||||
return this.clz == c;
|
||||
}
|
||||
|
||||
public int size()
|
||||
{
|
||||
return this.tunnelSources == null ? 0 : this.tunnelSources.size();
|
||||
}
|
||||
public Class<? extends PartP2PTunnel> getClz() {
|
||||
return this.clz;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.tunnelSources == null ? 0 : this.tunnelSources.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
-17
@@ -23,25 +23,21 @@ import appeng.api.networking.IGridConnection;
|
||||
import appeng.parts.p2p.PartP2PTunnelME;
|
||||
|
||||
|
||||
public class TunnelConnection
|
||||
{
|
||||
public class TunnelConnection {
|
||||
|
||||
private final PartP2PTunnelME tunnel;
|
||||
private final IGridConnection c;
|
||||
private final PartP2PTunnelME tunnel;
|
||||
private final IGridConnection c;
|
||||
|
||||
public TunnelConnection( final PartP2PTunnelME t, final IGridConnection con )
|
||||
{
|
||||
this.tunnel = t;
|
||||
this.c = con;
|
||||
}
|
||||
public TunnelConnection(final PartP2PTunnelME t, final IGridConnection con) {
|
||||
this.tunnel = t;
|
||||
this.c = con;
|
||||
}
|
||||
|
||||
public IGridConnection getConnection()
|
||||
{
|
||||
return this.c;
|
||||
}
|
||||
public IGridConnection getConnection() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public PartP2PTunnelME getTunnel()
|
||||
{
|
||||
return this.tunnel;
|
||||
}
|
||||
public PartP2PTunnelME getTunnel() {
|
||||
return this.tunnel;
|
||||
}
|
||||
}
|
||||
+34
-42
@@ -19,56 +19,48 @@
|
||||
package appeng.me.cache.helpers;
|
||||
|
||||
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
import appeng.parts.p2p.PartP2PTunnel;
|
||||
|
||||
public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T> {
|
||||
|
||||
public class TunnelIterator<T extends PartP2PTunnel> implements Iterator<T>
|
||||
{
|
||||
private final Iterator<T> wrapped;
|
||||
private final Class targetType;
|
||||
private T Next;
|
||||
|
||||
private final Iterator<T> wrapped;
|
||||
private final Class targetType;
|
||||
private T Next;
|
||||
public TunnelIterator(final Collection<T> tunnelSources, final Class clz) {
|
||||
this.wrapped = tunnelSources.iterator();
|
||||
this.targetType = clz;
|
||||
this.findNext();
|
||||
}
|
||||
|
||||
public TunnelIterator( final Collection<T> tunnelSources, final Class clz )
|
||||
{
|
||||
this.wrapped = tunnelSources.iterator();
|
||||
this.targetType = clz;
|
||||
this.findNext();
|
||||
}
|
||||
private void findNext() {
|
||||
while (this.Next == null && this.wrapped.hasNext()) {
|
||||
this.Next = this.wrapped.next();
|
||||
if (!this.targetType.isInstance(this.Next)) {
|
||||
this.Next = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void findNext()
|
||||
{
|
||||
while( this.Next == null && this.wrapped.hasNext() )
|
||||
{
|
||||
this.Next = this.wrapped.next();
|
||||
if( !this.targetType.isInstance( this.Next ) )
|
||||
{
|
||||
this.Next = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
this.findNext();
|
||||
return this.Next != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNext()
|
||||
{
|
||||
this.findNext();
|
||||
return this.Next != null;
|
||||
}
|
||||
@Override
|
||||
public T next() {
|
||||
final T tmp = this.Next;
|
||||
this.Next = null;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T next()
|
||||
{
|
||||
final T tmp = this.Next;
|
||||
this.Next = null;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
// no.
|
||||
}
|
||||
@Override
|
||||
public void remove() {
|
||||
// no.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user