pick 97420a31d The big reformat of 2020
This commit is contained in:
@@ -18,62 +18,53 @@
|
||||
|
||||
package appeng.services.compass;
|
||||
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
public final class CompassReader
|
||||
{
|
||||
private final Map<Long, CompassRegion> regions = new HashMap<>( 100 );
|
||||
private final ServerWorld world;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
|
||||
public CompassReader( ServerWorld world )
|
||||
{
|
||||
this.world = Preconditions.checkNotNull( world );
|
||||
}
|
||||
public final class CompassReader {
|
||||
private final Map<Long, CompassRegion> regions = new HashMap<>(100);
|
||||
private final ServerWorld world;
|
||||
|
||||
public void close()
|
||||
{
|
||||
for( final CompassRegion r : this.regions.values() )
|
||||
{
|
||||
r.close();
|
||||
}
|
||||
public CompassReader(ServerWorld world) {
|
||||
this.world = Preconditions.checkNotNull(world);
|
||||
}
|
||||
|
||||
this.regions.clear();
|
||||
}
|
||||
public void close() {
|
||||
for (final CompassRegion r : this.regions.values()) {
|
||||
r.close();
|
||||
}
|
||||
|
||||
public void setHasBeacon( final int cx, final int cz, final int cdy, final boolean hasBeacon )
|
||||
{
|
||||
final CompassRegion r = this.getRegion( cx, cz );
|
||||
this.regions.clear();
|
||||
}
|
||||
|
||||
r.setHasBeacon( cx, cz, cdy, hasBeacon );
|
||||
}
|
||||
public void setHasBeacon(final int cx, final int cz, final int cdy, final boolean hasBeacon) {
|
||||
final CompassRegion r = this.getRegion(cx, cz);
|
||||
|
||||
public boolean hasBeacon( final int cx, final int cz )
|
||||
{
|
||||
final CompassRegion r = this.getRegion( cx, cz );
|
||||
r.setHasBeacon(cx, cz, cdy, hasBeacon);
|
||||
}
|
||||
|
||||
return r.hasBeacon( cx, cz );
|
||||
}
|
||||
public boolean hasBeacon(final int cx, final int cz) {
|
||||
final CompassRegion r = this.getRegion(cx, cz);
|
||||
|
||||
private CompassRegion getRegion( final int cx, final int cz )
|
||||
{
|
||||
long pos = cx >> 10;
|
||||
pos <<= 32;
|
||||
pos |= ( cz >> 10 );
|
||||
return r.hasBeacon(cx, cz);
|
||||
}
|
||||
|
||||
CompassRegion cr = this.regions.get( pos );
|
||||
private CompassRegion getRegion(final int cx, final int cz) {
|
||||
long pos = cx >> 10;
|
||||
pos <<= 32;
|
||||
pos |= (cz >> 10);
|
||||
|
||||
if( cr == null )
|
||||
{
|
||||
cr = new CompassRegion( world, cx, cz );
|
||||
this.regions.put( pos, cr );
|
||||
}
|
||||
CompassRegion cr = this.regions.get(pos);
|
||||
|
||||
return cr;
|
||||
}
|
||||
if (cr == null) {
|
||||
cr = new CompassRegion(world, cx, cz);
|
||||
this.regions.put(pos, cr);
|
||||
}
|
||||
|
||||
return cr;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user