Ejemplo n.º 1
0
  @Override
  protected void actionPerformed(GuiButton button) {
    if (button.id == 100) {
      mc.thePlayer.closeScreen();
    } else if (button.id == 10) {
      portalModifier.redstoneSetting = 0;
      ((GuiItemStackButton) buttonList.get(2)).isActive = false;
      ((GuiItemStackButton) buttonList.get(3)).displayString = "0";
      ((GuiItemStackButton) buttonList.get(3)).isActive = false;
      ((GuiItemStackButton) buttonList.get(4)).isActive = false;
      hasInteractedWith = true;
      ((GuiItemStackButton) button).isActive = true;
    } else if (button.id == 11) {
      portalModifier.redstoneSetting = 1;
      ((GuiItemStackButton) buttonList.get(1)).isActive = false;
      ((GuiItemStackButton) buttonList.get(3)).displayString = "0";
      ((GuiItemStackButton) buttonList.get(3)).isActive = false;
      ((GuiItemStackButton) buttonList.get(4)).isActive = false;
      hasInteractedWith = true;
      ((GuiItemStackButton) button).isActive = true;
    } else if (button.id == 12) {
      int num = 0;

      if (button.displayString != null && button.displayString != "") {
        num = Integer.parseInt(button.displayString);
      }

      if (num + 1 < 16) {
        button.displayString = "" + (num + 1);
        num++;
      } else {
        button.displayString = "1";
        num = 1;
      }

      portalModifier.redstoneSetting = (byte) (2 + num);
      ((GuiItemStackButton) buttonList.get(1)).isActive = false;
      ((GuiItemStackButton) buttonList.get(2)).isActive = false;
      ((GuiItemStackButton) buttonList.get(4)).isActive = false;
      hasInteractedWith = true;
      ((GuiItemStackButton) button).isActive = true;
    } else if (button.id == 13) {
      int num = 0;

      if (button.displayString != null && button.displayString != "") {
        num = Integer.parseInt(button.displayString);
      }

      if (num + 1 < 5) {
        button.displayString = "" + (num + 1);
        num++;
      } else {
        button.displayString = "1";
        num = 1;
      }

      portalModifier.thickness = (byte) (num - 1);
      ((GuiItemStackButton) button)
          .hoverText.set(
              1,
              EnumChatFormatting.GRAY
                  + (portalModifier.thickness == 0
                      ? Strings.Normal.toString()
                      : portalModifier.thickness == 1
                          ? Strings.Thick.toString()
                          : portalModifier.thickness == 2
                              ? Strings.Thicker.toString()
                              : Strings.FullBlock.toString()));
      hasInteractedWith = true;
    } else if (button.id == 14) {
      if (portalModifier.upgradeHandler.hasUpgrade(new UpgradeDialDevice())) {
        ((GuiItemStackButton) button).isActive = true;
        return;
      }

      portalModifier.redstoneSetting = -1;
      ((GuiItemStackButton) buttonList.get(1)).isActive = false;
      ((GuiItemStackButton) buttonList.get(2)).isActive = false;
      ((GuiItemStackButton) buttonList.get(3)).displayString = "0";
      ((GuiItemStackButton) buttonList.get(3)).isActive = false;
      hasInteractedWith = true;
      ((GuiItemStackButton) button).isActive = true;
    } else if (button.id == 50) {
      GuiItemStackButton guiButton = (GuiItemStackButton) button;

      for (Upgrade u : Upgrade.getAllUpgrades()) {
        if (u.getDisplayItemStack().isItemEqual(guiButton.itemStack)) {
          if (portalModifier.upgradeHandler.removeUpgrade(u.getUpgradeID(), portalModifier)) {
            buttonList.remove(button);
            hasInteractedWith = true;
          }

          if (u.getName().equals(new UpgradeDialDevice().getName())) {
            if (portalModifier.redstoneSetting != -1) {
              ((GuiItemStackButton) buttonList.get(4)).isActive = false;
            }
          }
        }
      }
    }
  }
Ejemplo n.º 2
0
  @SuppressWarnings("unchecked")
  @Override
  public void initGui() {
    super.initGui();

    okayButton =
        new GuiButton(100, width / 2 - 50, height / 2 - 10, 100, 20, Strings.Accept.toString());
    buttonList.add(okayButton);
    okayButton.drawButton = isActive;

    List<String> strList = new ArrayList<String>();
    strList.add(Strings.RedstoneControl.toString());
    strList.add(EnumChatFormatting.GRAY + Strings.Normal.toString());
    buttonList.add(
        new GuiItemStackButton(
            10,
            guiLeft + xSize + 4,
            guiTop + 4,
            new ItemStack(Block.torchRedstoneActive),
            portalModifier.redstoneSetting == 0,
            strList,
            false,
            !portalModifier.upgradeHandler.hasUpgrade(new UpgradeDialDevice())));

    strList = new ArrayList<String>();
    strList.add(Strings.RedstoneControl.toString());
    strList.add(EnumChatFormatting.GRAY + Strings.Inverted.toString());
    buttonList.add(
        new GuiItemStackButton(
            11,
            guiLeft + xSize + 4,
            guiTop + 24,
            new ItemStack(Block.torchRedstoneIdle),
            portalModifier.redstoneSetting == 1,
            strList,
            false,
            !portalModifier.upgradeHandler.hasUpgrade(new UpgradeDialDevice())));

    strList = new ArrayList<String>();
    strList.add(Strings.RedstoneControl.toString());
    strList.add(EnumChatFormatting.GRAY + Strings.Precise.toString());
    buttonList.add(
        new GuiItemStackButton(
            12,
            guiLeft + xSize + 4,
            guiTop + 44,
            new ItemStack(Item.redstone),
            portalModifier.redstoneSetting > 1,
            strList,
            "" + (portalModifier.redstoneSetting > 2 ? portalModifier.redstoneSetting - 2 : 0),
            !portalModifier.upgradeHandler.hasUpgrade(new UpgradeDialDevice())));

    strList = new ArrayList<String>();
    strList.add(Strings.RedstoneControl.toString());
    strList.add(EnumChatFormatting.GRAY + Strings.Disabled.toString());
    buttonList.add(
        new GuiItemStackButton(
            14,
            guiLeft + xSize + 4,
            guiTop + 64,
            new ItemStack(Item.gunpowder),
            portalModifier.redstoneSetting == -1
                || portalModifier.upgradeHandler.hasUpgrade(new UpgradeDialDevice()),
            strList,
            false,
            true));

    strList = new ArrayList<String>();
    strList.add(Strings.Thickness.toString());
    strList.add("");
    buttonList.add(
        new GuiItemStackButton(
            13,
            guiLeft + xSize - 42,
            guiTop + 15,
            new ItemStack(Block.portal),
            true,
            strList,
            true));
    ((GuiItemStackButton) buttonList.get(5)).displayString = "" + (portalModifier.thickness + 1);
    ((GuiItemStackButton) buttonList.get(5))
        .hoverText.set(
            1,
            EnumChatFormatting.GRAY
                + (portalModifier.thickness == 0
                    ? Strings.Normal.toString()
                    : portalModifier.thickness == 1
                        ? Strings.Thick.toString()
                        : portalModifier.thickness == 2
                            ? Strings.Thicker.toString()
                            : Strings.FullBlock.toString()));

    for (int i = portalModifier.upgradeHandler.getUpgrades().size() - 1; i >= 0; i--) {
      buttonList.add(
          new GuiItemStackButton(
              50,
              guiLeft + 8 + i * 18,
              guiTop + 15,
              portalModifier.upgradeHandler.getUpgrade(i).getDisplayItemStack(),
              false,
              portalModifier.upgradeHandler.getUpgrade(i).getText(true),
              true));
    }
  }