Example #1
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));
    }
  }
  /** Updates Client side signs */
  public void handleUpdateSign(Packet130UpdateSign par1Packet130UpdateSign) {
    WorldServer worldserver = mcServer.worldServerForDimension(playerEntity.dimension);

    if (worldserver.blockExists(
        par1Packet130UpdateSign.xPosition,
        par1Packet130UpdateSign.yPosition,
        par1Packet130UpdateSign.zPosition)) {
      TileEntity tileentity =
          worldserver.getBlockTileEntity(
              par1Packet130UpdateSign.xPosition,
              par1Packet130UpdateSign.yPosition,
              par1Packet130UpdateSign.zPosition);

      if (tileentity instanceof TileEntitySign) {
        TileEntitySign tileentitysign = (TileEntitySign) tileentity;

        if (!tileentitysign.isEditable()) {
          mcServer.logWarningMessage(
              (new StringBuilder())
                  .append("Player ")
                  .append(playerEntity.username)
                  .append(" just tried to change non-editable sign")
                  .toString());
          return;
        }
      }

      for (int i = 0; i < 4; i++) {
        boolean flag = true;

        if (par1Packet130UpdateSign.signLines[i].length() > 15) {
          flag = false;
        } else {
          for (int l = 0; l < par1Packet130UpdateSign.signLines[i].length(); l++) {
            if (ChatAllowedCharacters.allowedCharacters.indexOf(
                    par1Packet130UpdateSign.signLines[i].charAt(l))
                < 0) {
              flag = false;
            }
          }
        }

        if (!flag) {
          par1Packet130UpdateSign.signLines[i] = "!?";
        }
      }

      if (tileentity instanceof TileEntitySign) {
        int j = par1Packet130UpdateSign.xPosition;
        int k = par1Packet130UpdateSign.yPosition;
        int i1 = par1Packet130UpdateSign.zPosition;
        TileEntitySign tileentitysign1 = (TileEntitySign) tileentity;
        System.arraycopy(par1Packet130UpdateSign.signLines, 0, tileentitysign1.signText, 0, 4);
        tileentitysign1.onInventoryChanged();
        worldserver.markBlockNeedsUpdate(j, k, i1);
      }
    }
  }
Example #3
0
  /** Updates Client side signs */
  public void handleUpdateSign(Packet130UpdateSign par1Packet130UpdateSign) {
    WorldServer var2 = this.mcServer.getWorldManager(this.playerEntity.dimension);

    if (var2.blockExists(
        par1Packet130UpdateSign.xPosition,
        par1Packet130UpdateSign.yPosition,
        par1Packet130UpdateSign.zPosition)) {
      TileEntity var3 =
          var2.getBlockTileEntity(
              par1Packet130UpdateSign.xPosition,
              par1Packet130UpdateSign.yPosition,
              par1Packet130UpdateSign.zPosition);

      if (var3 instanceof TileEntitySign) {
        TileEntitySign var4 = (TileEntitySign) var3;

        if (!var4.isEditable()) {
          this.mcServer.logWarning(
              "Player " + this.playerEntity.username + " just tried to change non-editable sign");
          return;
        }
      }

      int var6;
      int var8;

      for (var8 = 0; var8 < 4; ++var8) {
        boolean var5 = true;

        if (par1Packet130UpdateSign.signLines[var8].length() > 15) {
          var5 = false;
        } else {
          for (var6 = 0; var6 < par1Packet130UpdateSign.signLines[var8].length(); ++var6) {
            if (ChatAllowedCharacters.allowedCharacters.indexOf(
                    par1Packet130UpdateSign.signLines[var8].charAt(var6))
                < 0) {
              var5 = false;
            }
          }
        }

        if (!var5) {
          par1Packet130UpdateSign.signLines[var8] = "!?";
        }
      }

      if (var3 instanceof TileEntitySign) {
        var8 = par1Packet130UpdateSign.xPosition;
        int var9 = par1Packet130UpdateSign.yPosition;
        var6 = par1Packet130UpdateSign.zPosition;
        TileEntitySign var7 = (TileEntitySign) var3;
        System.arraycopy(par1Packet130UpdateSign.signLines, 0, var7.signText, 0, 4);
        var7.onInventoryChanged();
        var2.markBlockNeedsUpdate(var8, var9, var6);
      }
    }
  }
Example #4
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
  }
Example #5
0
 /** Displays the GUI for editing a sign. Args: tileEntitySign */
 public void displayGUIEditSign(TileEntity par1TileEntity) {
   if (par1TileEntity instanceof TileEntitySign) {
     ((TileEntitySign) par1TileEntity).func_142010_a(this);
     this.playerNetServerHandler.sendPacketToPlayer(
         new Packet133TileEditorOpen(
             0, par1TileEntity.xCoord, par1TileEntity.yCoord, par1TileEntity.zCoord));
   }
 }
 public void a(EnumCommandResult enumcommandresult, int i) {
   TileEntitySign.a(this.b).a(this, enumcommandresult, i);
 }
Example #7
0
  /** Draws the screen and all the components in it. */
  public void drawScreen(int x, int y, float z) {
    drawDefaultBackground();
    drawCenteredString(fontRenderer, screenTitle, width / 2, 40, 0xffffff);

    // Spout Start
    if (org.spoutcraft.client.config.ConfigReader.showChatColors) {
      for (int c = 0; c < 16; c++) {
        ChatColor value = ChatColor.getByCode(c);
        String name = value.name().toLowerCase();
        boolean lastUnderscore = true;
        String parsedName = "";
        for (int chr = 0; chr < name.length(); chr++) {
          char ch = name.charAt(chr);
          if (lastUnderscore) {
            ch = Character.toUpperCase(ch);
          }
          if (ch == '_') {
            lastUnderscore = true;
            ch = ' ';
          } else {
            lastUnderscore = false;
          }
          parsedName += ch;
        }
        char code = (char) ('0' + c);
        if (c >= 10) {
          code = (char) ('a' + c - 10);
        }
        fontRenderer.drawStringWithShadow(
            "&" + code + " - " + value + parsedName, width - 90, 70 + c * 10, 0xffffffff);
      }
    }
    // Spout end

    GL11.glPushMatrix();
    GL11.glTranslatef(width / 2, 0.0F, 50F);
    float f = 93.75F;
    GL11.glScalef(-f, -f, -f);
    GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);
    Block block = entitySign.getBlockType();

    if (block == Block.signPost) {
      float f1 = (float) (entitySign.getBlockMetadata() * 360) / 16F;
      GL11.glRotatef(f1, 0.0F, 1.0F, 0.0F);
      GL11.glTranslatef(0.0F, -1.0625F, 0.0F);
    } else {
      int i = entitySign.getBlockMetadata();
      float f2 = 0.0F;

      if (i == 2) {
        f2 = 180F;
      }

      if (i == 4) {
        f2 = 90F;
      }

      if (i == 5) {
        f2 = -90F;
      }

      GL11.glRotatef(f2, 0.0F, 1.0F, 0.0F);
      GL11.glTranslatef(0.0F, -1.0625F, 0.0F);
    }

    // Spout start
    // if(this.updateCounter / 6 % 2 == 0) {
    this.entitySign.lineBeingEdited = this.editLine;
    entitySign.columnBeingEdited = editColumn;
    // }
    // Spout end

    TileEntityRenderer.instance.renderTileEntityAt(entitySign, -0.5D, -0.75D, -0.5D, 0.0F);
    // Spout start
    this.entitySign.lineBeingEdited = -1;
    entitySign.columnBeingEdited = -1;
    // Spout end
    GL11.glPopMatrix();
    super.drawScreen(x, y, z);
    // Spout start
    if (unicode.enabled
        && isInBoundingRect(
            unicode.xPosition,
            unicode.yPosition,
            unicode.field_52007_b,
            unicode.field_52008_a,
            x,
            y)) {
      this.drawTooltip(
          "Some servers censor unicode characters. \nIf yours does, try sending as plain text.",
          x,
          y);
    }
    // Spout end
  }
Example #8
0
  // Spout - rewritten method
  // Spout Start
  protected void keyTyped(char var1, int var2) {
    if (var2 == 200) { // up
      this.editLine = this.editLine - 1 & 3;
      editColumn = entitySign.signText[editLine].length();
    }

    if (var2 == 208 || var2 == 28) { // down
      this.editLine = this.editLine + 1 & 3;
      editColumn = entitySign.signText[editLine].length();
    }
    if (var2 == 205) { // right
      editColumn++;
      if (editColumn > entitySign.signText[editLine].length()) {
        editColumn--;
      }
    }
    if (var2 == 203) { // left
      editColumn--;
      if (editColumn < 0) {
        editColumn = 0;
      }
    }
    if (var2 == 14 && this.entitySign.signText[this.editLine].length() > 0) { // backsp
      String line = entitySign.signText[editLine];
      int endColumnStart = Math.min(editColumn, line.length());
      String before = "";
      if (endColumnStart > 0) {
        before = line.substring(0, endColumnStart);
      }
      String after = "";
      if (line.length() - editColumn > 0) {
        after = line.substring(editColumn, line.length());
      }
      if (before.length() > 0) {
        before = before.substring(0, before.length() - 1);
        line = before + after;
        entitySign.signText[editLine] = line;
        endColumnStart--;
        editColumn = endColumnStart;
        if (editColumn < 0) {
          editColumn = 0;
        }
      }
    }
    if ((allowedCharacters.indexOf(var1) > -1 || var1 > 32)
        && this.entitySign.signText[this.editLine].length() < 15) { // enter
      String line = entitySign.signText[editLine];

      // prevent out of bounds on the substring call
      int endColumnStart = Math.min(editColumn, line.length());
      String before = "";
      if (endColumnStart > 0) {
        before = line.substring(0, endColumnStart);
      }
      String after = "";
      if (line.length() - endColumnStart > 0) {
        after = line.substring(endColumnStart, line.length());
      }
      before += var1;
      line = before + after;
      entitySign.signText[editLine] = line;
      endColumnStart++;
      editColumn = endColumnStart;
    }
    if (var2 == 211) // del
    {
      String line = entitySign.signText[editLine];
      String before = line.substring(0, editColumn);
      String after = "";
      if (line.length() - editColumn > 0) {
        after = line.substring(editColumn, line.length());
      }
      if (after.length() > 0) {
        after = after.substring(1, after.length());
        line = before + after;
        entitySign.signText[editLine] = line;
      }
    }
    entitySign.recalculateText();
  }