Exemplo n.º 1
0
  public void writeToNBT(NBTTagCompound compound) {
    super.writeToNBT(compound);

    for (int var2 = 0; var2 < 4; ++var2) {
      String var3 = IChatComponent.Serializer.componentToJson(this.signText[var2]);
      compound.setString("Text" + (var2 + 1), var3);
    }

    this.field_174883_i.func_179670_b(compound);
  }
Exemplo n.º 2
0
  public void writeToNBT(NBTTagCompound compound) {
    super.writeToNBT(compound);

    for (int i = 0; i < 4; ++i) {
      String s = IChatComponent.Serializer.componentToJson(this.signText[i]);
      compound.setString("Text" + (i + 1), s);
    }

    this.stats.writeStatsToNBT(compound);
  }
Exemplo n.º 3
0
  @SubscribeEvent
  public void tickStart(PlayerTickEvent evt) {

    if (evt.phase != Phase.START) {
      return;
    }
    if (lastPoll > 0) {
      --lastPoll;
      return;
    }
    lastPoll = 400;

    if (!_notificationDisplayed && _updateThread.checkComplete()) {
      _notificationDisplayed = true;
      FMLCommonHandler.instance().bus().unregister(this);
      if (_updateThread.newVersionAvailable()) {
        if (!CoFHProps.enableUpdateNotice && !_updateThread.isCriticalUpdate()) {
          return;
        }
        ModVersion newVersion = _updateThread.newVersion();

        EntityPlayer player = evt.player;
        player.addChatMessage(
            new ChatComponentText(GOLD + "[" + _mod.getModName() + "]")
                .appendText(WHITE + " A new version is available:"));
        IChatComponent chat;
        String text = newVersion.modVersion().toString();
        if (Strings.isNullOrEmpty(_downloadUrl)) {
          chat = new ChatComponentText(text).setChatStyle(version);
        } else {
          chat =
              IChatComponent.Serializer.func_150699_a(
                  "[{\"text\":\""
                      + text
                      + "\",\"color\":\"aqua\"},"
                      + "{\"text\":\" "
                      + WHITE
                      + "["
                      + GREEN
                      + "Download"
                      + WHITE
                      + "]\","
                      + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                      + "{\"text\":\"Click this to download the latest version\",\"color\":\"yellow\"}},"
                      + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                      + _downloadUrl
                      + "\"}}]");
        }
        player.addChatMessage(chat);
        player.addChatMessage(
            new ChatComponentText(newVersion.description()).setChatStyle(description));
      }
    }
  }
Exemplo n.º 4
0
  @SubscribeEvent
  public void playerLogin(final PlayerLoggedInEvent event) {

    if (event.player instanceof EntityPlayer) {
      if (status == UpdateStatus.OUTDATED) {
        final String msg =
            StatCollector.translateToLocalFormatted(
                "msg.NewVersionAvailable.dsurround",
                Module.MOD_NAME,
                currentVersion,
                CURSE_PROJECT_NAME);
        final IChatComponent component = IChatComponent.Serializer.jsonToComponent(msg);
        event.player.addChatMessage(component);
      }
    }
  }
  public void func_71515_b(ICommandSender p_71515_1_, String[] p_71515_2_) throws CommandException {
    if (p_71515_2_.length < 2) {
      throw new WrongUsageException("commands.tellraw.usage", new Object[0]);
    } else {
      EntityPlayerMP var3 = func_82359_c(p_71515_1_, p_71515_2_[0]);
      String var4 = func_180529_a(p_71515_2_, 1);

      try {
        IChatComponent var5 = IChatComponent.Serializer.func_150699_a(var4);
        var3.func_145747_a(ChatComponentProcessor.func_179985_a(p_71515_1_, var5, var3));
      } catch (JsonParseException var7) {
        Throwable var6 = ExceptionUtils.getRootCause(var7);
        throw new SyntaxErrorException(
            "commands.tellraw.jsonException", new Object[] {var6 == null ? "" : var6.getMessage()});
      }
    }
  }
Exemplo n.º 6
0
  public void readFromNBT(NBTTagCompound compound) {
    this.isEditable = false;
    super.readFromNBT(compound);
    ICommandSender var2 =
        new ICommandSender() {

          public String getName() {
            return "Sign";
          }

          public IChatComponent getDisplayName() {
            return new ChatComponentText(this.getName());
          }

          public void addChatMessage(IChatComponent message) {}

          public boolean canCommandSenderUseCommand(int permissionLevel, String command) {
            return true;
          }

          public BlockPos getPosition() {
            return TileEntitySign.this.pos;
          }

          public Vec3 getPositionVector() {
            return new Vec3(
                (double) TileEntitySign.this.pos.getX() + 0.5D,
                (double) TileEntitySign.this.pos.getY() + 0.5D,
                (double) TileEntitySign.this.pos.getZ() + 0.5D);
          }

          public World getEntityWorld() {
            return TileEntitySign.this.worldObj;
          }

          public Entity getCommandSenderEntity() {
            return null;
          }

          public boolean sendCommandFeedback() {
            return false;
          }

          public void func_174794_a(CommandResultStats.Type p_174794_1_, int p_174794_2_) {}
        };

    for (int var3 = 0; var3 < 4; ++var3) {
      String var4 = compound.getString("Text" + (var3 + 1));

      try {
        IChatComponent var5 = IChatComponent.Serializer.jsonToComponent(var4);

        try {
          this.signText[var3] = ChatComponentProcessor.func_179985_a(var2, var5, (Entity) null);
        } catch (CommandException var7) {
          this.signText[var3] = var5;
        }
      } catch (JsonParseException var8) {
        this.signText[var3] = new ChatComponentText(var4);
      }
    }

    this.field_174883_i.func_179668_a(compound);
  }
Exemplo n.º 7
0
  public void readFromNBT(NBTTagCompound compound) {
    this.isEditable = false;
    super.readFromNBT(compound);
    ICommandSender icommandsender =
        new ICommandSender() {
          public String getName() {
            return "Sign";
          }

          public IChatComponent getDisplayName() {
            return new ChatComponentText(this.getName());
          }

          public void addChatMessage(IChatComponent component) {}

          public boolean canCommandSenderUseCommand(int permLevel, String commandName) {
            return true;
          }

          public BlockPos getPosition() {
            return TileEntitySign.this.pos;
          }

          public Vec3 getPositionVector() {
            return new Vec3(
                (double) TileEntitySign.this.pos.getX() + 0.5D,
                (double) TileEntitySign.this.pos.getY() + 0.5D,
                (double) TileEntitySign.this.pos.getZ() + 0.5D);
          }

          public World getEntityWorld() {
            return TileEntitySign.this.worldObj;
          }

          public Entity getCommandSenderEntity() {
            return null;
          }

          public boolean sendCommandFeedback() {
            return false;
          }

          public void setCommandStat(CommandResultStats.Type type, int amount) {}
        };

    for (int i = 0; i < 4; ++i) {
      String s = compound.getString("Text" + (i + 1));

      try {
        IChatComponent ichatcomponent = IChatComponent.Serializer.jsonToComponent(s);

        try {
          this.signText[i] =
              ChatComponentProcessor.processComponent(
                  icommandsender, ichatcomponent, (Entity) null);
        } catch (CommandException var7) {
          this.signText[i] = ichatcomponent;
        }
      } catch (JsonParseException var8) {
        this.signText[i] = new ChatComponentText(s);
      }
    }

    this.stats.readStatsFromNBT(compound);
  }
  /** Draws all of the hovering texts for the buttons that need explanation in the booklet */
  @SuppressWarnings("unchecked")
  public static void doHoverTexts(GuiBooklet booklet, int mouseX, int mouseY) {
    // Achievements Hover Text
    if (booklet.buttonAchievements.func_146115_a()) {
      booklet.drawHoveringText(
          Collections.singletonList(EnumChatFormatting.GOLD + "Show Achievements"), mouseX, mouseY);
    }
    // Config Hover Text
    else if (booklet.buttonConfig.func_146115_a()) {
      ArrayList list = new ArrayList();
      list.add(EnumChatFormatting.GOLD + "Show Configuration GUI");
      list.addAll(
          booklet
              .getFontRenderer()
              .listFormattedStringToWidth(
                  "It is highly recommended that you restart your game after changing anything as that prevents possible bugs occuring!",
                  GuiBooklet.TOOLTIP_SPLIT_LENGTH));
      booklet.drawHoveringText(list, mouseX, mouseY);

    }
    // Twitter Hover Text
    else if (booklet.buttonTwitter.func_146115_a()) {
      booklet.drawHoveringText(
          Collections.singletonList(
              EnumChatFormatting.GOLD + "Open @ActAddMod on Twitter in Browser"),
          mouseX,
          mouseY);
    }
    // Forum Hover Text
    else if (booklet.buttonForum.func_146115_a()) {
      booklet.drawHoveringText(
          Collections.singletonList(
              EnumChatFormatting.GOLD + "Open Minecraft Forum Post in Browser"),
          mouseX,
          mouseY);
    }
    // Update Checker Hover Text
    else if (booklet.buttonUpdate.func_146115_a()) {
      ArrayList list = new ArrayList();
      if (UpdateChecker.checkFailed) {
        list.add(
            IChatComponent.Serializer.func_150699_a(
                    StringUtil.localize("info." + ModUtil.MOD_ID_LOWER + ".update.failed"))
                .getFormattedText());
      } else if (UpdateChecker.needsUpdateNotify) {
        list.add(
            IChatComponent.Serializer.func_150699_a(
                    StringUtil.localize("info." + ModUtil.MOD_ID_LOWER + ".update.generic"))
                .getFormattedText());
        list.add(
            IChatComponent.Serializer.func_150699_a(
                    StringUtil.localizeFormatted(
                        "info." + ModUtil.MOD_ID_LOWER + ".update.versionCompare",
                        ModUtil.VERSION,
                        UpdateChecker.updateVersion))
                .getFormattedText());
        list.add(StringUtil.localize("info." + ModUtil.MOD_ID_LOWER + ".update.buttonOptions"));
      }
      booklet.drawHoveringText(list, mouseX, mouseY);
    } else {
      for (GuiButton button : booklet.bookmarkButtons) {
        if (button instanceof BookmarkButton && button.func_146115_a()) {
          ((BookmarkButton) button).drawHover(mouseX, mouseY);
        }
      }
    }
  }
Exemplo n.º 9
0
  @Override
  public void onBuild(int i, EntityPlayerSP player) {
    // 0 : opened GC inventory tab
    // 1,2,3 : Compressor, CF, Standard Wrench
    // 4,5,6 : Fuel loader, Launchpad, NASA Workbench
    // 7: oil found 8: placed rocket

    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    int flag = stats.buildFlags;
    if (flag == -1) flag = 0;
    int repeatCount = flag >> 9;
    if (repeatCount <= 3) {
      repeatCount++;
    }
    if ((flag & 1 << i) > 0) return;
    flag |= 1 << i;
    stats.buildFlags = (flag & 511) + (repeatCount << 9);
    GalacticraftCore.packetPipeline.sendToServer(
        new PacketSimple(
            EnumSimplePacket.S_BUILDFLAGS_UPDATE,
            player.worldObj.provider.getDimensionId(),
            new Object[] {stats.buildFlags}));
    switch (i) {
      case 0:
      case 1:
      case 2:
      case 3:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.help1")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/1"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/1"
                    + "\"}}]"));
        player.addChatMessage(
            new ChatComponentText(
                GCCoreUtil.translate("gui.message.help1a") + EnumColor.AQUA + " /gchelp"));
        break;
      case 4:
      case 5:
      case 6:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.help2")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/2"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/2"
                    + "\"}}]"));
        break;
      case 7:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.help3")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/oil"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/oil"
                    + "\"}}]"));
        break;
      case 8:
        player.addChatMessage(
            IChatComponent.Serializer.jsonToComponent(
                "[{\"text\":\""
                    + GCCoreUtil.translate("gui.message.prelaunch")
                    + ": \",\"color\":\"white\"},"
                    + "{\"text\":\" "
                    + EnumColor.BRIGHT_GREEN
                    + "wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/pre"
                    + "\","
                    + "\"color\":\"green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":"
                    + "{\"text\":\""
                    + GCCoreUtil.translate("gui.message.clicklink")
                    + "\",\"color\":\"yellow\"}},"
                    + "\"clickEvent\":{\"action\":\"open_url\",\"value\":\""
                    + "http://wiki."
                    + GalacticraftCore.PREFIX
                    + "com/wiki/pre"
                    + "\"}}]"));
        break;
    }
  }