Reduced dependency scope of CompassReader

This commit is contained in:
thatsIch 2014-11-04 01:46:36 +01:00
parent dbbfb12cc2
commit f5823b6802
2 changed files with 12 additions and 10 deletions

View file

@ -251,7 +251,7 @@ public class CompassService implements ThreadFactory
if ( cr == null ) if ( cr == null )
{ {
cr = new CompassReader( w, rootFolder ); cr = new CompassReader( w.provider.dimensionId, rootFolder );
worldSet.put( w, cr ); worldSet.put( w, cr );
} }

View file

@ -3,24 +3,26 @@ package appeng.services.helpers;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
import net.minecraft.world.World;
public class CompassReader public class CompassReader
{ {
private final HashMap<Long, CompassRegion> regions = new HashMap<Long, CompassRegion>(); private final HashMap<Long, CompassRegion> regions = new HashMap<Long, CompassRegion>();
private final int id; private final int dimensionId;
private final File rootFolder; private final File rootFolder;
public void close() public void close()
{ {
for (CompassRegion r : regions.values()) for (CompassRegion r : this.regions.values())
{
r.close(); r.close();
}
regions.clear(); this.regions.clear();
} }
public CompassReader(World w, File rootFolder) { public CompassReader(int dimensionId, File rootFolder)
id = w.provider.dimensionId; {
this.dimensionId = dimensionId;
this.rootFolder = rootFolder; this.rootFolder = rootFolder;
} }
@ -42,11 +44,11 @@ public class CompassReader
pos = pos << 32; pos = pos << 32;
pos = pos | (cz >> 10); pos = pos | (cz >> 10);
CompassRegion cr = regions.get( pos ); CompassRegion cr = this.regions.get( pos );
if ( cr == null ) if ( cr == null )
{ {
cr = new CompassRegion( cx, cz, id, rootFolder ); cr = new CompassRegion( cx, cz, this.dimensionId, this.rootFolder );
regions.put( pos, cr ); this.regions.put( pos, cr );
} }
return cr; return cr;