Skip to content

Commit

Permalink
Beta13:
Browse files Browse the repository at this point in the history
* @MOD->item searching has been added using item subsets, allowing for things like `@Blocks.MobSpawners->zombie`
* DoubleFilteredFilter - Requires both filters to apply (Subset & Pattern)
* Finally updated the README.md
  • Loading branch information
mitchej123 committed Apr 10, 2021
1 parent 3899588 commit 254e625
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 8 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NotEnoughItems - GTNH
# NotEnoughItems Unofficial - By the GTNH Team

A continuation of NotEnoughItems for 1.7.10 by the developers of Gregtech: New Horizons modpack, with features either inspired and/or backported from JustEnoughItems

Expand All @@ -10,12 +10,19 @@ We've tested this against all of the mods included in GTNH, as well as a limited

## New Features:

* Speed - Uses a parallel stream to search the item list over multiple cores, resulting in 2-6x faster searches on average [Feels instantaneous]
* Speed
- Uses a parallel stream to search the item list over multiple cores, resulting in 2-6x faster searches on average
- Loads the recipe handlers in parallel
* A textbox for search with most of the features you'd expect - moving forward, backwards, selection, etc
* Bookmarks! What are you in the process of crafting? Bookmark it using either 'A' or configure your own key.
* Toggle bookmark pane. Default shortcut key `B`. Item Subsets menu is only available if bookmarks are not visible.
* Utility/Cheat buttons line up and wrap based on GUI size
* ItemList is no longer regenerated from the ItemRegistry on every inventory load

* JEI (Or Creative) Style tabs [Optional] Note: Requires explicit support to be added for an ItemStack to render, otherwise falls back to the first two letters of the handler name.
* Tabs/Handlers are loaded from a CSV config in the JAR (or optionally from the config folder). IMCEvent for mod authors to register this information is planned.
* `@[Mod]->[item]` searching. ex: `@Gregtech->iron ingot`
* Cycle between Recipe, Utility, and Cheat mode by cntrl clicking on the Wrench Icon

## Other items of note:

* Licensed under LGPL - Use this however you want, but please give back any modifications
Expand Down
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ mc_version=1.7.10
forge_version=10.13.4.1614-1.7.10
ccl_version=1.1.3.138
ccc_version=1.0.7.+
mod_version=2.1.0-GTNH-beta12
mod_version=2.1.0-GTNH-beta13
22 changes: 22 additions & 0 deletions src/codechicken/nei/DoubleFilteredFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package codechicken.nei;

import codechicken.nei.api.ItemFilter;
import net.minecraft.item.ItemStack;

public class DoubleFilteredFilter implements ItemFilter {
private ItemFilter filter;
private ItemList.PatternItemFilter patternFilter;

public DoubleFilteredFilter(ItemFilter filter, String itemFilter) {
this.filter = filter;
this.patternFilter = new ItemList.PatternItemFilter(SearchField.getPattern(itemFilter));
}

@Override
public boolean matches(ItemStack item) {
if(filter.matches(item)) {
return patternFilter.matches(item);
}
return false;
}
}
1 change: 1 addition & 0 deletions src/codechicken/nei/ItemList.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private void damageSearch(Item item, List<ItemStack> permutations) {
}

@Override
@SuppressWarnings("unchecked")
public void execute() {
// System.out.println("Executing NEI Item Loading");
ThreadOperationTimer timer = getTimer(500);
Expand Down
31 changes: 27 additions & 4 deletions src/codechicken/nei/SubsetWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,18 @@ protected void cacheState() {
for(SubsetTag tag : sorted)
tag.cacheState();
}
public void addFiltersWithItem(List<ItemFilter> filters, String itemSearch) {
if(itemSearch == null) {
addFilters(filters);
} else {
if(filter != null)
filters.add(new DoubleFilteredFilter(filter, itemSearch));

for(SubsetTag child : sorted)
child.addFiltersWithItem(filters, itemSearch);

}
}
public void addFilters(List<ItemFilter> filters) {
if(filter != null)
filters.add(filter);
Expand Down Expand Up @@ -826,20 +837,32 @@ public ItemFilter getFilter(String searchText) {
return null;

searchText = searchText.substring(1);
String itemSearch = null;
if(searchText.contains("->")) {
String[] split = searchText.split("->");
searchText = split[0];
if(split.length > 1) itemSearch = split[1];
}

AnyMultiItemFilter filter = new AnyMultiItemFilter();
SubsetTag tag = getTag(searchText);
if(tag != null)
tag.addFilters(filter.filters);
if(tag != null) {
// We've got an exact match
tag.addFiltersWithItem(filter.filters, itemSearch);
}
else {
// Try searching for a substring
Pattern p = SearchField.getPattern(searchText);
if(p == null) return null;

List<SubsetTag> matching = new LinkedList<>();
root.search(matching, p);
if(matching.isEmpty()) return null;
for(SubsetTag tag2 : matching)
tag2.addFilters(filter.filters);
for(SubsetTag tag2 : matching) {
tag2.addFiltersWithItem(filter.filters, itemSearch);
}
}

return filter;
}

Expand Down
3 changes: 3 additions & 0 deletions src/codechicken/nei/api/ItemInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ public BiomeGenBase[] array() {
API.addOption(new HandlerDumper("tools.dump.handlers"));
}

@SuppressWarnings("unchecked")
private static void parseModItems() {
HashMap<String, ItemStackSet> modSubsets = new HashMap<>();
for (Item item : (Iterable<Item>) Item.itemRegistry) {
Expand Down Expand Up @@ -330,6 +331,7 @@ private static void addDefaultDropDowns() {
API.addSubset("Blocks.MobSpawners", ItemStackSet.of(Blocks.mob_spawner));
}

@SuppressWarnings("unchecked")
private static void searchItems() {
ItemStackSet tools = new ItemStackSet();
ItemStackSet picks = new ItemStackSet();
Expand Down Expand Up @@ -452,6 +454,7 @@ private static void addSpawnEggs()
addEntityEgg(EntityIronGolem.class, 0xC5C2C1, 0xffe1cc);
}

@SuppressWarnings("unchecked")
private static void addEntityEgg(Class<?> entity, int i, int j) {
int id = (Integer)EntityList.classToIDMapping.get(entity);
EntityList.entityEggs.put(id, new EntityEggInfo(id, i, j));
Expand Down

0 comments on commit 254e625

Please sign in to comment.