Exemplo n.º 1
0
  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);
  }
Exemplo n.º 2
0
  private void setCurrentCreativeTab(CreativeTabs p_147050_1_) {
    if (p_147050_1_ == null) return;
    int i = selectedTabIndex;
    selectedTabIndex = p_147050_1_.getTabIndex();
    CreativeInv.ContainerCreative containercreative =
        (CreativeInv.ContainerCreative) this.inventorySlots;
    this.field_147008_s.clear();
    containercreative.itemList.clear();
    p_147050_1_.displayAllReleventItems(containercreative.itemList);

    if (p_147050_1_ == CreativeTabs.tabInventory) {
      Container container = this.mc.thePlayer.inventoryContainer;

      if (this.field_147063_B == null) {
        this.field_147063_B = containercreative.inventorySlots;
      }

      containercreative.inventorySlots = new ArrayList();

      for (int j = 0; j < container.inventorySlots.size(); ++j) {
        CreativeInv.CreativeSlot creativeslot =
            new CreativeInv.CreativeSlot((Slot) container.inventorySlots.get(j), j);
        containercreative.inventorySlots.add(creativeslot);
        int k;
        int l;
        int i1;

        if (j >= 5 && j < 9) {
          k = j - 5;
          l = k / 2;
          i1 = k % 2;
          creativeslot.xDisplayPosition = 9 + l * 54;
          creativeslot.yDisplayPosition = 6 + i1 * 27;
        } else if (j >= 0 && j < 5) {
          creativeslot.yDisplayPosition = -2000;
          creativeslot.xDisplayPosition = -2000;
        } else if (j < container.inventorySlots.size()) {
          k = j - 9;
          l = k % 9;
          i1 = k / 9;
          creativeslot.xDisplayPosition = 9 + l * 18;

          if (j >= 36) {
            creativeslot.yDisplayPosition = 112;
          } else {
            creativeslot.yDisplayPosition = 54 + i1 * 18;
          }
        }
      }

      this.field_147064_C = new Slot(field_147060_v, 0, 173, 112);
      containercreative.inventorySlots.add(this.field_147064_C);
    } else if (i == CreativeTabs.tabInventory.getTabIndex()) {
      containercreative.inventorySlots = this.field_147063_B;
      this.field_147063_B = null;
    }

    if (this.searchField != null) {
      if (p_147050_1_.hasSearchBar()) {
        this.searchField.setVisible(true);
        this.searchField.setCanLoseFocus(false);
        this.searchField.setFocused(true);
        this.searchField.setText("");
        this.updateCreativeSearch();
      } else {
        this.searchField.setVisible(false);
        this.searchField.setCanLoseFocus(true);
        this.searchField.setFocused(false);
      }
    }

    this.currentScroll = 0.0F;
    containercreative.scrollTo(0.0F);
  }