// updates slot visibility
  protected void updateSlots() {
    firstSlotId = slider.getValue() * columns;
    lastSlotId = Math.min(slotCount, firstSlotId + getDisplayedRows() * columns);

    int xd = border.w + xOffset;
    int yd = border.h + yOffset;

    if (shouldDrawName()) {
      yd += textBackground.h;
    }

    for (Object o : inventorySlots.inventorySlots) {
      Slot slot = (Slot) o;
      if (shouldDrawSlot(slot)) {
        // calc position of the slot
        int offset = slot.getSlotIndex() - firstSlotId;
        int x = (offset % columns) * this.slot.w;
        int y = (offset / columns) * this.slot.h;

        slot.xDisplayPosition = xd + x + 1;
        slot.yDisplayPosition = yd + y + 1;

        if (this.right) {
          slot.xDisplayPosition += parent.realWidth;
        } else {
          slot.xDisplayPosition -= this.xSize;
        }
      } else {
        slot.xDisplayPosition = 0;
        slot.yDisplayPosition = 0;
      }
    }
  }
Пример #2
0
  // updates slot visibility
  public void updateSlots() {
    // calculate displayed slots
    firstSlotId = slider.getValue() * columns;
    lastSlotId = Math.min(slotCount, firstSlotId + rows * columns);

    for (Slot slot : container.inventorySlots) {
      if (shouldDrawSlot(slot)) {
        // calc position of the slot
        int offset = slot.getSlotIndex() - firstSlotId;
        int x = (offset % columns) * GuiDynInventory.slot.w;
        int y = (offset / columns) * GuiDynInventory.slot.h;

        slot.xDisplayPosition = xOffset + x + 1;
        slot.yDisplayPosition = yOffset + y + 1;
      } else {
        slot.xDisplayPosition = 0;
        slot.yDisplayPosition = 0;
      }
    }
  }