Esempio n. 1
0
  @Override
  protected void executeAction() {
    MinimapConfig.initialize(false);
    MinimapConfig.getInstance().save();

    SpoutClient.getHandle().displayGuiScreen(new GuiMinimapMenu(parent.parent));
  }
Esempio n. 2
0
 private void entityCalc() {
   synchronized (map.watchedEntities) {
     map.watchedEntities.clear();
     if (!Spoutcraft.hasPermission("spout.plugin.minimap.showentities")) {
       return;
     }
     if (!MinimapConfig.getInstance().isShowingEntities()) {
       return;
     }
     int radius = map.renderSize / 2;
     double playerX = map.getPlayerX();
     double playerZ = map.getPlayerZ();
     for (Object ob :
         SpoutClient.getHandle()
             .theWorld
             .getEntitiesWithinAABB(
                 EntityLiving.class,
                 AxisAlignedBB.getBoundingBox(
                     playerX - radius,
                     0,
                     playerZ - radius,
                     playerX + radius,
                     256,
                     playerZ + radius))) {
       net.minecraft.src.Entity e = (net.minecraft.src.Entity) ob;
       if (!MinimapConfig.getInstance().isEntityVisible(e.getClass())) {
         continue;
       }
       WatchedEntity w = new WatchedEntity(e);
       if (w.getTexture() != null) {
         map.watchedEntities.add(w);
       }
     }
   }
 }
Esempio n. 3
0
  /** Check if a render is necessary, and if so, do one. */
  private void tryARender() {
    if (Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null)
      return;
    try {
      double x = Minecraft.getMinecraft().thePlayer.posX;
      double z = Minecraft.getMinecraft().thePlayer.posZ;
      if (MinimapConfig.getInstance().isEnabled() && map.isDirty(x, z)) {
        //				long start = System.currentTimeMillis();
        if (MinimapConfig.getInstance().getScanRadius() > 0) {
          int radius = MinimapConfig.getInstance().getScanRadius() << 4;
          for (int cx = (int) (x - radius); cx <= (int) (x + radius); cx += 16) {
            for (int cz = (int) (z - radius); cz <= (int) (z + radius); cz += 16) {
              Chunk chunk =
                  Minecraft.getMinecraft().theWorld.getChunkFromBlockCoords((int) cx, (int) cz);
              org.spoutcraft.client.chunkcache.HeightMapAgent.scanChunk(chunk);
            }
          }
        }
        // long dur = System.currentTimeMillis() - start;
        // int chunks = (int) Math.pow(MinimapConfig.getInstance().getScanRadius() * 2, 2);
        // System.out.println("Took " + dur + "ms to scan " + chunks + " chunks.\nThat is " +
        // (float) (dur/(float)chunks) + " per chunk!");
        mapCalc();

        entityCalc();
        map.timer = 1;
      }
    } catch (RuntimeException e) {
      throw e;
    } finally {
      map.timer++;
    }
  }
Esempio n. 4
0
  private final int getBlockHeight(World world, int x, int z) {
    if (MinimapConfig.getInstance().isCavemap()) {
      Chunk chunk = world.getChunkFromBlockCoords(x, z);
      cmdist.setSeed((x & 0xffff) | ((z & 0xffff) << 16));
      float dist =
          distance(
              (int) Minecraft.getMinecraft().thePlayer.posX,
              (int) Minecraft.getMinecraft().thePlayer.posZ,
              x,
              z);
      int y = (int) Minecraft.getMinecraft().thePlayer.posY;
      if (dist > 5) y -= (cmdist.nextInt((int) (dist)) - ((int) dist / 2));
      x &= 0xf;
      z &= 0xf;

      if (y < 0) {
        y = 0;
      } else if (y > 255) {
        y = 255;
      }

      if (blockIsSolid(chunk, x, y, z)) {
        int itery = y;
        while (true) {
          itery++;
          if (itery > y + 10) return y + 10;
          if (!blockIsSolid(chunk, x, itery, z)) {
            return itery - 1;
          }
        }
      }
      while (y > -1) {
        y--;
        if (blockIsSolid(chunk, x, y, z)) {
          return y;
        }
      }
      return -1;
    }

    return world.getHeightValue(x, z) - 1;

    // return world.b(x, z).b(x & 0xf, z & 0xf);
    /*
     * li chunk = world.b(x, z); int y = (int)(game.h.aM); // starty; x &=
     * 0xf; z &= 0xf;
     *
     * //while (y > 0) // {
     *
     *
     * if (getBlockColor(id, meta).alpha == 0) return -1; // y--; else return
     * y + 1; // what //}
     */
    // return -1;
  }
Esempio n. 5
0
  private int getBlockLight(World world, int x, int y, int z) {
    int light = world.getBlockLightValue_do(x, y + 1, z, false) * 17;
    int min = 32;
    if (light < min) {
      light = min;
    }
    if (MinimapConfig.getInstance().isLightmap()) {
      light *= 1.3f;
    } else if (MinimapConfig.getInstance().isCavemap()) {
      light *= 0.5;
      light += 64;
    }

    if (light > 255) {
      light = 255;
    } else if (light < 0) {
      light = 0;
    }

    return light;
  }
Esempio n. 6
0
  private int getBlockColor(World world, int x, int y, int z) {
    int color24 = 0;

    try {
      if (MinimapConfig.getInstance().isColor() && !MinimapConfig.getInstance().isCavemap()) {
        if (x == (int) map.getPlayerX() && z == (int) map.getPlayerZ()) return 0xff0000;
        if ((world.getBlockMaterial(x, y + 1, z) == Material.ice)
            || (world.getBlockMaterial(x, y + 1, z) == Material.snow)) {
          color24 = 0xffffff;
        } else {
          BlockColor col =
              BlockColor.getBlockColor(world.getBlockId(x, y, z), world.getBlockMetadata(x, y, z));
          color24 = col.color;
        }
      }
    } catch (Exception e) {
      return 0;
    }

    return color24;
  }
Esempio n. 7
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;
    }
  }
Esempio n. 8
0
 @Override
 public void onButtonClick(ButtonClickEvent event) {
   MinimapConfig.getInstance().setScale(isChecked());
 }
Esempio n. 9
0
 public ScaleToggleCheckBox() {
   super("Scale Minimap");
   setChecked(MinimapConfig.getInstance().isScale());
   setTooltip(
       "Scale Minimap\nThe minimap will resize itself based on the \ndimensions of your screen.");
 }
 public MinimapToggleCheckBox() {
   super("Minimap Enabled");
   setChecked(MinimapConfig.getInstance().isEnabled());
   setTooltip("Minimap Enabled\nEnables or disables the minimap on the HUD.");
 }
 @Override
 public void onButtonClick() {
   MinimapConfig.getInstance().setAdjustX(-5);
   MinimapConfig.getInstance().setAdjustY(5);
   MinimapConfig.getInstance().setSquare(isChecked());
 }
 public SquareToggleCheckBox() {
   super("Square Minimap");
   setChecked(MinimapConfig.getInstance().isSquare());
   setTooltip("Square Minimap\nOFF - Shows a circle minimap.\nON - Shows a square minimap.");
 }
Esempio n. 13
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) {
    }
  }
Esempio n. 14
0
 public CoordsToggleCheckBox() {
   super("Show Coordinates");
   setChecked(MinimapConfig.getInstance().isCoords());
   setEnabled(SpoutClient.getInstance().isCoordsCheat());
   setTooltip("Minimap Enabled\nEnables or disables the minimap on the HUD.");
 }