Compare commits

..
Author SHA1 Message Date
Jason Mitchell 0fad93fb3b Update CCL Dep (#501) 2024-07-03 09:41:26 -07:00
b1a34c761b Create JEI-like Advanced Search (#485)
* Create JEI like Search

* add subfilter

* fix extended search pattern

* fix search crash without prefixes

* fix unicode case in search

* add regexp to extended patternMode

* move autofocus config to seatch widget panel

* code refactoring

* add matching language to searh parser

* fix type

* fix modname search

* clean cache after add new provider

---------

Co-authored-by: slprime <[email protected]>
Co-authored-by: Martin Robertz <[email protected]>
2024-06-27 17:03:50 +02:00
Martin Robertz cc9715d9f2 update 2024-06-18 20:33:08 +02:00
Jason Mitchell be253a00d2 Broaden visibility (#495)
Fixes #473
2024-06-18 20:25:26 +02:00
10 changed files with 36 additions and 18 deletions

No files matched your search

+1 -2
View File
@@ -1,7 +1,6 @@
// Add your dependencies here
dependencies {
api('com.github.GTNewHorizons:CodeChickenLib:1.2.1:dev')
api('com.github.GTNewHorizons:CodeChickenCore:1.2.1:dev')
api('com.github.GTNewHorizons:CodeChickenCore:1.3.0:dev')
shadowImplementation('org.apache.commons:commons-csv:1.10.0')
}
+2 -2
View File
@@ -141,7 +141,7 @@ modrinthProjectId = notenoughitems-unofficial
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
modrinthRelations = required-project\:codechickenlib-unofficial;required-project\:codechickencore-unofficial
modrinthRelations = required-project\:codechickencore-unofficial
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
#
@@ -155,7 +155,7 @@ curseForgeProjectId = 358228
# and the name is the CurseForge project slug of the other mod.
# Example: requiredDependency:railcraft;embeddedLibrary:cofhlib;incompatible:buildcraft
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
curseForgeRelations = requiredDependency\:codechickencore-unofficial;requiredDependency\:codechickenlib-unofficial
curseForgeRelations = requiredDependency\:codechickencore-unofficial
# Optional parameter to customize the produced artifacts. Use this to preserve artifact naming when migrating older
# projects. New projects should not use this parameter.
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Vendored
+1 -1
View File
@@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.22'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.23'
}
@@ -235,7 +235,7 @@ public class SearchField extends TextField implements ItemFilterProvider {
}
public static String getEscapedSearchText(ItemStack stack) {
final FluidStack fluidStack = StackInfo.getFluid(stack);
final FluidStack fluidStack = StackInfo.isFluidContainer(stack) ? null : StackInfo.getFluid(stack);
String displayName;
if (fluidStack != null) {
@@ -65,12 +65,17 @@ public class SearchTokenParser {
private static class ProvidersCache {
protected String languageCode = null;
protected List<ISearchParserProvider> providers;
public String languageCode = null;
public List<ISearchParserProvider> providers = new ArrayList<>();
public void clear() {
this.languageCode = null;
this.providers.clear();
}
}
protected final List<ISearchParserProvider> searchProviders;
protected ProvidersCache providersCache = new ProvidersCache();
protected final ProvidersCache providersCache = new ProvidersCache();
public SearchTokenParser(List<ISearchParserProvider> searchProviders) {
this.searchProviders = searchProviders;
@@ -82,6 +87,7 @@ public class SearchTokenParser {
public void addProvider(ISearchParserProvider provider) {
this.searchProviders.add(provider);
this.providersCache.clear();
}
protected List<ISearchParserProvider> getProviders() {
@@ -93,7 +99,7 @@ public class SearchTokenParser {
for (int index = this.searchProviders.size() - 1; index >= 0; index--) {
ISearchParserProvider provider = this.searchProviders.get(index);
if (!providers.containsKey(provider.getPrefix()) && provider.getSearchMode() != SearchMode.NEVER
if (!providers.containsKey(provider.getPrefix())
&& provider.getMatchingLanguages().contains(currentLanguage)) {
providers.put(provider.getPrefix(), provider);
}
@@ -107,7 +113,9 @@ public class SearchTokenParser {
}
public ISearchParserProvider getProvider(char ch) {
return getProviders().stream().filter(provider -> provider.getPrefix() == ch).findFirst().orElse(null);
return getProviders().stream()
.filter(provider -> provider.getSearchMode() == SearchMode.PREFIX && provider.getPrefix() == ch)
.findFirst().orElse(null);
}
public ItemFilter getFilter(String filterText) {
@@ -197,7 +197,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
return ingredients;
}
protected void randomRenderPermutation(List<PositionedStack> stacks, long cycle) {
public void randomRenderPermutation(List<PositionedStack> stacks, long cycle) {
final ItemFilter filter = getItemFilter();
final int randCycle = Math.abs(new Random(cycle + offset).nextInt());
@@ -228,7 +228,7 @@ public abstract class TemplateRecipeHandler implements ICraftingHandler, IUsageH
}
@Deprecated
protected void randomRenderPermutation(PositionedStack stack, long cycle) {
public void randomRenderPermutation(PositionedStack stack, long cycle) {
Random rand = new Random(cycle + offset);
stack.setPermutationToRender((int) (Math.abs(rand.nextInt()) % stack.items.length));
}
@@ -8,6 +8,8 @@ import net.minecraft.item.ItemStack;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.api.ItemFilter;
import codechicken.nei.api.ItemInfo;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.GameRegistry.UniqueIdentifier;
@@ -21,7 +23,16 @@ public class ModNameFilter implements ItemFilter {
@Override
public boolean matches(ItemStack itemStack) {
return this.pattern.matcher(getModId(itemStack.getItem())).find();
return this.pattern.matcher(nameFromStack(itemStack.getItem())).find();
}
protected static String nameFromStack(Item item) {
try {
ModContainer mod = Loader.instance().getIndexedModList().get(getModId(item));
return mod == null ? "Minecraft" : mod.getName();
} catch (NullPointerException e) {
return "";
}
}
protected static String getModId(Item item) {
@@ -54,7 +54,7 @@ public class TooltipFilter implements ItemFilter {
@Override
public boolean matches(ItemStack itemStack) {
return pattern.matcher(getSearchName(itemStack)).find();
return pattern.matcher(getSearchTooltip(itemStack)).find();
}
public static void populateSearchMap() {
@@ -68,7 +68,7 @@ public class TooltipFilter implements ItemFilter {
itemSearchNames.keySet().removeAll(oldItems);
}
protected static String getSearchName(ItemStack stack) {
protected static String getSearchTooltip(ItemStack stack) {
return itemSearchNames.computeIfAbsent(new ItemStackKey(stack), key -> getTooltip(key.stack));
}