コード例 #1
0
ファイル: GuiFrequency.java プロジェクト: Randolph-J/ICBM
  /** Adds the buttons (and other controls) to the screen in question. */
  @Override
  public void initGui() {
    super.initGui();

    this.textFieldFrequency = new GuiTextField(fontRenderer, 80, 50, 40, 12);
    this.textFieldFrequency.setMaxStringLength(4);

    if (itemStack != null) {
      this.textFieldFrequency.setText(
          ((IItemFrequency) this.itemStack.getItem()).getFrequency(this.itemStack) + "");
    }
  }
コード例 #2
0
ファイル: GuiFrequency.java プロジェクト: Randolph-J/ICBM
  /** Call this method from you GuiScreen to process the keys into textbox. */
  @Override
  public void keyTyped(char par1, int par2) {
    super.keyTyped(par1, par2);
    this.textFieldFrequency.textboxKeyTyped(par1, par2);

    try {
      int newFrequency = Math.max(0, Integer.parseInt(this.textFieldFrequency.getText()));
      this.textFieldFrequency.setText(newFrequency + "");

      if (((IItemFrequency) this.itemStack.getItem()).getFrequency(this.itemStack)
          != newFrequency) {
        ((IItemFrequency) this.itemStack.getItem()).setFrequency(newFrequency, this.itemStack);
        PacketDispatcher.sendPacketToServer(
            ICBMCore.PACKET_ITEM.getPacket(this.player, newFrequency));
      }
    } catch (NumberFormatException e) {
    }
  }
コード例 #3
0
ファイル: GuiFrequency.java プロジェクト: Randolph-J/ICBM
 /** Args: x, y, buttonClicked */
 @Override
 public void mouseClicked(int par1, int par2, int par3) {
   super.mouseClicked(par1, par2, par3);
   this.textFieldFrequency.mouseClicked(par1 - containerWidth, par2 - containerHeight, par3);
 }