mezz / JustEnoughItems

Item and Recipe viewing mod for Minecraft
https://www.curseforge.com/minecraft/mc-mods/jei
MIT License
781 stars 303 forks source link

Regex search #63

Closed SoniEx2 closed 8 years ago

SoniEx2 commented 8 years ago

NEI can search regexes. Please add regex search.

mezz commented 8 years ago

Sorry I have already explained to you on reddit, and twitter, and IRC.

No regex, I want JEI to run well :). You can search in the middle of names and use spaces for multiple requirements though. "Wren @ildcraf" is valid for instance. Each character typed narrows down the search (except @ prefix for mod names and space) which makes it very fast and efficient. Regex doesn't have such nice properties, and I would need to run expensive comparisons across every item for each character typed, with no ability to cache results.

Regex is wonderful for all kinds of things, like searching across long sentences of text, refactoring code, or for complex queries, but searching against item names is not one of those things.

I don't think there are real circumstances where regex is more useful than the current search implementation, for this specific application.

SoniEx2 commented 8 years ago

Actually you can compile the item list into a long string, and map the positions back to the items.

mezz commented 8 years ago

That doesn't make any sense at all. You're hyped up about regex without thinking about if it's even useful here. Please go write a regex HTML parser and report back.

SoniEx2 commented 8 years ago

I have a Lua parser in regex... does that count?

mezz commented 8 years ago

Reference to this.

SoniEx2 commented 8 years ago

You can parse HTML with regex.

boop5 commented 7 years ago

It's really annoying to not have regular expressions to work with. There are multiple legit use cases.

Also. It's even more annoying that one can't use item id's.

I was really hyped about JEI since NEI had some issues (those npe's argh..) and I read a lot of positive. At first I thought well u gotta adjust your work pattern to JEI but to be honest there are too many things which are missing. Meh.

@mezz

shadowfacts commented 7 years ago

What actual regex features do you need for searching Minecraft items? The only one I can think of is | for or.

way2muchnoise commented 7 years ago

I'm with @shadowfacts on this one. I don't see much use for regex. An OR feature would be nice but is it really needed? Seems like it is there already

mezz commented 7 years ago

We have an OR, |.

boop5 commented 7 years ago

@shadowfacts @way2muchnoise @mezz

Anchors are def missing imo ^chest$

Lets say I'm searching this item I can't remember the name of. I just know it was chest something. Since there are tons of items which include chest I want to exclude all items which do not start with chest.

^chest

The are those upgrade items which are called Machine Upgrade X Tier where X is a wildcard. I know the wildcard happens to be only letters. Since there are tons of upgrade items in any kitchensink pack I want to only find them above described upgrades

^machine upgrade [a-z]+ tier$

I'm looking for the best tinkers materials. I want to build a sword. I know the highest damage is 2 digit So I'm going to pin those 5 items or of 100 down with

max Damage\: [0,9]{2}

When I'm building towards a larger goal I tend to list all the needed items separated by |

So I want to pin down one exact item. Often only possible in combination with the item id.

For example in exu2 there are often duplicates. There is the machine SAG mill and the deco block with the exact same name. Only possible to pin down through the ID.

I'm actually totally new to a anything beyond 1.7.10 - does minecraft still used id's at all? I think I've read something about removing id's in the future. Could be totally wrong tho

On mobile. Excuse any formatting errors. Examples may not be accurate since I don't have access to a minecraft instance right now.

shadowfacts commented 7 years ago

JEI doesn't match spaces, in JEI spaces function like an and operator. So searching for "machine upgrade tier" will match the upgrades you're looking for.

Minecraft still uses numerical IDs internally, but modders and end users don't care about those. Instead everything uses a registry name which is a combination of the domain (minecraft for vanilla, or the mod id) and the name.

boop5 commented 7 years ago

JEI doesn't match spaces, in JEI spaces function like an and operator. So searching for "machine upgrade tier" will match the upgrades you're looking for.

Well that's not what I want to do. But I understand.

Minecraft still uses numerical IDs internally, but modders and end users don't care about those

I did not care about them per se but they were pretty helpful.

cleverca22 commented 7 years ago

something i have thought of before, is a way to bookmark certain items, so i can get the same effect as searching for "item1|item2|item3" but i wont loose the entire thing if i right click the search box, or if RS winds up in auto-JEI mode and eats the entire search query

this way, i can pin the stuff i want to craft, and the missing components, and not loose them to a single misclick or badly behaving block

boop5 commented 7 years ago

Just another pro for RegEx / ID's

How am I going to only display redstone? I mean just the dust. nothing else. I don't understand how this is supposed to work w/o RegEx or at least ID's

Okay I could combine it with the mod, @minecraft in this case. But that's still not really helpful

SoniEx2 commented 7 years ago

Y'all do realize minecraft:redstone is just as much of an ID as 331 right?

mezz commented 7 years ago

There are a few upcoming features that mitigate most of the problems brought up here.

  1. an Item "history" which shows what you've looked up recently, including pinning
  2. using quotes for search terms that include spaces
boop5 commented 7 years ago

I just want to see Electrical Furnace - none of the other:

Electrical Furnace
Electrical Furnace Tier 2
Electrical Furnace Tier 3
Electrical Furnace Tier 4
Electrical Furnace Tier 5

How am I going to do this? I have to pin it? Sounds complicated.

mezz commented 7 years ago

Please use your very advanced human eyes to choose from the small remaining list. This is a gui tool, you're not piping it into a dumb program upstream.

boop5 commented 7 years ago

Well the example was simple. There are way worse examples.
I mean I get it that you don't like the feature. Just tried to communicate that for me it's very stressful.

SoniEx2 commented 7 years ago

you're not piping it into a dumb program upstream.

Are you sure? I'm pretty sure the API lets me get the search results...

(This is a bad joke. Please don't thumbs up.)

mezz commented 7 years ago

Well the example was simple. There are way worse examples. I mean I get it that you don't like the feature. Just tried to communicate that for me it's very stressful.

I'm sorry it's very stressful, but I believe I have given many reasons for why I will not support regex. What's stressful to me and the vast majority of players is very slow searches in big packs.

Are you sure? I'm pretty sure the API lets me get the search results...

Yeah, for conveniently using it to display items to the player in a GUI in a way that exactly matches JEI. If you need something different from JEI, you can a search bar to your mod's GUI with your own behavior.

KnightMiner commented 7 years ago

It seems to me the main reason people here still want regex is the start and end line matching. Would that be expensive by itself without the rest of regex, maybe even if only used within exact matches?

mezz commented 7 years ago

If I add start and end line matching, it would be broken by anything with ^ or $ in the name (requiring escaping), and I would have to change the existing prefix for $ (OreDict name) and ^ (colors).

The benefit to me seems minor, and it will only be used by a very tiny group of players, so I do not think the compromises required for implementing it are justified.

SoniEx2 commented 7 years ago

Use [[ and ]] instead of ^ and $.

mezz commented 7 years ago

That may work. It seems obscure enough that the only people who would use it are here in this issue though.

ShaunDreclin commented 7 years ago

Just adding my voice to the crowd, regex is something I'm missing from NEI. If you're that worried about performance, make it an opt-in feature.

SoniEx2 commented 7 years ago

Add it to options.txt to make sure it doesn't get set by modpack authors.

dzaima commented 7 years ago

The use for regex I had was doing something like +\d\d attack damage or searching for ME drives with at least 15k bytes used ([12345]\d\d\d of). Make it optional and everyone will benefit.

SoniEx2 commented 7 years ago

Append user UUID to config setting ID to make it impossible to enable by default.

lrwerewolf commented 7 years ago

Just wanted to add my voice as well in favor of regex. My use case is for finding values where I don't actually know what item I'm searching for. As a specific example, I enjoy modpacks that include ProjectE. I find it useful to be able to use various ranges to track down items with specific EMC values. For example, if I'm looking for an item with maximum EMC, I might do something like "EMC: [1-9][0-9]{2},[0-9]{3},[0-9]{3}" which will show me anything from 100,000,000 EMC to 999,999,999 EMC. This is along the lines of dzaima's comment on Mar 5 where that user wished to look for things with double-digit attack damage or storage items holding a certain amount of stuff.

boop5 commented 7 years ago

searching for

tin pickaxe head

I expect one item as result

what do I get? all the TINkers construct pickaxe heads. another reason for regex.

KnightMiner commented 7 years ago

That's not a reason for regex, that's a reason for whitespace matching.

lrwerewolf commented 7 years ago

Gotta side with KnightMiner on that one, babbelnedd. If you know exactly what you're looking for, you don't need regex. The only time you need regex is when you need to select potentially more than one string. Your use-case could be solved by recognizing double quotes as markers for capturing white space.

mezz commented 7 years ago

JEI can use quotes for capturing white space, "tin pickaxe head". By default, searching mod names require the @ prefix. If you are finding Tinker's items with the search, you may have changed your search config settings so it doesn't require the prefix.

boop5 commented 7 years ago

I haven't changed anything - playing on ATM 3 1.12. Maybe they did?

On Sun, Oct 15, 2017 at 3:56 AM, mezz notifications@github.com wrote:

JEI can use quotes for capturing white space, "tin pickaxe head". By default, searching mod names require the @ prefix. If you are finding Tinker's items with the search, you may have changed your search config settings so it doesn't require the prefix.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mezz/JustEnoughItems/issues/63#issuecomment-336680338, or mute the thread https://github.com/notifications/unsubscribe-auth/AEcJanj_pFlou2IgqUwIS-EYvmZf0POYks5ssWY7gaJpZM4G0x6M .

DaComputerNerd717 commented 7 years ago

I wanted to put in a thought I had on the subject. I think regex should be allowed for the purpose of history. This also is a feature suggestion for that history system: If a history item lists only one item, clicking it will show recipes and uses, just like clicking the item in JEI. This is both useful for crafting, so you don't have to look through a list more than once, and it's actually a good purpose for regex since many terms are used in many items (just toggle F3+H and search for block or for item and you will see what I mean)

OrdinatorStouff commented 7 years ago

Just FYI-- Yes, in ATM3 configs every search option is set to "enabled" by default except for "color."

These of course are free to be changed by end-users who prefer a less inclusive list of results. With these pack defaults, "tin" search alone has about 8 pages of results.