Пример #1
0
  @Override
  protected void keyTyped(char c, int code) throws IOException {
    super.keyTyped(c, code);

    switch (code) {
      case Keyboard.KEY_RIGHT:
        nextButton.playPressSound(mc.getSoundHandler());
        actionPerformed(nextButton);
        break;
      case Keyboard.KEY_LEFT:
        prevButton.playPressSound(mc.getSoundHandler());
        actionPerformed(prevButton);
        break;
    }
  }
Пример #2
0
  @Override
  protected void mouseClicked(int mouseX, int mouseY, int code) throws IOException {
    super.mouseClicked(mouseX, mouseY, code);

    if (code == 0
        && mouseX >= guiLeft
        && mouseX <= guiLeft + 20
        && mouseY >= guiTop
        && mouseY <= guiTop + 20) {
      nextButton.playPressSound(mc.getSoundHandler());

      ItemStack[] items = new ItemStack[container.craftMatrix.getSizeInventory()];

      for (int i = 0; i < items.length; ++i) {
        items[i] = container.craftMatrix.removeStackFromSlot(i);
      }

      CraftingEX.NETWORK.sendToServer(new OpenCraftingMessage(pos, items));
    } else if (code == 0
        && mouseX <= guiLeft + xSize
        && mouseX >= guiLeft + xSize - 50
        && mouseY >= guiTop
        && mouseY <= guiTop + 20
        && container.isRecipes()) {
      mc.displayGuiScreen(new GuiCraftingResult(this, container.getRecipes()));
    }
  }
 @Override
 public void playPressSound(SoundHandler soundHandlerIn) {
   if (soundSelect != null && !selected) {
     SoundsExtraBitManipulation.playSound(soundSelect);
     return;
   }
   if (soundDeselect != null && selected) {
     SoundsExtraBitManipulation.playSound(soundDeselect);
     return;
   }
   super.playPressSound(soundHandlerIn);
 }
Пример #4
0
  /** Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton */
  protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
    if (mouseButton == 0) {
      for (int i = 0; i < this.buttonList.size(); ++i) {
        GuiButton guibutton = (GuiButton) this.buttonList.get(i);

        if (guibutton.mousePressed(this.mc, mouseX, mouseY)) {
          net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre event =
              new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Pre(
                  this, guibutton, this.buttonList);
          if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event)) break;
          guibutton = event.button;
          this.selectedButton = guibutton;
          guibutton.playPressSound(this.mc.getSoundHandler());
          this.actionPerformed(guibutton);
          if (this.equals(this.mc.currentScreen))
            net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(
                new net.minecraftforge.client.event.GuiScreenEvent.ActionPerformedEvent.Post(
                    this, event.button, this.buttonList));
        }
      }
    }
  }