Пример #1
0
  private void updateContentsList() {
    List<ItemStack> items = tileEntity.getShowingItems();
    if (itemList.getMaximum() == 0) {
      // We need to refresh.
      for (ItemStack stack : items) {
        if (stack != null) {
          String displayName = BlockInfo.getReadableName(stack, 0);

          Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
          panel.addChild(new BlockRender(mc, this).setRenderItem(stack));
          panel.addChild(
              new Label(mc, this)
                  .setDynamic(true)
                  .setText(displayName)
                  .setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT));
          itemList.addChild(panel);
        }
      }
    }
  }
Пример #2
0
 private InvBlockInfo getSelectedContainer() {
   int selected = storageList.getSelected();
   if (selected != -1) {
     SyncedValueList<InvBlockInfo> inventories = tileEntity.getInventories();
     if (selected < inventories.size()) {
       InvBlockInfo invBlockInfo = inventories.get(selected);
       return invBlockInfo;
     }
   }
   return null;
 }
Пример #3
0
  private void updateStorageList() {
    SyncedValueList<InvBlockInfo> inventories = tileEntity.getInventories();
    if (inventories.getClientVersion() != clientVersion) {
      clientVersion = inventories.getClientVersion();
      storageList.removeChildren();
      for (InvBlockInfo blockInfo : inventories) {
        Coordinate c = blockInfo.getCoordinate();
        Block block = mc.theWorld.getBlock(c.getX(), c.getY(), c.getZ());
        int meta = mc.theWorld.getBlockMetadata(c.getX(), c.getY(), c.getZ());
        String displayName;
        if (block == null || block.isAir(mc.theWorld, c.getX(), c.getY(), c.getZ())) {
          displayName = "[REMOVED]";
          block = null;
        } else {
          displayName = BlockInfo.getReadableName(block, meta);
        }

        Panel panel = new Panel(mc, this).setLayout(new HorizontalLayout());
        panel.addChild(new BlockRender(mc, this).setRenderItem(block));
        panel.addChild(
            new Label(mc, this)
                .setText(displayName)
                .setHorizontalAlignment(HorizontalAlignment.ALIGH_LEFT)
                .setDesiredWidth(90));
        panel.addChild(new Label(mc, this).setDynamic(true).setText(c.toString()));
        storageList.addChild(panel);
      }
    }
    storageList.clearHilightedRows();
    Set<Coordinate> coordinates = fromServer_coordinates;
    int i = 0;
    for (InvBlockInfo blockInfo : inventories) {
      Coordinate c = blockInfo.getCoordinate();
      if (coordinates.contains(c)) {
        storageList.addHilightedRow(i);
      }
      i++;
    }
  }