示例#1
0
  /** only shows items which have tabToDisplayOn == this */
  public void getItemsForTab(List<ItemStack> stacks) {
    for (Item item : Item.itemRegistry) {
      if (item != null && item.getCreativeTab() == this) {
        item.getSubItems(item, this, stacks);
      }
    }

    if (this.getRelevantEnchantmentTypes() != null) {
      this.addEnchantmentBooksToList(stacks, this.getRelevantEnchantmentTypes());
    }
  }
  @Override
  public void registerItem(ModManager manager, String name, String modPrefix, Item item) {
    super.registerItem(manager, name, modPrefix, item);
    if (modPrefix != null) {
      if (item.unlocalizedName == null || item.unlocalizedName.isEmpty()) {
        item.setUnlocalizedName(modPrefix + name);
      }

      if (item.iconString == null || item.iconString.isEmpty()) {
        item.setTextureName(modPrefix + name);
      }
    }

    if (manager.defaultTab != null && item.getCreativeTab() == null) {
      item.setCreativeTab(manager.defaultTab);
    }
  }
  private void updateCreativeSearch() {
    CreativeInv.ContainerCreative containercreative =
        (CreativeInv.ContainerCreative) this.inventorySlots;
    containercreative.itemList.clear();

    CreativeTabs tab = CreativeTabs.creativeTabArray[selectedTabIndex];
    if (tab.hasSearchBar() && tab != CreativeTabs.tabAllSearch) {
      tab.displayAllReleventItems(containercreative.itemList);
      updateFilteredItems(containercreative);
      return;
    }

    Iterator iterator = Item.itemRegistry.iterator();

    while (iterator.hasNext()) {
      Item item = (Item) iterator.next();

      if (item != null && item.getCreativeTab() != null) {
        item.getSubItems(item, (CreativeTabs) null, containercreative.itemList);
      }
    }
    updateFilteredItems(containercreative);
  }