-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#3110 Provide search transformers in the API
- Loading branch information
Showing
17 changed files
with
206 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
CommonApi/src/main/java/mezz/jei/api/registration/ISearchRegistration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package mezz.jei.api.registration; | ||
|
||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.helpers.IJeiHelpers; | ||
import mezz.jei.api.search.ILanguageTransformer; | ||
|
||
/** | ||
* The {@link ISearchRegistration} instance is passed to your mod plugin in {@link IModPlugin#registerSearch(ISearchRegistration)}. | ||
* | ||
* @since 12.2.0 | ||
*/ | ||
public interface ISearchRegistration { | ||
/** | ||
* {@link IJeiHelpers} provides helpers and tools for addon mods. | ||
* | ||
* @since 12.2.0 | ||
*/ | ||
IJeiHelpers getJeiHelpers(); | ||
|
||
/** | ||
* Register your own {@link ILanguageTransformer} here. | ||
* | ||
* @since 12.2.0 | ||
*/ | ||
void addLanguageTransformer(ILanguageTransformer languageTransformer); | ||
} |
31 changes: 31 additions & 0 deletions
31
CommonApi/src/main/java/mezz/jei/api/search/ILanguageTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package mezz.jei.api.search; | ||
|
||
import net.minecraft.resources.ResourceLocation; | ||
|
||
/** | ||
* A language transformer lets you change string tokens that are added to the search tree. | ||
* | ||
* This is useful for some languages where there may be multiple ways | ||
* to type the same thing, and the transformer can change the text. | ||
* For example, "nihao" can be transformed to match "你好". | ||
* | ||
* @since 12.2.0 | ||
*/ | ||
public interface ILanguageTransformer { | ||
/** | ||
* Get the unique ID for this language transformer. | ||
*/ | ||
ResourceLocation getId(); | ||
|
||
/** | ||
* Change the token into something else. | ||
* | ||
* This is called before inserting any ingredients into the search tree, | ||
* and also for looking up ingredients in the search tree. | ||
* | ||
* In order to work, this must always be consistent. | ||
* For an input string, it must always return the same output | ||
* string every time it is called. | ||
*/ | ||
String transformToken(String token); | ||
} |
7 changes: 7 additions & 0 deletions
7
CommonApi/src/main/java/mezz/jei/api/search/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package mezz.jei.api.search; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.