public void run(int playerId) {
   World world = SpoutClient.getHandle().theWorld;
   TileEntity te = world.getBlockTileEntity(x, y, z);
   if (te != null && te instanceof TileEntitySign) {
     TileEntitySign sign = (TileEntitySign) te;
     GuiEditSign gui = new GuiEditSign(sign);
     SpoutClient.getHandle().displayGuiScreen(gui);
   }
 }
 @Override
 protected void buttonClicked(Button btn) {
   if (btn == doneButton) {
     SpoutClient.getHandle().displayGuiScreen(parent);
   }
   if (btn == switchToAdvancedCheck) {
     Configuration.setAdvancedOptions(true);
     Configuration.write();
     SpoutClient.getHandle().displayGuiScreen(new GuiAdvancedOptions(parent));
   }
 }
Exemple #3
0
  private String completeNames(String message) {
    tabHelp = null;
    String[] words = message.split(" ");
    if (words.length > 0) {
      String lastWord = words[words.length - 1];
      if (lastWord.endsWith("_")) {
        lastWord = lastWord.substring(0, lastWord.length() - 1);
      }
      if (lastWord.length() > 2) {
        // Check nearby players
        Player p = SpoutClient.getInstance().getPlayer(lastWord);
        String playerName = p != null ? p.getName() : null;

        // Check server player list
        if (playerName == null && SpoutClient.getHandle().isMultiplayerWorld()) {
          int delta = Integer.MAX_VALUE;
          String best = null;
          final List<GuiPlayerInfo> players =
              ((EntityClientPlayerMP) SpoutClient.getHandle().thePlayer).sendQueue.playerNames;
          final String toLower = lastWord.toLowerCase();
          for (GuiPlayerInfo info : players) {
            String name = ChatColor.stripColor(info.name);
            if (name.toLowerCase().startsWith(toLower)) {
              int curDelta = info.name.length() - lastWord.length();
              if (curDelta < delta) {
                best = name;
                delta = curDelta;
              }
              if (curDelta == 0) {
                break;
              }
            }
          }
          if (best != null) {
            playerName = best;
          }
        }

        // Autocomplete
        if (playerName != null && playerName.length() > lastWord.length()) {
          message =
              message.substring(0, message.length() - 1)
                  + "|"
                  + ChatColor.YELLOW
                  + playerName.substring(lastWord.length())
                  + ChatColor.RESET;
          tabHelp = playerName.substring(lastWord.length());
        }
      }
    }
    return message;
  }
Exemple #4
0
  @Override
  protected void executeAction() {
    MinimapConfig.initialize(false);
    MinimapConfig.getInstance().save();

    SpoutClient.getHandle().displayGuiScreen(new GuiMinimapMenu(parent.parent));
  }
 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);
       }
     }
   }
 }
 public void render(int x, int y, int width, int height) {
   FontRenderer font = SpoutClient.getHandle().fontRenderer;
   parent.drawString(font, cmd, x + 2, y + 2, 0xffffff);
   if (cmd.startsWith("/")) {
     parent.drawString(font, "Command", x + 2, y + 13, 0xaaaaaa);
   } else {
     parent.drawString(font, "Chat Message", x + 2, y + 13, 0xaaaaaa);
   }
 }
Exemple #7
0
 public void sendChat(String message) {
   if (!Spoutcraft.hasPermission("spout.client.chatcolors")) {
     message = message.replaceAll("(&([a-fA-F0-9]))", "");
   }
   List<String> lines = formatChat(message, false);
   for (String chat : lines) {
     SpoutClient.getHandle().thePlayer.sendChatMessage(chat);
   }
 }
  public void render(int x, int y, int width, int height) {
    MCRenderDelegate r = (MCRenderDelegate) SpoutClient.getInstance().getRenderDelegate();
    FontRenderer font = SpoutClient.getHandle().fontRenderer;

    String sResolution = resolution + "x";
    int sWidth = font.getStringWidth(sResolution);
    font.drawStringWithShadow(sResolution, x + width - sWidth - 2, y + 2, 0xffaaaaaa);

    String name = r.getFittingText(getName(), width - 29 - sWidth - 2 - x);
    font.drawStringWithShadow(name, x + 29, y + 2, 0xffffffff);

    String sStatus = "";
    if (size > 1024 * 1024 * 9000) {
      sStatus = ChatColor.RED + "It's over 9000! ";
    }
    if (size > 1024 * 1024) {
      sStatus += size / (1024 * 1024) + " MB";
    } else if (size > 1024) {
      sStatus = size / 1024 + " KB";
    } else {
      sStatus = size + " Bytes";
    }
    if (isDownloading()) {
      sStatus = "Downloading: " + ChatColor.WHITE + download.getProgress() + "%";
    }
    if (downloadFail != null) {
      sStatus = downloadFail;
    }
    if (installed) {
      sStatus = ChatColor.GREEN + "Installed";
    }
    if (sStatus != null) {
      sWidth = font.getStringWidth(sStatus);
      font.drawStringWithShadow(sStatus, x + width - sWidth - 2, y + 11, 0xffaaaaaa);
    }

    String author = "by " + ChatColor.WHITE + getAuthor();
    author = r.getFittingText(author, width - 29 - sWidth - 2 - x);
    font.drawStringWithShadow(author, x + 29, y + 11, 0xffaaaaaa);

    String desc = r.getFittingText(getDescription(), width - 2 - 29);
    font.drawStringWithShadow(desc, x + 29, y + 20, 0xffaaaaaa);

    String iconUrl = getIconUrl();
    Texture icon = CustomTextureManager.getTextureFromUrl(iconUrl);
    if (icon == null) {
      CustomTextureManager.downloadTexture(iconUrl, true);
    } else {
      GL11.glPushMatrix();
      GL11.glTranslated(x + 2, y + 2, 0);
      r.drawTexture(icon, 25, 25);
      GL11.glPopMatrix();
    }
  }
Exemple #9
0
 public boolean handleCommand(String command) {
   try {
     if (command.equals("/?") || command.startsWith("/client help")) {
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(ChatColor.YELLOW.toString() + "Spoutcraft Client Debug Commands:");
       SpoutClient.getHandle().ingameGUI.addChatMessage("/client gc - run the garbage collector");
       return true;
     } else if (command.startsWith("/client gc")) {
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(ChatColor.YELLOW.toString() + "Starting Garbage Collection...");
       long start = System.currentTimeMillis();
       long mem = Runtime.getRuntime().freeMemory();
       long time = 250;
       if (command.split(" ").length > 2) {
         try {
           time = Long.parseLong(command.split(" ")[2]);
         } catch (Exception ignore) {
         }
       }
       while ((System.currentTimeMillis() - start) < time) {
         System.gc();
       }
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(ChatColor.GREEN.toString() + "Garbage Collection Complete!");
       SpoutClient.getHandle()
           .ingameGUI
           .addChatMessage(
               ChatColor.GREEN.toString()
                   + (Runtime.getRuntime().freeMemory() - mem) / (1024D * 1024D)
                   + " mb of memory freed");
       return true;
     }
   } catch (Exception e) {
   }
   return false;
 }
Exemple #10
0
 public Point getPlayerPosition() {
   int x = (int) SpoutClient.getHandle().thePlayer.posX;
   int z = (int) SpoutClient.getHandle().thePlayer.posZ;
   return new Point(x, z);
 }
Exemple #11
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;
    }
  }
Exemple #12
0
 private void updateGeometry() {
   FontRenderer font = SpoutClient.getHandle().fontRenderer;
   this.width = (float) font.getStringWidth(text) * 0.0139F * scale;
   this.height = 0.124F * scale;
 }
Exemple #13
0
  public void setCamera(FixedLocation pos) {
    EntityLiving cam = SpoutClient.getHandle().renderViewEntity;
    if (!(cam.spoutEntity instanceof CameraEntity)) return;

    ((CameraEntity) cam.spoutEntity).teleport(pos);
  }