Ejemplo n.º 1
0
  /**
   * Fired when a control is clicked. This is the equivalent of
   * ActionListener.actionPerformed(ActionEvent e).
   */
  protected void actionPerformed(GuiButton par1GuiButton) {
    if (!par1GuiButton.enabled) {
      return;
    }

    if (par1GuiButton.id == 0) {

      if (!Spoutcraft.hasPermission("spout.client.signcolors")) {
        for (int i = 0; i < entitySign.signText.length; i++) {
          entitySign.signText[i] = ChatColor.stripColor(entitySign.signText[i]);
        }
      }
      entitySign.onInventoryChanged();
      mc.displayGuiScreen(null);
    }
    // Spout start
    else if (par1GuiButton.id == 1 && unicode.enabled) {
      ConfigReader.sendColorsAsUnicode = !ConfigReader.sendColorsAsUnicode;
      if (ConfigReader.sendColorsAsUnicode) {
        unicode.displayString = "Send As Unicode";
      } else {
        unicode.displayString = "Send As Plain Text";
      }
    }
    // Spout end
  }
Ejemplo n.º 2
0
 @SuppressWarnings("unchecked")
 public void load(InputStream input) {
   Addon spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
   scroll.removeWidgets(spoutcraft);
   try {
     Yaml yaml = new Yaml();
     HashMap<String, Object> root = (HashMap<String, Object>) yaml.load(input);
     if (root.containsKey("options")) {
       HashMap<String, Object> options = (HashMap<String, Object>) root.get("options");
       if (options.containsKey("section-margin")) {
         sectionMargin = (Integer) options.get("section-margin");
       }
       if (options.containsKey("column-margin")) {
         columnMargin = (Integer) options.get("column-margin");
       }
     }
     if (root.containsKey("columns")) {
       LinkedHashMap<String, Object> columns = (LinkedHashMap<String, Object>) root.get("columns");
       for (Object col : columns.values()) {
         System.out.println("Column");
         List<Section> sections = new LinkedList<Section>();
         LinkedHashMap<String, Object> secs = (LinkedHashMap<String, Object>) col;
         for (Object sec : secs.values()) {
           System.out.println("Section");
           LinkedHashMap<String, Object> section = (LinkedHashMap<String, Object>) sec;
           String title = "Untitled";
           if (section.containsKey("title")) {
             title = (String) section.get("title");
           }
           Set<String> keys = section.keySet();
           if (keys.size() > 2) {
             System.out.println("Too many keys");
             continue;
           }
           String sectionType = "";
           for (String key : keys) {
             if (!key.equals("title")) {
               sectionType = key;
             }
           }
           Section sectionObject = Section.getSection(sectionType);
           if (sectionObject == null) {
             System.out.println("type " + sectionType + " not found");
             continue;
           }
           sectionObject.init(this, title, section.get(sectionType));
           System.out.println(
               "Section " + title + " of type " + sectionObject.getClass().getSimpleName());
           scroll.attachWidgets(spoutcraft, sectionObject.getWidgets().toArray(new Widget[0]));
           sections.add(sectionObject);
         }
         this.columns.add(sections);
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     layoutWidgets();
   }
 }
Ejemplo n.º 3
0
  /** Called when the screen is unloaded. Used to disable keyboard repeat events */
  public void onGuiClosed() {
    // Spout start
    entitySign.lineBeingEdited = -1;
    entitySign.columnBeingEdited = -1;
    entitySign.recalculateText();
    // Colorize text
    if (sendAsUnicode()) {
      boolean allow = Spoutcraft.hasPermission("spout.client.signcolors");
      for (int i = 0; i < entitySign.signText.length; i++) {
        if (entitySign.signText[i] != null)
          entitySign.signText[i] =
              entitySign.signText[i].replaceAll("(&([a-fA-F0-9]))", allow ? "\u00A7$2" : "");
      }
    } else {
      for (int i = 0; i < entitySign.signText.length; i++) {
        if (entitySign.signText[i] != null)
          entitySign.signText[i] = entitySign.signText[i].replaceAll("(&([a-fA-F0-9]))", "");
      }
    }
    // Spout end
    Keyboard.enableRepeatEvents(false);

    if (mc.theWorld.isRemote) {
      mc.getSendQueue()
          .addToSendQueue(
              new Packet130UpdateSign(
                  entitySign.xCoord, entitySign.yCoord, entitySign.zCoord, entitySign.signText));
    }
  }
Ejemplo n.º 4
0
 public AnimalTamer getOwner() {
   // If the wolf has a previously set owner use that, otherwise try and find the player who owns
   // it
   if (owner == null && !("").equals(getOwnerName())) {
     owner = Spoutcraft.getPlayer(getOwnerName());
   }
   return owner;
 }
Ejemplo n.º 5
0
 public Texture setUrl(String url) {
   this.url = url;
   if (getUrl() != null) {
     Spoutcraft.getClient()
         .getRenderDelegate()
         .downloadTexture(getAddon().getDescription().getName(), getUrl());
   }
   return this;
 }
Ejemplo n.º 6
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);
   }
 }
Ejemplo n.º 7
0
  public void initGui() {
    Addon spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
    recordLabel = new GenericLabel("Key:");
    recordLabel.setAlign(WidgetAnchor.TOP_LEFT);
    recordLabel.setWidth(50).setHeight(20);
    recordLabel.setX(10).setY(40);
    getScreen().attachWidget(spoutcraft, recordLabel);

    recordButton = new GenericButton();
    recordButton.setAlign(WidgetAnchor.CENTER_CENTER);
    recordButton.setHeight(20).setWidth(100);
    recordButton.setX(44).setY(33);
    getScreen().attachWidget(spoutcraft, recordButton);
    updateRecordButton();

    titleLabel = new GenericLabel("Name:");
    titleLabel.setAlign(WidgetAnchor.TOP_LEFT);
    titleLabel.setWidth(50).setHeight(20);
    titleLabel.setX(10).setY(10);
    getScreen().attachWidget(spoutcraft, titleLabel);

    commandText = new GenericTextField();
    commandText.setHeight(16).setWidth(355);
    commandText.setX(45).setY(8);
    commandText.setText(item.getTitle());
    commandText.setFocus(true);
    commandText.setMaximumCharacters(99);
    getScreen().attachWidget(spoutcraft, commandText);

    slot = new GuiCommandsSlot(this);
    getScreen().attachWidget(spoutcraft, slot);

    doneButton = new GenericButton("Done");
    doneButton.setHeight(20).setWidth(50);
    doneButton.setX(10).setY(height - 30);
    getScreen().attachWidget(spoutcraft, doneButton);

    addButton = new GenericButton("Add Command");
    addButton.setHeight(20).setWidth(100);
    addButton.setX(70).setY(height - 30);
    getScreen().attachWidget(spoutcraft, addButton);

    editButton = new GenericButton("Edit Command");
    editButton.setHeight(20).setWidth(100);
    editButton.setX(180).setY(height - 30);
    getScreen().attachWidget(spoutcraft, editButton);

    removeButton = new GenericButton("Remove Command");
    removeButton.setHeight(20).setWidth(100);
    removeButton.setX(290).setY(height - 30);
    getScreen().attachWidget(spoutcraft, removeButton);

    updateButtons();
  }
 public void run(int playerId) {
   ByteBuffer result = ByteBuffer.allocate(data.length).put(data);
   Chunk chunk = Spoutcraft.getWorld().getChunkAt(chunkX, chunkZ);
   for (int i = 0; i < data.length / 6; i++) {
     int index = i * 6;
     int x = result.get(index) + chunkX * 16;
     int y = result.getShort(index + 1);
     int z = result.get(index + 3) + chunkZ * 16;
     short id = result.getShort(index + 4);
     chunk.setCustomBlockId(x, y, z, id);
   }
 }
Ejemplo n.º 9
0
 @Override
 public void onTick() {
   int width = Spoutcraft.getClient().getRenderDelegate().getScreenWidth();
   int height = Spoutcraft.getClient().getRenderDelegate().getScreenHeight();
   if (width != screenWidth || height != screenHeight) {
     onScreenResized(screenWidth, screenHeight, width, height);
   }
   screenWidth = width;
   screenHeight = height;
   for (Widget widget : new HashSet<Widget>(widgets.keySet())) {
     try {
       widget.onTick();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   for (Widget widget : widgets.keySet()) {
     try {
       widget.onAnimate();
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
Ejemplo n.º 10
0
  @Override
  protected void createInstances() {
    title = new GenericLabel("About");
    buttonDone = new GenericButton("Main Menu");
    scroll = new GenericScrollArea();

    Addon spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
    getScreen().attachWidgets(spoutcraft, title, buttonDone, scroll);

    Thread load =
        new Thread() {
          @Override
          public void run() {
            try {
              load((new URL("http://get.spout.org/about.yml")).openStream());
            } catch (MalformedURLException e) {
              e.printStackTrace();
            } catch (IOException e) {
              e.printStackTrace();
            }
          }
        };
    load.start();
  }
Ejemplo n.º 11
0
 @Override
 public void render() {
   int x = (int) getWidthX() - 13 - Spoutcraft.getMinecraftFont().getTextWidth(this.getText());
   this.setX(x).setY((int) (getWidthX() / 5));
   super.render();
 }
Ejemplo n.º 12
0
 public double getHeightY() {
   return Spoutcraft.getRenderDelegate().getScreenHeight();
 }
Ejemplo n.º 13
0
 public double getWidthX() {
   return Spoutcraft.getRenderDelegate().getScreenWidth();
 }
Ejemplo n.º 14
0
 public void render() {
   Spoutcraft.getClient().getRenderDelegate().render(this);
 }
Ejemplo n.º 15
0
 public static ChatMessage parseMessage(String unparsed) {
   String player = null;
   boolean highlighted = false;
   unparsed = Spoutcraft.getChatManager().formatChatColors(unparsed);
   String message = unparsed;
   for (Pattern p : messagePatterns) {
     Matcher m = p.matcher(ChatColor.stripColor(unparsed));
     if (m.matches()) {
       player = m.group(1);
       message = m.group(2);
       break;
     }
   }
   String playerName = Spoutcraft.getActivePlayer().getName();
   if (!playerName.equals(player)) { // Don't highlight our own messages
     if (message.contains(playerName)) {
       highlighted = true;
     } else {
       for (String highlightWord : Spoutcraft.getChatManager().getWordsToHighlight()) {
         if (Spoutcraft.getChatManager().isUsingRegex()) {
           try {
             if (message.matches(".*" + highlightWord + ".*")) {
               highlighted = true;
               break;
             }
           } catch (PatternSyntaxException e) {
           }
         } else {
           if (message.contains(highlightWord)) {
             highlighted = true;
             break;
           }
         }
       }
     }
   }
   if (player != null) {
     player = ChatColor.stripColor(player);
   }
   ChatMessage ret = new ChatMessage(unparsed, message, highlighted, player);
   if (message.contains("has joined")) {
     ret.setJoinMessage(true);
   }
   if (ret.hasPlayer()) {
     for (String name : Spoutcraft.getChatManager().getIgnoredPlayers()) {
       if (Spoutcraft.getChatManager().isUsingRegex()) {
         try {
           if (ret.getPlayer().matches(".*" + name + ".*")) {
             ret.setIgnoredPerson(true);
             break;
           }
         } catch (PatternSyntaxException e) {
         }
       } else {
         if (ret.getPlayer().equalsIgnoreCase(name)) {
           ret.setIgnoredPerson(true);
           break;
         }
       }
     }
   }
   return ret;
 }
Ejemplo n.º 16
0
 public void run(int id) {
   Spoutcraft.getActivePlayer().setMaximumAir(airTime);
   Spoutcraft.getActivePlayer().setRemainingAir(air);
 }
Ejemplo n.º 17
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;
    }
  }
Ejemplo n.º 18
0
 public GenericScreen() {
   screenWidth = Spoutcraft.getClient().getRenderDelegate().getScreenWidth();
   screenHeight = Spoutcraft.getClient().getRenderDelegate().getScreenHeight();
   spoutcraft = Spoutcraft.getAddonManager().getAddon("Spoutcraft");
 }