// split from above for custom search tabs private void updateFilteredItems(CreativeInv.ContainerCreative containercreative) { Iterator iterator; Enchantment[] aenchantment = Enchantment.enchantmentsList; int j = aenchantment.length; for (int i = 0; i < j; ++i) { Enchantment enchantment = aenchantment[i]; if (enchantment != null && enchantment.type != null) { Items.enchanted_book.func_92113_a(enchantment, containercreative.itemList); } } iterator = containercreative.itemList.iterator(); String s1 = this.searchField.getText().toLowerCase(); while (iterator.hasNext()) { ItemStack itemstack = (ItemStack) iterator.next(); boolean flag = false; Iterator iterator1 = itemstack .getTooltip(this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips) .iterator(); while (true) { if (iterator1.hasNext()) { String s = (String) iterator1.next(); if (!s.toLowerCase().contains(s1)) { continue; } flag = true; } if (!flag) { iterator.remove(); } break; } } this.currentScroll = 0.0F; containercreative.scrollTo(0.0F); }
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); }