コード例 #1
0
  @Override
  public void addInformation(
      ItemStack essentiaCell, EntityPlayer player, List displayList, boolean advancedItemTooltips) {
    // TODO: Save provider??
    // Get the contents of the cell
    IMEInventoryHandler<IAEFluidStack> handler =
        AEApi.instance()
            .registries()
            .cell()
            .getCellInventory(essentiaCell, null, StorageChannel.FLUIDS);

    // Ensure we have a cell inventory handler
    if (!(handler instanceof HandlerItemEssentiaCell)) {
      return;
    }

    // Cast to cell inventory handler
    HandlerItemEssentiaCell cellHandler = (HandlerItemEssentiaCell) handler;

    // Create the bytes tooltip
    String bytesTip =
        String.format(
            StatCollector.translateToLocal(
                ThaumicEnergistics.MOD_ID + ".tooltip.essentia.cell.bytes"),
            new Object[] {
              cellHandler.usedBytes() / ItemEssentiaCell.CONVERSION_SIZE,
              cellHandler.totalBytes() / ItemEssentiaCell.CONVERSION_SIZE
            });

    // Create the types tooltip
    String typesTip =
        String.format(
            StatCollector.translateToLocal(
                ThaumicEnergistics.MOD_ID + ".tooltip.essentia.cell.types"),
            new Object[] {cellHandler.usedTypes(), cellHandler.totalTypes()});

    // Add the tooltips
    displayList.add(bytesTip);
    displayList.add(typesTip);

    // Is the cell pre-formated?
    if (cellHandler.isPreformatted()) {
      displayList.add(
          StatCollector.translateToLocal("Appeng.GuiITooltip.Partitioned")
              + " - "
              + StatCollector.translateToLocal("Appeng.GuiITooltip.Precise"));
    }

    // Is shift being held?
    if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) {
      // Add information about the essentia types in the cell
      this.addContentsToCellDescription(cellHandler, displayList, player);
    }
  }
コード例 #2
0
  @Override
  public int getStatusForCell(ItemStack essentiaCell, IMEInventory handler) {
    // Do we have a handler?
    if (handler == null) {
      return ItemEssentiaCell.CELL_STATUS_MISSING;
    }

    // Get the inventory handler
    HandlerItemEssentiaCell cellHandler = (HandlerItemEssentiaCell) handler;

    // Full bytes?
    if (cellHandler.usedBytes() == cellHandler.totalBytes()) {
      return ItemEssentiaCell.CELL_STATUS_FULL;
    }

    // Full types?
    if (cellHandler.usedTypes() == cellHandler.totalTypes()) {
      return ItemEssentiaCell.CELL_STATUS_TYPES_FULL;
    }

    return ItemEssentiaCell.CELL_STATUS_HAS_ROOM;
  }