Beispiel #1
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()));
    }
  }
Beispiel #2
0
  @Override
  public void drawScreen(int mouseX, int mouseY, float ticks) {
    super.drawScreen(mouseX, mouseY, ticks);

    int i = 0;

    if (prevHover.checkHover(mouseX, mouseY)) {
      i = -1;
    } else if (nextHover.checkHover(mouseX, mouseY)) {
      i = 1;
    }

    if (container.isRecipes() && i != 0) {
      ItemStack stack = container.getNextRecipe(i);

      drawCreativeTabHoveringText(stack.getDisplayName(), mouseX, mouseY);
    }

    if (container.isRecipes()
        && mouseX >= guiLeft + recipesX - 5
        && mouseX <= guiLeft + xSize - 5
        && mouseY >= guiTop + recipesY - 4
        && mouseY <= guiTop + recipesY + 10) {
      tooltips.clear();

      for (ItemStack stack : container.getRecipes()) {
        tooltips.add(stack.getDisplayName());
      }

      drawHoveringText(tooltips, mouseX, mouseY);
    }
  }
Beispiel #3
0
  @Override
  protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    fontRendererObj.drawString(I18n.format("container.crafting") + " EX", 28, 6, 0x404040);
    fontRendererObj.drawString(I18n.format("container.inventory"), 8, ySize - 94, 0x404040);

    if (container.isRecipes()) {
      String str = container.getCurrentIndex() + 1 + " / " + container.getRecipeSize();
      recipesX = xSize - fontRendererObj.getStringWidth(str) - 10;
      recipesY = 6;
      fontRendererObj.drawString(str, recipesX, recipesY, 0x707070);
    }

    if (mouseX >= guiLeft && mouseX <= guiLeft + 20 && mouseY >= guiTop && mouseY <= guiTop + 20) {
      GlStateManager.pushMatrix();
      GlStateManager.scale(0.82F, 0.82F, 1.0F);
      RenderHelper.enableGUIStandardItemLighting();
      itemRender.zLevel = 100.0F;
      itemRender.renderItemAndEffectIntoGUI(CRAFTING_TABLE, 6, 6);
      itemRender.zLevel = 0.0F;
      RenderHelper.disableStandardItemLighting();
      GlStateManager.popMatrix();
    }
  }
Beispiel #4
0
  @Override
  public void handleMouseInput() throws IOException {
    super.handleMouseInput();

    int mouseX = Mouse.getEventX() * width / mc.displayWidth;
    int mouseY = height - Mouse.getEventY() * height / mc.displayHeight - 1;
    Slot slot = container.getSlot(0);

    if (isPointInRegion(slot.xPos - 5, slot.yPos - 5, 21, 21, mouseX, mouseY)) {
      int wheel = Mouse.getDWheel();

      if (wheel < 0) {
        actionPerformed(nextButton);
      } else if (wheel > 0) {
        actionPerformed(prevButton);
      }
    }
  }
Beispiel #5
0
  protected void resultSelected(ItemStack stack) {
    int prev = container.getCurrentIndex();

    container.resetCurrentIndex();

    for (int i = 0; i < container.getRecipeSize(); ++i) {
      if (ItemStack.areItemStacksEqual(stack, container.getNextRecipe(i))) {
        CraftingEX.NETWORK.sendToServer(new NextRecipeMessage(i));

        container.nextRecipe(i);

        return;
      }
    }

    container.nextRecipe(prev);
  }
Beispiel #6
0
  @Override
  protected void actionPerformed(GuiButton button) {
    if (!button.enabled) {
      return;
    }

    int next;

    switch (button.id) {
      case 0:
        next = -1;
        break;
      case 1:
        next = 1;
        break;
      default:
        return;
    }

    CraftingEX.NETWORK.sendToServer(new NextRecipeMessage(next));

    container.nextRecipe(next);
  }
Beispiel #7
0
  @Override
  public void updateScreen() {
    super.updateScreen();

    prevButton.visible = nextButton.visible = container.isRecipes();
  }