コード例 #1
0
  @Override
  public void extendedSlotChanged(GuiExtendedItemSlot slot) {
    ItemStack stack = slot.getItemStack();

    if (stack.itemID == EnhancedPortals_deprecated.proxy.blockDummyPortal.blockID) {
      stack = new ItemStack(Item.dyePowder, 1, stack.getItemDamage());
    }

    PortalTexture text = Textures.getTextureFromItemStack(stack);

    if (text != null) {
      portalModifier.texture = text.getID();
    } else {
      portalModifier.texture = "C:5";
    }

    hasInteractedWith = true;
  }
コード例 #2
0
  public GuiPortalModifier(InventoryPlayer player, TileEntityPortalModifier modifier) {
    super(new ContainerPortalModifier(player, modifier), null);
    portalModifier = modifier;
    hasInteractedWith = false;
    isActive = portalModifier.isActive();

    extendedSlots.add(
        new GuiTextureSlot(
            xSize - 24, 15, Textures.getItemStackFromTexture(portalModifier.texture), this));
  }
コード例 #3
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;
            }
          }
        }
      }
    }
  }
コード例 #4
0
  @Override
  protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    super.drawGuiContainerBackgroundLayer(f, i, j);

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.func_110577_a(
        new ResourceLocation(
            Reference.RESOURCE_NAME, Reference.GUI_LOCATION + "portalModifier.png"));
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2 - 3;
    drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

    fontRenderer.drawString(
        Localization.localizeString("tile.portalModifier.name"),
        guiLeft
            + xSize / 2
            - fontRenderer.getStringWidth(Localization.localizeString("tile.portalModifier.name"))
                / 2,
        guiTop + -15,
        0xFFFFFF);
    fontRenderer.drawString(Strings.Upgrades.toString(), guiLeft + 8, guiTop + 3, 0xFF444444);
    fontRenderer.drawString(
        Strings.Modifications.toString(),
        guiLeft + xSize - 8 - fontRenderer.getStringWidth(Strings.Modifications.toString()),
        guiTop + 3,
        0xFF444444);
    fontRenderer.drawString(
        portalModifier.upgradeHandler.hasUpgrade(new UpgradeDialDevice())
            ? Strings.UniqueIdentifier.toString()
            : Strings.Network.toString(),
        guiLeft + 8,
        guiTop + 35,
        0xFF444444);

    boolean draw =
        portalModifier.isRemotelyControlled()
            ? portalModifier.dialDeviceNetwork.equals("")
            : portalModifier.modifierNetwork.equals("");

    if (draw) {
      String str =
          portalModifier.isRemotelyControlled()
              ? Strings.ClickToSetIdentifier.toString()
              : Strings.ClickToSetNetwork.toString();

      drawRect(guiLeft + 7, guiTop + 46, guiLeft + xSize - 7, guiTop + 64, 0x55000000);

      if (!EnhancedPortals_deprecated.proxy.isIdentifierTaken) {
        fontRenderer.drawStringWithShadow(
            str,
            guiLeft + xSize / 2 - fontRenderer.getStringWidth(str) / 2,
            guiTop + 51,
            0xFF00FF00);
      } else {
        fontRenderer.drawStringWithShadow(
            Strings.IdentifierInUse.toString(),
            guiLeft
                + xSize / 2
                - fontRenderer.getStringWidth(Strings.IdentifierInUse.toString()) / 2,
            guiTop + 51,
            0xEE0000);
      }
    }

    String network =
        portalModifier.isRemotelyControlled()
            ? portalModifier.dialDeviceNetwork
            : portalModifier.modifierNetwork;

    if (!network.equals("")) {
      String[] split = network.split(Reference.glyphSeperator);

      for (int i1 = 0; i1 < split.length; i1++) {
        for (int j1 = 0; j1 < Reference.glyphItems.size(); j1++) {
          if (Reference.glyphItems
              .get(j1)
              .getItemName()
              .replace("item.", "")
              .equalsIgnoreCase(split[i1])) {
            itemRenderer.renderItemIntoGUI(
                fontRenderer,
                mc.renderEngine,
                Reference.glyphItems.get(j1),
                guiLeft + 8 + i1 * 18,
                guiTop + 47);
          }
        }
      }
    }
  }