// Path: src/nbt/map/pos/ChunkPosition.java
// public final class ChunkPosition extends Pair {
// 
//   /**
//    * Creates an own chunk position.
//    * 
//    * @param x The x coordinate.
//    * @param z The z coordinate.
//    */
//   public ChunkPosition(final int x, final int z) {
//     super(x, z);
//   }
// 
// }
// 
// Path: src/nbt/map/pos/InChunkPosition.java
// public class InChunkPosition extends Pair {
// 
//   /**
//    * Creates an in-chunk position.
//    * 
//    * @param x The x coordinate.
//    * @param z The z coordinate.
//    */
//   public InChunkPosition(final int x, final int z) {
//     super(x, z);
//   }
// 
// }


import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import nbt.map.pos.ChunkPosition;
import nbt.map.pos.InChunkPosition;
  private final Object drawLock = new Object();

  private final UpdateReceiver user;

  private final Image loading;

  /**
   * Creates a chunk painter.
   * 
   * @param user The user that is notified when something changes.
   * @param scale The scaling factor.
   */
  public ChunkPainter(final UpdateReceiver user, final double scale) {
    this.user = user;
    this.scale = scale;
    loading = createLoadingImage();
    int numThreads = Math.max(Runtime.getRuntime().availableProcessors(), 2);
    System.out.println("Using " + numThreads + " image loader");
    while(--numThreads >= 0) {
      startOneImageThread();
    }
  }

  private void drawChunk(final Chunk chunk) {
    final BufferedImage img =
        new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
    final Graphics2D gi = (Graphics2D) img.getGraphics();
    for(int x = 0; x < 16; ++x) {
      for(int z = 0; z < 16; ++z) {
        final Rectangle2D rect = new Rectangle2D.Double(x, z, 1, 1);
// Path: src/nbt/map/pos/ChunkPosition.java
// public final class ChunkPosition extends Pair {
// 
//   /**
//    * Creates an own chunk position.
//    * 
//    * @param x The x coordinate.
//    * @param z The z coordinate.
//    */
//   public ChunkPosition(final int x, final int z) {
//     super(x, z);
//   }
// 
// }
// 
// Path: src/nbt/map/pos/InChunkPosition.java
// public class InChunkPosition extends Pair {
// 
//   /**
//    * Creates an in-chunk position.
//    * 
//    * @param x The x coordinate.
//    * @param z The z coordinate.
//    */
//   public InChunkPosition(final int x, final int z) {
//     super(x, z);
//   }
// 
// }


// Path: src/nbt/map/ChunkPainter.java
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import nbt.map.pos.ChunkPosition;
import nbt.map.pos.InChunkPosition;

  private final Object drawLock = new Object();

  private final UpdateReceiver user;

  private final Image loading;

  /**
   * Creates a chunk painter.
   * 
   * @param user The user that is notified when something changes.
   * @param scale The scaling factor.
   */
  public ChunkPainter(final UpdateReceiver user, final double scale) {
    this.user = user;
    this.scale = scale;
    loading = createLoadingImage();
    int numThreads = Math.max(Runtime.getRuntime().availableProcessors(), 2);
    System.out.println("Using " + numThreads + " image loader");
    while(--numThreads >= 0) {
      startOneImageThread();
    }
  }

  private void drawChunk(final Chunk chunk) {
    final BufferedImage img =
        new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
    final Graphics2D gi = (Graphics2D) img.getGraphics();
    for(int x = 0; x < 16; ++x) {
      for(int z = 0; z < 16; ++z) {
        final Rectangle2D rect = new Rectangle2D.Double(x, z, 1, 1);
        final InChunkPosition pos = new InChunkPosition(x, z);