Example #1
0
 private void drawCircle(int x, int y, int radius, int color) {
   try {
     for (int dx = -radius; dx <= radius; dx++) {
       for (int dy = -radius; dy <= radius; dy++) {
         if (x + dx < map.renderSize && x + dx > 0 && y + dy < map.renderSize && y + dy > 0) {
           if (MinimapUtils.insideCircle(x, y, radius, x + dx, y + dy)) {
             map.setColorPixel(x + dx, y + dy, color);
           }
         }
       }
     }
   } catch (ArrayIndexOutOfBoundsException ignore) {
   } // happens with fast movement
 }
Example #2
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);
  }
Example #3
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;
    }
  }
Example #4
0
  private void mapCalc() {
    if (Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null)
      return;
    try {
      final boolean square = MinimapConfig.getInstance().isSquare();
      final World data = Minecraft.getMinecraft().theWorld;
      int renderSize;
      int startX;
      int startZ;
      synchronized (map) {
        if (map.zoom != MinimapConfig.getInstance().getZoom()) {
          map.zoom = MinimapConfig.getInstance().getZoom();
          switch (map.zoom) {
            case 0:
              map.renderSize = Map.ZOOM_0;
              break;
            case 1:
              map.renderSize = Map.ZOOM_1;
              break;
            case 2:
              map.renderSize = Map.ZOOM_2;
              break;
            default:
              map.renderSize = Map.ZOOM_2;
              break;
          }
          map.renderOff = map.renderSize / 2;
          map.clear();
        }
        map.square = square;

        map.update(
            Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posZ);
        renderSize = map.renderSize;
        startX = (int) (map.getPlayerX() - map.renderOff);
        startZ = (int) (map.getPlayerZ() - map.renderOff);
      }

      for (int worldX = startX; worldX < startX + renderSize; worldX++) {
        for (int worldZ = startZ; worldZ < startZ + renderSize; worldZ++) {
          int worldY = getBlockHeight(data, worldX, worldZ);

          int pixelX = worldX - startX;
          if (pixelX >= renderSize) {
            pixelX -= renderSize;
          }

          int pixelZ = worldZ - startZ;
          pixelZ = renderSize - pixelZ;
          if (pixelZ >= renderSize) {
            pixelZ -= renderSize;
          }

          if (square
              || MinimapUtils.insideCircle(
                  startX + renderSize / 2,
                  startZ + renderSize / 2,
                  renderSize / 2,
                  worldX,
                  worldZ)) {
            int color = getBlockColor(data, worldX, worldY, worldZ);
            if (color == 0) {
              map.clearColorPixel(pixelX, pixelZ);
            } else {
              map.setColorPixel(pixelX, pixelZ, color);
            }

            short height = (short) data.getHeightValue(worldX, worldZ);
            short reference = (short) data.getHeightValue(worldX + 1, worldZ + 1);
            map.heightimg.setARGB(pixelZ, pixelX, getHeightColor(height, reference));
            map.setLightPixel(pixelX, pixelZ, getBlockLight(data, worldX, worldY, worldZ));

          } else {
            map.clearColorPixel(pixelX, pixelZ);
            map.heightimg.setARGB(pixelX, pixelZ, 0);
            map.setLightPixel(pixelX, pixelZ, 255);
          }
        }
      }

      synchronized (map) {
        for (Waypoint pt : MinimapConfig.getInstance().getWaypoints(MinimapUtils.getWorldName())) {
          if (pt.enabled) {
            boolean render = false;
            if (square) {
              render =
                  Math.abs(map.getPlayerX() - pt.x) < map.renderSize
                      && Math.abs(map.getPlayerZ() - pt.z) < map.renderSize;
            } else {
              render =
                  MinimapUtils.insideCircle(
                      startX + map.renderSize / 2,
                      startZ + map.renderSize / 2,
                      map.renderSize / 2,
                      pt.x,
                      pt.z);
            }
            if (pt.deathpoint && !MinimapConfig.getInstance().isDeathpoints()) {
              render = false;
            }
            if (render) {
              int pixelX = pt.x - startX;

              int pixelZ = pt.z - startZ;
              pixelZ = map.renderSize - pixelZ;

              int scale = map.zoom + 2;
              if (map.zoom > 2) {
                scale += 2;
              }
              if (map.zoom > 1) {
                scale += 1;
              }

              int color = 0xEE2C2C;
              if (pt == MinimapConfig.getInstance().getFocussedWaypoint()) {
                color = 0xff00ffff;
              }
              drawCircle(pixelX, pixelZ, scale + map.zoom + 1, pt.deathpoint ? color : 0);
              drawCircle(pixelX, pixelZ, scale, pt.deathpoint ? 0 : color);
            }
          }
        }
        for (Waypoint pt : MinimapConfig.getInstance().getServerWaypoints()) {
          boolean render = false;
          if (square) {
            render =
                Math.abs(map.getPlayerX() - pt.x) < map.renderSize
                    && Math.abs(map.getPlayerZ() - pt.z) < map.renderSize;
          } else {
            render =
                MinimapUtils.insideCircle(
                    startX + map.renderSize / 2,
                    startZ + map.renderSize / 2,
                    map.renderSize / 2,
                    pt.x,
                    pt.z);
          }
          if (render) {
            int pixelX = pt.x - startX;

            int pixelZ = pt.z - startZ;
            pixelZ = map.renderSize - pixelZ;

            int scale = map.zoom + 2;
            if (map.zoom > 2) {
              scale += 2;
            }
            if (map.zoom > 1) {
              scale += 1;
            }

            int color = 0x3366CC;
            if (pt == MinimapConfig.getInstance().getFocussedWaypoint()) {
              color = 0xff00ffff;
            }
            drawCircle(pixelX, pixelZ, scale + map.zoom + 1, 0);
            drawCircle(pixelX, pixelZ, scale, color);
          }
        }
      }
    } catch (Throwable whatever) {
    }
  }