Beispiel #1
0
  public BufferedImage renderFullImage() {
    int scrollX = (int) (getScrollPosition(Orientation.HORIZONTAL) / scale);
    int scrollY = (int) (getScrollPosition(Orientation.VERTICAL) / scale);

    int minChunkX = heightMap.getMinX() + scrollX / 16,
        minChunkZ = heightMap.getMinZ() + scrollY / 16,
        maxChunkX = 0,
        maxChunkZ = 0;
    int horiz = (int) (getWidth() / 16 / scale) + 1;
    int vert = (int) (getHeight() / 16 / scale) + 1;
    maxChunkX = minChunkX + horiz;
    maxChunkZ = minChunkZ + vert;

    minChunkX++;
    minChunkZ++;
    BufferedImage fullImage =
        new BufferedImage(
            (maxChunkX - minChunkX) * 16 + 32,
            (maxChunkZ - minChunkZ) * 16 + 32,
            BufferedImage.TYPE_INT_ARGB);
    for (int chunkX = minChunkX; chunkX <= maxChunkX; chunkX++) {
      for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; chunkZ++) {
        Map map = drawChunk(chunkX, chunkZ, dirty);
        if (map != null && map != blankMap) {
          Raster raster = map.getColorRaster();
          int startX = (chunkX - minChunkX) * 16;
          int startZ = (chunkZ - minChunkZ) * 16;
          java.awt.image.DataBufferInt buf = (java.awt.image.DataBufferInt) raster.getDataBuffer();
          int[] srcbuf = buf.getData();
          fullImage.setRGB(startX, startZ, 16, 16, srcbuf, 0, 16);
        }
      }
    }
    return fullImage;
  }
Beispiel #2
0
 @Override
 public int getInnerSize(Orientation axis) {
   if (axis == Orientation.HORIZONTAL) {
     return (int) ((double) (heightMap.getMaxX() - heightMap.getMinX() + 1) * scale * 16d);
   } else {
     return (int) ((double) (heightMap.getMaxZ() - heightMap.getMinZ() + 1) * scale * 16d) + 30;
   }
 }
Beispiel #3
0
 public Point mapCoordsToOutside(Point coords) {
   int x = coords.getX();
   int y = coords.getY();
   x -= heightMap.getMinX() * 16;
   y -= heightMap.getMinZ() * 16;
   x *= scale;
   y *= scale;
   return new Point(x, y);
 }
Beispiel #4
0
 public Point mapOutsideToCoords(Point outside) {
   int x = outside.getX() + scrollX;
   int y = outside.getY() + scrollY;
   x /= scale;
   y /= scale;
   x += heightMap.getMinX() * 16;
   y += heightMap.getMinZ() * 16;
   return new Point(x, y);
 }
Beispiel #5
0
  public static Map drawChunk(int x, int z, boolean force) {
    synchronized (chunks) {
      Map map = chunks.get(levelOfDetail).get(x, z);
      if (map == null || (force && map == blankMap)) {
        map = new Map(16);
        map.originOffsetX = 0;
        map.originOffsetY = 0;
        map.renderSize = 16;
      } else if (!force) {
        return map;
      }
      boolean pixelSet = false;
      try {
        for (int cx = 0; cx < 16; cx++) {
          for (int cz = 0; cz < 16; cz++) {

            int aX = x * 16 + cx * levelOfDetail;
            int aZ = z * 16 + cz * levelOfDetail;

            short height = heightMap.getHeight(aX, aZ);
            byte id = heightMap.getBlockId(aX, aZ);
            if (id == -1 || height == -1) {
              continue;
            } else {
              pixelSet = true;
            }

            if (levelOfDetail <= 2) {
              short reference = heightMap.getHeight(aX + levelOfDetail, aZ + levelOfDetail);
              int color = MapCalculator.getHeightColor(height, reference);
              map.heightimg.setARGB(cx, cz, color);
            }

            map.setColorPixel(cz, cx, BlockColor.getBlockColor(id, 0).color | 0xff000000);
          }
        }
      } catch (Exception e) {
        pixelSet = false;
      }
      if (pixelSet) {
        getChunkMap(levelOfDetail).put(x, z, map);
      } else {
        getChunkMap(levelOfDetail).put(x, z, blankMap);
      }
      return map;
    }
  }
Beispiel #6
0
 private void drawPOI(String name, int x, int z, int color) {
   int mouseX =
       (int) ((getScreen().getMouseX() - getX() + scrollX) / scale + heightMap.getMinX() * 16);
   int mouseY =
       (int) ((getScreen().getMouseY() - getY() + scrollY) / scale + heightMap.getMinZ() * 16);
   int radius = (int) (2f / scale);
   if (radius <= 0) {
     radius = 2;
   }
   int mouseRadius = radius * 2;
   if (parent.isInBoundingRect(
       x - mouseRadius, z - mouseRadius, mouseRadius * 2, mouseRadius * 2, mouseX, mouseY)) {
     color = 0xff0000ff;
     parent.drawTooltip(name, x, z);
   }
   RenderUtil.drawRectangle(x - radius, z - radius, x + radius, z + radius, color);
 }
Beispiel #7
0
  public MapWidget(GuiScreen parent) {
    if (renderer == null) {
      renderer = new MapWidgetRenderer();
      renderer.start();
    }
    levelOfDetail = 1;
    this.parent = parent;
    HeightMap newheightMap = HeightMap.getHeightMap(MinimapUtils.getWorldName());
    if (newheightMap != heightMap) {
      chunks.clear();
      heightMap = newheightMap;
    }

    addProperty(
        "scale",
        new Property() {

          @Override
          public void set(Object value) {
            setScale((double) (Double) value);
          }

          @Override
          public Object get() {
            return getScale();
          }
        });

    addProperty(
        "scrollpos",
        new Property() {

          @Override
          public void set(Object value) {
            Point p = (Point) value;
            scrollTo(p, false, 0);
          }

          @Override
          public Object get() {
            return mapOutsideToCoords(new Point(0, 0));
          }
        });

    setScrollBarPolicy(Orientation.HORIZONTAL, ScrollBarPolicy.SHOW_NEVER);
    setScrollBarPolicy(Orientation.VERTICAL, ScrollBarPolicy.SHOW_NEVER);
  }
Beispiel #8
0
  @Override
  public void renderContents() {
    GL11.glDisable(2929);
    GL11.glEnable(3042);
    GL11.glDepthMask(false);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    int scrollX = (int) (getScrollPosition(Orientation.HORIZONTAL) / scale);
    int scrollY = (int) (getScrollPosition(Orientation.VERTICAL) / scale);

    GL11.glScaled(scale, scale, scale);
    GL11.glTranslatef(-heightMap.getMinX() * 16, -heightMap.getMinZ() * 16, 0);

    int minChunkX = heightMap.getMinX() + scrollX / 16,
        minChunkZ = heightMap.getMinZ() + scrollY / 16,
        maxChunkX = 0,
        maxChunkZ = 0;
    int horiz = (int) (getWidth() / 16 / scale) + 1;
    int vert = (int) (getHeight() / 16 / scale) + 1;
    maxChunkX = minChunkX + horiz;
    maxChunkZ = minChunkZ + vert;

    minChunkX = Math.max(minChunkX, heightMap.getMinX());
    minChunkZ = Math.max(minChunkZ, heightMap.getMinZ());
    maxChunkX = Math.min(maxChunkX, heightMap.getMaxX());
    maxChunkZ = Math.min(maxChunkZ, heightMap.getMaxZ());

    GL11.glPushMatrix();
    synchronized (chunks) {
      for (int chunkX = minChunkX; chunkX <= maxChunkX; chunkX += levelOfDetail) {
        for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; chunkZ += levelOfDetail) {
          Map map = getChunkMap(levelOfDetail).get(chunkX, chunkZ);
          if (dirty || map == null || random.nextInt(10000) == 0) {
            renderer.renderQueue.add(new Point(chunkX, chunkZ));
          }
          if (map != null && map != blankMap) {
            GL11.glPushMatrix();
            int x = chunkX * 16;
            int y = chunkZ * 16;
            int width = x + 16 * levelOfDetail;
            int height = y + 16 * levelOfDetail;
            map.loadColorImage();
            MinecraftTessellator tessellator = Spoutcraft.getTessellator();
            tessellator.startDrawingQuads();
            tessellator.addVertexWithUV((double) width, (double) height, -90, 1, 1);
            tessellator.addVertexWithUV((double) width, (double) y, -90, 1, 0);
            tessellator.addVertexWithUV((double) x, (double) y, -90, 0, 0);
            tessellator.addVertexWithUV((double) x, (double) height, -90, 0, 1);
            tessellator.draw();
            //					GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            //					RenderUtil.drawRectangle(x, y, width, height, 0x88ffffff);
            if (MinimapConfig.getInstance().isHeightmap()) {
              GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_COLOR);
              map.loadHeightImage();
              tessellator.startDrawingQuads();
              tessellator.addVertexWithUV((double) width, (double) height, -90, 1, 1);
              tessellator.addVertexWithUV((double) width, (double) y, -90, 1, 0);
              tessellator.addVertexWithUV((double) x, (double) y, -90, 0, 0);
              tessellator.addVertexWithUV((double) x, (double) height, -90, 0, 1);
              tessellator.draw();
            }
            GL11.glPopMatrix();
          }
        }
      }
    }
    int x = (int) SpoutClient.getHandle().thePlayer.posX;
    int z = (int) SpoutClient.getHandle().thePlayer.posZ;

    drawPOI("You", x, z, 0xffff0000);

    for (Waypoint waypoint :
        MinimapConfig.getInstance().getAllWaypoints(MinimapUtils.getWorldName())) {
      if (!waypoint.deathpoint || MinimapConfig.getInstance().isDeathpoints()) {
        drawPOI(waypoint.name, waypoint.x, waypoint.z, 0xff00ff00);
      }
    }

    if (MinimapConfig.getInstance().getFocussedWaypoint() != null) {
      Waypoint pos = MinimapConfig.getInstance().getFocussedWaypoint();
      drawPOI("Marker", pos.x, pos.z, 0xff00ffff);
    }

    GL11.glPopMatrix();
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glEnable(2929);
    GL11.glDisable(3042);
    dirty = false;

    Point newpos = getPlayerPosition();
    if (lastPlayerPos.getX() != newpos.getX() || lastPlayerPos.getY() != newpos.getY()) {
      showPlayer(0);
      lastPlayerPos = newpos;
    }
  }
Beispiel #9
0
  public static int getHeightColor(int x, int z, HeightMap heightMap) {
    short height = heightMap.getHeight(x, z);
    short reference = heightMap.getHeight(x + 1, z + 1);

    return getHeightColor(height, reference);
  }