Package appeng.services.helpers

Examples of appeng.services.helpers.CompassReader


    jobSize = 0;
  }

  private CompassReader getReader(World w)
  {
    CompassReader cr = worldSet.get( w );

    if ( cr == null )
    {
      cr = new CompassReader( w, rootFolder );
      worldSet.put( w, cr );
    }

    return cr;
  }
View Full Code Here


    @Override
    public void run()
    {
      jobSize--;

      CompassReader cr = getReader( world );
      cr.setHasBeacon( chunkX, chunkZ, doubleChunkY, value );

      if ( jobSize() < 2 )
        cleanUp();
    }
View Full Code Here

      jobSize--;

      int cx = coord.x >> 4;
      int cz = coord.z >> 4;

      CompassReader cr = getReader( coord.getWorld() );

      // Am I standing on it?
      if ( cr.hasBeacon( cx, cz ) )
      {
        callback.calculatedDirection( true, true, -999, 0 );

        if ( jobSize() < 2 )
          cleanUp();

        return;
      }

      // spiral outward...
      for (int offset = 1; offset < maxRange; offset++)
      {
        int minX = cx - offset;
        int minZ = cz - offset;
        int maxX = cx + offset;
        int maxZ = cz + offset;

        int closest = Integer.MAX_VALUE;
        int chosen_x = cx;
        int chosen_z = cz;

        for (int z = minZ; z <= maxZ; z++)
        {
          if ( cr.hasBeacon( minX, z ) )
          {
            int closeness = dist( cx, cz, minX, z );
            if ( closeness < closest )
            {
              closest = closeness;
              chosen_x = minX;
              chosen_z = z;
            }
          }

          if ( cr.hasBeacon( maxX, z ) )
          {
            int closeness = dist( cx, cz, maxX, z );
            if ( closeness < closest )
            {
              closest = closeness;
              chosen_x = maxX;
              chosen_z = z;
            }
          }
        }

        for (int x = minX + 1; x < maxX; x++)
        {
          if ( cr.hasBeacon( x, minZ ) )
          {
            int closeness = dist( cx, cz, x, minZ );
            if ( closeness < closest )
            {
              closest = closeness;
              chosen_x = x;
              chosen_z = minZ;
            }
          }

          if ( cr.hasBeacon( x, maxZ ) )
          {
            int closeness = dist( cx, cz, x, maxZ );
            if ( closeness < closest )
            {
              closest = closeness;
View Full Code Here

TOP

Related Classes of appeng.services.helpers.CompassReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.