コード例 #1
0
  @Override
  public ItemStack onItemRightClick(ItemStack essentiaCell, World world, EntityPlayer player) {
    // Ensure the player is sneaking(holding shift)
    if (!player.isSneaking()) {
      return essentiaCell;
    }

    // TODO: SaveProvider??
    // Get the handler
    IMEInventoryHandler<IAEFluidStack> handler =
        AEApi.instance()
            .registries()
            .cell()
            .getCellInventory(essentiaCell, null, StorageChannel.FLUIDS);

    // Is it the correct handler type?
    if (!(handler instanceof HandlerItemEssentiaCell)) {
      return essentiaCell;
    }

    // Cast
    HandlerItemEssentiaCell cellHandler = (HandlerItemEssentiaCell) handler;

    // If the cell is empty, and the player can hold the casing
    if ((cellHandler.usedBytes() == 0)
        && (player.inventory.addItemStackToInventory(
            ItemEnum.STORAGE_CASING.getItemStackWithSize(1)))) {
      // Return the storage component
      return ItemEnum.STORAGE_COMPONENT.getItemStackWithDamage(essentiaCell.getItemDamage());
    }

    // Can not remove storage component, return the current cell as is.
    return essentiaCell;
  }
コード例 #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;
  }
コード例 #3
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);
    }
  }
コード例 #4
0
  private void addContentsToCellDescription(
      HandlerItemEssentiaCell cellHandler, List displayList, EntityPlayer player) {
    // Get the list of stored aspects
    List<AspectStack> cellAspects = cellHandler.getAvailableAspects();

    // Sort the list
    Collections.sort(cellAspects, new AspectStackComparator());

    for (AspectStack currentStack : cellAspects) {
      if (currentStack != null) {
        // Get the chat color
        String aspectChatColor = currentStack.getChatColor();

        // Does this aspect have color?
        if (aspectChatColor != null) {
          // Add the color header
          aspectChatColor = GuiHelper.CHAT_COLOR_HEADER + aspectChatColor;
        } else {
          // It does not, set to gray
          aspectChatColor = EnumChatFormatting.GRAY.toString();
        }

        // Build the display string
        String aspectInfo =
            String.format(
                "%s%s%s x %d",
                aspectChatColor,
                currentStack.getAspectName(player),
                EnumChatFormatting.GRAY.toString(),
                currentStack.amount);

        // Add to the list
        displayList.add(aspectInfo);
      }
    }
  }