コード例 #1
0
 @Override
 public String getText() {
   if (Minecraft.getMinecraft().theWorld != null
       && Minecraft.getMinecraft().theWorld.getWorldInfo().isHardcoreModeEnabled()) {
     return "Difficulty: Hardcore";
   }
   String difficulty;
   switch (Minecraft.getMinecraft().gameSettings.difficulty) {
     case 0:
       difficulty = "Peaceful";
       break;
     case 1:
       difficulty = "Easy";
       break;
     case 2:
       difficulty = "Normal";
       break;
     case 3:
       difficulty = "Hard";
       break;
     default:
       difficulty = "Unknown";
       break;
   }
   return "Difficulty: " + difficulty;
 }
コード例 #2
0
ファイル: MapCalculator.java プロジェクト: Top-Cat/Spoutcraft
  /** 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++;
    }
  }
コード例 #3
0
 @Override
 public void onButtonClick() {
   Minecraft.getMinecraft().gameSettings.difficulty++;
   if (Minecraft.getMinecraft().gameSettings.difficulty > 3) {
     Minecraft.getMinecraft().gameSettings.difficulty = 0;
   }
   Minecraft.getMinecraft().gameSettings.saveOptions();
 }
コード例 #4
0
ファイル: MapCalculator.java プロジェクト: Top-Cat/Spoutcraft
  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;
  }
コード例 #5
0
 @Override
 public boolean isEnabled() {
   if (Minecraft.getMinecraft().theWorld == null) {
     return false;
   }
   if (!Minecraft.getMinecraft().isSingleplayer()) {
     return false;
   }
   if (Minecraft.getMinecraft().theWorld.getWorldInfo().isHardcoreModeEnabled()) {
     return false;
   }
   return true;
 }
コード例 #6
0
 @Override
 public String getTooltip() {
   if (Minecraft.getMinecraft().theWorld == null) {
     return "Can not change difficulty outside of the game";
   }
   if (!Minecraft.getMinecraft().isSingleplayer()) {
     return "Can not change difficulty in multiplayer";
   }
   if (Minecraft.getMinecraft().theWorld.getWorldInfo().isHardcoreModeEnabled()) {
     return "Can not change difficulty in hardcore mode";
   }
   return super.getTooltip();
 }
コード例 #7
0
  /** Attempts to find a config If there is one load it If there is not one create one */
  private void loadConfig() {
    config = new Properties(defaults);

    try {
      configPath =
          Minecraft.getMinecraft().mcDataDir.getCanonicalPath()
              + File.separatorChar
              + "config"
              + File.separatorChar
              + "ServerListFolder"
              + File.separatorChar;

      File cfg = new File(configPath + "ServerListFolder.cfg");

      if (cfg.exists()) {
        ServerListFolder.info("Config file found, loading...");
        config.load(new FileInputStream(configPath + "ServerListFolder.cfg"));
      } else {
        ServerListFolder.info("No config file found, creating...");
        createConfig(cfg);
      }
    } catch (Exception e) {
      ServerListFolder.warn(e.toString());
    }
  }
コード例 #8
0
 @Override
 protected void keyTyped(char par1, int par2) {
   if (par2 == Keyboard.KEY_ESCAPE) {
     if (mod_Undercast.CONFIG.showGSClass
         && UndercastData.currentGSClass.equals("Unknown")
         && UndercastData.currentServerType == ServerType.ghostsquadron) {
       Minecraft.getMinecraft().thePlayer.sendChatMessage("/class");
     }
     mc.displayGuiScreen(null);
     return;
   }
 }
コード例 #9
0
  /** Init the mod */
  private void modInit() {

    // TODO: Mod initialization.
    modinstance = this;
    update();
    guiStatesFile = new File(minecraft.mcDataDir, "/Cheating Essentials/gui.coords");
    xrayBlocks = new File(minecraft.mcDataDir, "/Cheating Essentials/BlockList.txt");
    CELogAgent.logInfo(
        Strings.MOD_NAME
            + " "
            + Strings.MOD_VERSION
            + " "
            + "starting in"
            + " "
            + Strings.MINECRAFT_VERSION
            + "...");
    if (debugMode) {
      System.out.println(
          "You only can view this messages if you're viewing the code, using it, or anything else - Debugging and misc. system info.");
      CELogAgent.logInfo(Strings.MOD_AVALIABLE_MODULES);
      CELogAgent.logInfo("Instance Started in (Miliseconds): " + System.currentTimeMillis() / 1000);
      // WHY IT IS NOT IMPLEMENTED TO VANILLA MC :/
      CELogAgent.logInfo("Open GL version: " + GL11.glGetString(GL11.GL_VERSION));
      CELogAgent.logInfo("Open GL vendor: " + GL11.glGetString(GL11.GL_VENDOR));
      System.out.println("I hate the Integrated Server! :(");
    }
    run();
    mainModLoader = new ModManager(this);
    modUtils = new Utils(minecraft);
    MainGui = new ModuleGui();
    minecraft = Minecraft.getMinecraft();
    now = System.currentTimeMillis();
    then = now + 250;
    modKeyManager = new KeyManager();
    theConsoleHelper = new ConsoleHelper();
    keys = new HashMap<Mod, Integer>();
    theFriendManager = new FrenemyManager();
    getModWrapper = new Wrapper();
    CELogAgent.logInfo("Basic init finished with no errors.");
    for (Mod m : mainModLoader.mods) {
      keys.put(m, m.keyBind);
    }
    CELogAgent.logInfo(
        Strings.MOD_NAME
            + " "
            + Strings.MOD_VERSION
            + " started succefully in "
            + Strings.MINECRAFT_VERSION);
  }
コード例 #10
0
 @Override
 protected void actionPerformed(GuiButton guibutton) {
   // If the button is clicked, toggle and save the setting
   if (guibutton instanceof SettingsToggleButton) {
     SettingsToggleButton button = (SettingsToggleButton) guibutton;
     button.buttonPressed();
   } else if (guibutton.id == 15) {
     this.pageIndex++;
     this.buttonList.clear();
     this.initGui();
   } else if (guibutton.id == 16) {
     this.pageIndex--;
     this.buttonList.clear();
     this.initGui();
   } else {
     if (mod_Undercast.CONFIG.showGSClass
         && UndercastData.currentGSClass.equals("Unknown")
         && UndercastData.currentServerType == ServerType.ghostsquadron) {
       Minecraft.getMinecraft().thePlayer.sendChatMessage("/class");
     }
     ModLoader.openGUI(mc.thePlayer, parentScreen);
   }
 }
コード例 #11
0
ファイル: MapCalculator.java プロジェクト: Top-Cat/Spoutcraft
 /** Called each tick of the render. */
 void onRenderTick() {
   if (Minecraft.getMinecraft() != null && Minecraft.getMinecraft().theWorld != null) {
     tryARender();
   }
 }
コード例 #12
0
ファイル: MapCalculator.java プロジェクト: Top-Cat/Spoutcraft
  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) {
    }
  }