├── .gitignore ├── LICENSE ├── README.md ├── build.gradle ├── generate.py ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main ├── java └── me │ └── towdium │ └── jecharacters │ ├── JechCommand.java │ ├── JechConfig.java │ ├── JustEnoughCharacters.java │ └── utils │ ├── Greetings.java │ ├── Match.java │ └── Profiler.java └── resources ├── META-INF └── mods.toml ├── assets └── jecharacters │ └── lang │ ├── en_us.json │ ├── zh_cn.json │ └── zh_tw.json ├── me └── towdium │ └── jecharacters │ └── scripts │ ├── _lib.js │ ├── jei1.js │ ├── jei2.js │ ├── jei3.js │ └── psi.js └── pack.mcmeta /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | .vscode 24 | 25 | # generated 26 | src/main/resources/me/towdium/jecharacters/scripts/_gen* 27 | src/main/resources/META-INF/coremods.json -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Juntong Liu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![][2]][1] 2 | [![][3]][1] 3 | [![][4]][5] 4 | 5 | # JustEnoughCharacters 6 | 7 | ## 作用 8 | 9 | 使用这个模组,你可以在市面上绝大部分模组中使用拼音搜索。这包括了各类模组的手册,物流模组的容器,还有各种稀奇古怪的场景。简体和繁体都可以使用。你可以使用原文,全拼,声母的各种组合进行搜索,你可以使用声调或者忽略声调,任何你能想到的组合都可以使用。模组默认使用全拼拼法,也可以通过修改配置切换到注音或者双拼。当然,双拼场景下字形辅助码是不能用的,但是你可以像其他拼法一样使用声调来过滤。任何不支持的模组搜索都欢迎到 issue 区提给我。 10 | 11 | 尽管有一些个人实现的代码库已经在当前版本支持 config GUI 了,Forge 在当前版本仍然没有官方支持,因此本模组目前也不开放图形化配置。你可以修改配置文件或者使用 `/jech` 命令来配置。 12 | 13 | > 一个意外的好处是,和 JEI 一同使用时,JEI 的内存占用可能会缩减 100M 左右。 14 | 15 | ## 原理 16 | 17 | 由于核心匹配逻辑已经分离到 [PinIn][9] 这个项目了,本模组当前版本的工作原理极为简单。我们只需要将各模组文本匹配相关的代码找到,然后替换成兼容拼音的实现即可。我们将相关的调用位置填写在 [generate.py][10] 里,然后基于 Forge 现版本的 coremod 机制,使用脚本直接生成所需的 coremod,编译时打入模组包中即可。当然,有一些模组需要特别的兼容处理,这一部分内容你可以在 [这里][11] 找到。 18 | 19 | 至于 Fabric,我实在没有时间研究如何进行开发了,但是基于 PinIn 的基础上进行开发的话,根据经验来看仍然会是一个小于 1k 行的小项目,这方面欢迎其他人接坑。本项目和 PinIn 的核心匹配逻辑,在肉眼可见的将来我还是会保持维护的,这方面不必担心。 20 | 21 | ## 开发 22 | 23 | 尽管直到目前该项目的贡献者屈指可数,给该项目贡献代码仍然是十分简单的。如果你发现有某个模组不支持拼音搜索,你只需要执行 `/jech profile` 命令获得一份全量搜索报告,排查该模组相关的调用栈(需要亿点点技巧),然后提交上来即可。当然,如果能力有限,直接把模组名甩给我也是欢迎的。 24 | 25 | ## 致谢 26 | 27 | - 本模组更新到 1.16 的绝大部分工作是由 [yzl210][8] 完成的。 28 | - 本模组更新到 1.18 的绝大部分工作是由 [yzl210][8] 和 [vfyjxf][13] 完成的。 29 | - 本模组对于 1.16 的一吨 mod 的支持是由 [Death-123][12] 完成的。 30 | - 本模组的核心库 PinIn 中使用的拼音数据来自于 [地球拼音][6] 和 [pinyin-data][7]。 31 | 32 | [1]: https://minecraft.curseforge.com/projects/just-enough-characters 33 | [2]: http://cf.way2muchnoise.eu/full_250702_downloads.svg 34 | [3]: http://cf.way2muchnoise.eu/versions/250702.svg 35 | [4]: https://img.shields.io/discord/517485644163973120.svg?logo=discord 36 | [5]: https://discord.gg/M3fNfTW 37 | [6]: https://github.com/rime/rime-terra-pinyin 38 | [7]: https://github.com/mozillazg/pinyin-data 39 | [8]: https://github.com/yzl210 40 | [9]: https://github.com/Towdium/PinIn 41 | [10]: https://github.com/Towdium/JustEnoughCharacters/blob/1.16/generate.py 42 | [11]: https://github.com/Towdium/JustEnoughCharacters/tree/1.16/src/main/resources/me/towdium/jecharacters/scripts 43 | [12]: https://github.com/Death-123 44 | [13]: https://github.com/vfyjxf -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "dev.architectury.loom" version "1.1-SNAPSHOT" 3 | } 4 | 5 | version = "${mc_version}-${verspec}.${verbuild}" 6 | group = "me.towdium.jecharacters" 7 | archivesBaseName = "jecharacters" 8 | 9 | java.toolchain.languageVersion = JavaLanguageVersion.of(17) 10 | 11 | repositories { 12 | mavenCentral() 13 | maven { url = 'https://jitpack.io' } 14 | maven { url = "https://dvs1.progwml6.com/files/maven/" } 15 | maven { url = "https://maven.blamejared.com/" } 16 | maven { url = "https://modmaven.dev" } 17 | maven { url = 'https://maven.parchmentmc.org' } 18 | } 19 | 20 | configurations { 21 | shade 22 | implementation.extendsFrom shade 23 | } 24 | 25 | loom { 26 | silentMojangMappingsLicense() 27 | } 28 | 29 | 30 | dependencies { 31 | 32 | mappings loom.layered() { 33 | officialMojangMappings() 34 | parchment("org.parchmentmc.data:parchment-1.19.2:2022.11.27@zip") 35 | } 36 | 37 | minecraft "com.mojang:minecraft:${project.mc_version}" 38 | forge "net.minecraftforge:forge:${project.forge_version}" 39 | modImplementation 'mezz.jei:jei-1.18.2-forge:10.2.1.1002' 40 | implementation "com.github.towdium:PinIn:${verpinin}" 41 | forgeRuntimeLibrary "com.github.towdium:PinIn:${verpinin}" 42 | include(group: 'com.github.towdium', name: 'PinIn', version: "${verpinin}") { 43 | transitive = false 44 | } 45 | } 46 | 47 | test { 48 | useJUnitPlatform() 49 | } 50 | 51 | jar { 52 | manifest { 53 | attributes([ 54 | "Specification-Title" : 'Just Enough Characters', 55 | "Specification-Vendor" : 'Towdium', 56 | "Specification-Version" : "${verspec}", 57 | "Implementation-Title" : project.name, 58 | "Implementation-Version" : "${verspec}.${verbuild}", 59 | "Implementation-Vendor" : 'Towdium', 60 | "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") 61 | ]) 62 | } 63 | } 64 | 65 | tasks.withType(JavaCompile).configureEach { 66 | options.encoding = 'UTF-8' 67 | } 68 | 69 | task generate(type: Exec) { 70 | commandLine 'python', 'generate.py' 71 | } 72 | 73 | compileJava.dependsOn generate 74 | 75 | processResources { 76 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE 77 | inputs.property "version", project.version 78 | 79 | filesMatching("META-INF/mods.toml") { 80 | expand "version": project.version 81 | } 82 | } -------------------------------------------------------------------------------- /generate.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | manual = ['jei1', 'jei2', 'jei3', 'psi'] 4 | suffix = [ 5 | 'net.minecraft.client.searchtree.ReloadableIdSearchTree:m_7729_()V', # Vanilla 6 | 'net.minecraft.client.searchtree.ReloadableSearchTree:m_7729_()V', # Vanilla 7 | ] 8 | contains = [ 9 | 'com.blamejared.controlling.client.NewKeyBindsScreen:lambda$filterKeys$10(Lcom/blamejared/controlling/client/NewKeyBindsList$KeyEntry;)Z', # Controlling 10 | 'com.blamejared.controlling.client.NewKeyBindsScreen:lambda$filterKeys$8(Lcom/blamejared/controlling/client/NewKeyBindsList$KeyEntry;)Z', # Controlling 11 | 'com.blamejared.controlling.client.NewKeyBindsScreen:lambda$filterKeys$9(Lcom/blamejared/controlling/client/NewKeyBindsList$KeyEntry;)Z', # Controlling 12 | 'com.blamejared.controlling.client.gui.GuiNewControls:lambda$filterKeys$11(Lcom/blamejared/controlling/client/gui/GuiNewKeyBindingList$KeyEntry;)Z', # Controlling legacy 13 | 'com.blamejared.controlling.client.gui.GuiNewControls:lambda$filterKeys$10(Lcom/blamejared/controlling/client/gui/GuiNewKeyBindingList$KeyEntry;)Z', # Controlling legacy 14 | 'com.blamejared.controlling.client.gui.GuiNewControls:lambda$filterKeys$9(Lcom/blamejared/controlling/client/gui/GuiNewKeyBindingList$KeyEntry;)Z', # Controlling legacy 15 | 'com.refinedmods.refinedstorage.screen.grid.filtering.ModGridFilter:test(Lcom/refinedmods/refinedstorage/screen/grid/stack/IGridStack;)Z', # Refined Storage 16 | 'com.refinedmods.refinedstorage.screen.grid.filtering.NameGridFilter:test(Lcom/refinedmods/refinedstorage/screen/grid/stack/IGridStack;)Z', # Refined Storage 17 | 'com.refinedmods.refinedstorage.screen.grid.filtering.TagGridFilter:lambda$test$0(Ljava/lang/String;)Z', # Refined Storage 18 | 'com.refinedmods.refinedstorage.screen.grid.filtering.TooltipGridFilter:test(Lcom/refinedmods/refinedstorage/screen/grid/stack/IGridStack;)Z', # Refined Storage 19 | 'com.rwtema.extrautils2.transfernodes.TileIndexer$ContainerIndexer$WidgetItemRefButton:lambda$getRef$0([Ljava/lang/String;Lcom/rwtema/extrautils2/utils/datastructures/ItemRef;)Z', # Extra Utilities 20 | 'de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry:fitsFilter(Lde/ellpeck/actuallyadditions/api/booklet/IBookletPage;Ljava/lang/String;)Z', # Actually Additions 21 | 'de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntry:getChaptersForDisplay(Ljava/lang/String;)Ljava/util/List;', # Actually Additions 22 | 'appeng.client.gui.me.interfaceterminal.InterfaceTerminalScreen:refreshList()V', # Applied Energistics 23 | 'appeng.client.gui.me.interfaceterminal.InterfaceTerminalScreen:itemStackMatchesSearchTerm(Lnet/minecraft/world/item/ItemStack;Ljava/lang/String;)Z', # Applied Energistics 24 | 'me.towdium.jecalculation.utils.Utilities$I18n:contains(Ljava/lang/String;Ljava/lang/String;)Z', # Just Enough Calculation 25 | 'sonar.logistics.core.tiles.readers.fluids.GuiFluidReader:getGridList()Ljava/util/List;', # Practical Logistics 26 | 'sonar.logistics.core.tiles.readers.items.GuiInventoryReader:getGridList()Ljava/util/List;', # Practical Logistics 27 | 'sonar.logistics.core.items.wirelessstoragereader.GuiWirelessStorageReader:getGridList()Ljava/util/List;', # Practical Logistics 28 | 'sonar.logistics.core.items.guide.GuiGuide:updateSearchList()V', # Practical Logistics 29 | 'binnie.core.machines.storage.SearchDialog:updateSearch()V', # Binnie Core 30 | 'vazkii.patchouli.client.book.BookEntry:isFoundByQuery(Ljava/lang/String;)Z', # Patchouli (Botania) 31 | 'vazkii.botania.api.corporea.CorporeaRequestDefaultMatchers$CorporeaStringMatcher:equalOrContain(Ljava/lang/String;)Z', # Botania (Corporea) 32 | 'net.blay09.mods.cookingforblockheads.container.RecipeBookContainer:search(Ljava/lang/String;)V', # Cooking for Blockheads 33 | 'net.blay09.mods.farmingforblockheads.container.MarketClientContainer:applyFilters()V', # Farming for Blockheads 34 | 'mcjty.rftools.blocks.shaper.LocatorTileEntity:checkFilter(Ljava/lang/String;Lnet/minecraft/entity/Entity;)Z', # RF Tools 35 | 'mcjty.rftoolsstorage.modules.scanner.blocks.StorageScannerTileEntity:lambda$makeSearchPredicate$30(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # RF Tools 36 | 'mcjty.rftoolsstorage.modules.modularstorage.client.GuiModularStorage:lambda$updateList$6(Ljava/lang/String;Ljava/util/List;Ljava/util/concurrent/atomic/AtomicInteger;Lnet/minecraftforge/items/IItemHandler;)V', # RF Tools 37 | 'mcjty.rftools.items.netmonitor.GuiNetworkMonitor:populateList()V', # RF Tools 38 | 'moze_intel.projecte.gameObjs.container.inventory.TransmutationInventory:doesItemMatchFilter(Lmoze_intel/projecte/api/ItemInfo;)Z', # Project E 39 | 'org.cyclops.integrateddynamics.core.client.gui.WidgetTextFieldDropdown:refreshDropdownList()V', # Integrated Dynamics 40 | 'blusunrize.immersiveengineering.api.ManualPageBlueprint:listForSearch(Ljava/lang/String;)Z', # Immersive Engineering 41 | 'blusunrize.lib.manual.ManualPages$Crafting:listForSearch(Ljava/lang/String;)Z', # Immersive Engineering 42 | 'blusunrize.lib.manual.ManualPages$CraftingMulti:listForSearch(Ljava/lang/String;)Z', # Immersive Engineering 43 | 'blusunrize.lib.manual.ManualPages$ItemDisplay:listForSearch(Ljava/lang/String;)Z', # Immersive Engineering 44 | 'blusunrize.lib.manual.gui.GuiManual:func_73869_a(CI)V', # Immersive Engineering 45 | 'betterquesting.api2.client.gui.panels.lists.CanvasEntityDatabase:queryMatches(Lnet/minecraftforge/fml/common/registry/EntityEntry;Ljava/lang/String;Ljava/util/ArrayDeque;)V', # Better Questing 46 | 'betterquesting.api2.client.gui.panels.lists.CanvasFileDirectory:queryMatches(Ljava/io/File;Ljava/lang/String;Ljava/util/ArrayDeque;)V', # Better Questing 47 | 'betterquesting.api2.client.gui.panels.lists.CanvasFluidDatabase:queryMatches(Lnet/minecraftforge/fluids/Fluid;Ljava/lang/String;Ljava/util/ArrayDeque;)V', # Better Questing 48 | 'betterquesting.api2.client.gui.panels.lists.CanvasItemDatabase:queryMatches(Lnet/minecraft/item/Item;Ljava/lang/String;Ljava/util/ArrayDeque;)V', # Better Questing 49 | 'betterquesting.api2.client.gui.panels.lists.CanvasQuestDatabase:queryMatches(Lbetterquesting/api2/storage/DBEntry;Ljava/lang/String;Ljava/util/ArrayDeque;)V', # Better Questing 50 | 'com.mia.props.client.container.GuiDecobench:refreshButtons()V', # Decofraft workbench 51 | 'logisticspipes.gui.orderer.GuiOrderer:isSearched(Ljava/lang/String;Ljava/lang/String;)Z', # Logistics Pipes 52 | 'logisticspipes.gui.orderer.GuiRequestTable:isSearched(Ljava/lang/String;Ljava/lang/String;)Z', # Logistics Pipes 53 | 'com.lothrazar.storagenetwork.api.util.UtilInventory:doOverlap(Ljava/lang/String;Ljava/lang/String;)Z', # Simple Storage Network legacy 54 | 'com.lothrazar.storagenetwork.gui.NetworkWidget:doesStackMatchSearch(Lnet/minecraft/world/item/ItemStack;)Z', # Simple Storage Network 55 | 'com.latmod.mods.projectex.gui.GuiTableBase:updateValidItemList()V', # Project EX 56 | 'net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen:m_98630_()V', # Vanilla 57 | 'net.minecraft.client.gui.screens.inventory.CreativeModeInventoryScreen:m_98619_(Ljava/lang/String;)V', # Vanilla 58 | 'zuve.searchablechests.ChestEventHandler:stackMatches(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Searchable Chests 59 | 'mekanism.common.content.qio.SearchQueryParser$QueryType:lambda$null$5(Ljava/lang/String;Ljava/lang/String;)Z', # Mekanism (QIO) 60 | 'mekanism.common.content.qio.SearchQueryParser$QueryType:lambda$null$3(Ljava/lang/String;Ljava/lang/String;)Z', # Mekanism (QIO) 61 | 'mekanism.common.content.qio.SearchQueryParser$QueryType:lambda$static$1(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Mekanism (QIO) 62 | 'mekanism.common.content.qio.SearchQueryParser$QueryType:lambda$static$0(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Mekanism (QIO) 63 | 'hellfirepvp.astralsorcery.client.screen.journal.ScreenJournalPerkTree:updateSearchHighlight()V', #Astral Sorcery 64 | 'hellfirepvp.astralsorcery.client.screen.journal.ScreenJournalProgression:onSearchTextInput()V', #Astral Sorcery 65 | 'com.ma.guide.GuideBookEntries:lambda$null$4(Lnet/minecraft/client/Minecraft;Ljava/lang/String;Ljava/util/HashMap;Lcom/ma/guide/RelatedRecipe;)V', #Mana and Artifice 66 | 'com.ma.guide.GuideBookEntries:lambda$null$1(Ljava/lang/String;Lcom/ma/guide/interfaces/IEntrySection;)Z', #Mana and Artifice 67 | 'com.minecolonies.coremod.client.gui.WindowHutAllInventory:lambda$updateResources$1(Lcom/minecolonies/api/crafting/ItemStorage;)Z', #MineColonies 68 | 'com.minecolonies.coremod.client.gui.WindowPostBox:lambda$updateResources$0(Lnet/minecraft/world/item/ItemStack;)Z', #MineColonies 69 | 'com.minecolonies.coremod.client.gui.ItemListModuleWindow:lambda$updateResources$2(Lnet/minecraft/world/item/ItemStack;)Z', #MineColonies 70 | 'com.minecolonies.coremod.client.gui.WindowSelectRes:lambda$updateResources$0(Lnet/minecraft/world/item/ItemStack;)Z', #MineColonies 71 | 'com.minecolonies.coremod.client.gui.WindowPostBox:lambda$updateResources$1(Lnet/minecraft/world/item/ItemStack;)Z', # MineColonies 72 | 'com.minecolonies.coremod.client.gui.modules.ItemListModuleWindow:lambda$updateResources$3(Lnet/minecraft/world/item/ItemStack;)Z', # MineColonies 73 | 'com.minecolonies.coremod.client.gui.WindowSelectRes:updateResources()V', # MineColonies 74 | 'com.minecolonies.coremod.client.gui.modules.EntityListModuleWindow:lambda$updateResources$3(Lnet/minecraft/resources/ResourceLocation;)Z', # MineColonies 75 | 'com.minecolonies.coremod.client.gui.ViewFilterableList:lambda$updateResources$0(Lnet/minecraft/item/ItemStack;)Z', # MineColonies 76 | 'com.minecolonies.coremod.client.gui.WindowHutAllInventory:lambda$updateResources$2(Lcom/minecolonies/api/crafting/ItemStorage;)Z', #MineColonies since 1.18.2-1.0.1440-ALPHA 77 | 'com.minecolonies.coremod.client.gui.WindowPostBox:lambda$updateResources$1(Lnet/minecraft/world/item/ItemStack;)Z', #MineColonies since 1.18.2-1.0.1440-ALPHA 78 | 'com.minecolonies.coremod.client.gui.modules.EntityListModuleWindow:lambda$updateResources$3(Lnet/minecraft/resources/ResourceLocation;)Z', #MineColonies since 1.18.2-1.0.1440-ALPHA 79 | 'com.minecolonies.coremod.client.gui.modules.ItemListModuleWindow:lambda$updateResources$3(Lnet/minecraft/world/item/ItemStack;)Z', #MineColonies since 1.18.2-1.0.1440-ALPHA 80 | 'com.minecolonies.coremod.client.gui.WindowSelectRes:updateResources()V', #MineColonies since 1.18.2-1.0.1440-ALPHA 81 | 'com.chaosthedude.naturescompass.gui.NaturesCompassScreen:processSearchTerm()V', #Nature's Compass 82 | 'com.hollingsworth.arsnouveau.client.gui.book.GuiSpellBook:onSearchChanged(Ljava/lang/String;)V', #Ars Nouveau 83 | 'me.shedaniel.rei.impl.client.search.argument.type.TagArgumentType:matches(Lorg/apache/commons/lang3/mutable/Mutable;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI legacy 84 | 'me.shedaniel.rei.impl.client.search.argument.type.IdentifierArgumentType:matches(Lorg/apache/commons/lang3/mutable/Mutable;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI legacy 85 | 'me.shedaniel.rei.impl.client.search.argument.type.ModArgumentType:matches(Lorg/apache/commons/lang3/mutable/Mutable;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI legacy 86 | 'me.shedaniel.rei.impl.client.search.argument.type.TooltipArgumentType:matches(Lorg/apache/commons/lang3/mutable/Mutable;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI legacy 87 | 'me.shedaniel.rei.impl.client.search.argument.type.TextArgumentType:matches(Lorg/apache/commons/lang3/mutable/Mutable;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI legacy 88 | 'me.shedaniel.rei.impl.client.search.argument.type.IdentifierArgumentType:matches(Ljava/lang/String;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI 89 | 'me.shedaniel.rei.impl.client.search.argument.type.ModArgumentType:matches(Lme/shedaniel/rei/impl/client/search/argument/type/ModArgumentType$ModInfoPair;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI 90 | 'me.shedaniel.rei.impl.client.search.argument.type.TagArgumentType:matches([Ljava/lang/String;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI 91 | 'me.shedaniel.rei.impl.client.search.argument.type.TextArgumentType:matches(Ljava/lang/String;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI 92 | 'me.shedaniel.rei.impl.client.search.argument.type.TooltipArgumentType:matches(Ljava/lang/String;Lme/shedaniel/rei/api/common/entry/EntryStack;Ljava/lang/String;Lnet/minecraft/util/Unit;)Z', # REI 93 | 'vazkii.quark.client.module.ChestSearchingModule:namesMatch(Lnet/minecraft/world/item/ItemStack;Ljava/lang/String;)Z', # Quark legacy 94 | 'vazkii.quark.content.client.module.ChestSearchingModule:namesMatch(Lnet/minecraft/world/item/ItemStack;Ljava/lang/String;)Z', # Quark 95 | 'me.shedaniel.clothconfig2.forge.gui.entries.DropdownBoxEntry$DefaultDropdownMenuElement:search()V', # Cloth Config 96 | 'me.shedaniel.clothconfig2.gui.entries.DropdownBoxEntry$DefaultDropdownMenuElement:search()V', # Cloth Config 97 | 'mezz.jei.search.ElementSearchLowMem:matches(Ljava/lang/String;Lmezz/jei/core/search/PrefixInfo;Lmezz/jei/ingredients/IListElementInfo;)Z', # JEI (low memory) 98 | 'mezz.jei.gui.search.ElementSearchLowMem:matches(Ljava/lang/String;Lmezz/jei/core/search/PrefixInfo;Lmezz/jei/gui/ingredients/IListElementInfo;)Z', # JEI (low memory) since 11.6.0.1016 99 | 'mezz.jei.common.search.ElementSearchLowMem:matches(Ljava/lang/String;Lmezz/jei/core/search/PrefixInfo;Lmezz/jei/common/ingredients/IListElementInfo;)Z', # JEI (low memory) since 10.2.1.1005 100 | 'com.github.klikli_dev.occultism.client.gui.storage.StorageControllerGuiBase:itemMatchesSearch(Lnet/minecraft/world/item/ItemStack;)Z', # Occultism 101 | 'com.github.klikli_dev.occultism.client.gui.storage.StorageControllerGuiBase:machineMatchesSearch(Lcom/github/klikli_dev/occultism/api/common/data/MachineReference;)Z', # Occultism, 102 | 'pro.mikey.xray.gui.GuiSelectionScreen:lambda$updateSearch$7(Lpro/mikey/xray/utils/BlockData;)Z', #Advanced XRay Gui 103 | 'pro.mikey.xray.gui.manage.GuiBlockList:lambda$reloadBlocks$1(Lpro/mikey/xray/store/GameBlockStore$BlockWithItemStack;)Z', #Advanced XRay Gui 104 | 'me.desht.pneumaticcraft.api.crafting.recipe.AmadronRecipe:passesQuery(Ljava/lang/String;)Z', # PneumaticCraft Amadron 105 | 'me.desht.pneumaticcraft.client.gui.ItemSearcherScreen$SearchEntry:test(Ljava/lang/String;)Z', # PneumaticCraft Item Search Upgrade 106 | 'de.ellpeck.prettypipes.terminal.containers.ItemTerminalGui:lambda$updateWidgets$8(Ljava/lang/String;Lorg/apache/commons/lang3/tuple/Pair;)Z', # Pretty Pipes Terminal 107 | 'dev.ftb.mods.ftblibrary.config.ui.SelectItemStackScreen$ItemStackButton:shouldAdd(Ljava/lang/String;Ljava/lang/String;)Z', # FTB Library(FTB Quests) 108 | 'dev.ftb.mods.ftblibrary.ui.misc.ButtonListBaseScreen$1:add(Ldev/ftb/mods/ftblibrary/ui/Widget;)V' # FTB Library(FTB Quests) 109 | 'me.shedaniel.rei.impl.client.search.method.DefaultInputMethod:contains(Ljava/lang/String;Ljava/lang/String;)Z', #REI default since 8.3.618 110 | 'com.github.einjerjar.mc.keymap.client.gui.widgets.KeymapListWidget:lambda$updateFilteredList$1(Lcom/github/einjerjar/mc/keymap/client/gui/widgets/KeymapListWidget$KeymapListEntry;Ljava/lang/String;)Z', #Keymap since 0.8.0-beta.1 111 | 'appeng.client.gui.me.interfaceterminal.InterfaceTerminalScreen:itemStackMatchesSearchTerm(Lnet/minecraft/world/item/ItemStack;Ljava/lang/String;)Z', #Applied Energistics 2 since 11.7.4 112 | 'appeng.client.gui.me.interfaceterminal.InterfaceTerminalScreen:refreshList()V', # Applied Energistics 2 since 11.7.4 113 | ] 114 | equals = [ 115 | 'vazkii.botania.api.corporea.CorporeaRequestDefaultMatchers$CorporeaStringMatcher:equalOrContain(Ljava/lang/String;)Z', # Botania (Corporea) 116 | 'vazkii.quark.client.module.ChestSearchingModule:namesMatch(Lnet/minecraft/world/item/ItemStack;Ljava/lang/String;)Z', # Quark legacy 117 | 'vazkii.quark.content.client.module.ChestSearchingModule:namesMatch(Lnet/minecraft/world/item/ItemStack;Ljava/lang/String;)Z', # Quark 118 | 'org.cyclops.integrateddynamics.core.client.gui.WidgetTextFieldDropdown:lambda$refreshDropdownList$0(Lorg/cyclops/integrateddynamics/core/client/gui/IDropdownEntry;)Z', # Integrated Dynamics 119 | ] 120 | regExp = [ 121 | 'appeng.client.gui.me.fluids.FluidRepo:matchesSearch(Lappeng/client/gui/me/common/Repo$SearchMode;Ljava/util/regex/Pattern;Lappeng/api/storage/data/IAEFluidStack;)Z', # Applied Energistics 122 | 'appeng.client.gui.me.items.ItemRepo:matchesSearch(Lappeng/client/gui/me/common/Repo$SearchMode;Ljava/util/regex/Pattern;Lappeng/api/storage/data/IAEItemStack;)Z', # Applied Energistics 123 | 'org.cyclops.integrateddynamics.inventory.container.ContainerLogicProgrammerBase:lambda$static$0(Lorg/cyclops/integrateddynamics/api/logicprogrammer/ILogicProgrammerElement;Ljava/util/regex/Pattern;)Z', # Integrated Dynamics 1 124 | 'org.cyclops.integrateddynamics.core.inventory.container.ContainerMultipartAspects:lambda$new$0(Lorg/cyclops/integrateddynamics/api/part/aspect/IAspect;Ljava/util/regex/Pattern;)Z', # Integrated Dynamics 2 125 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$getInstanceFilterPredicate$13(Ljava/lang/String;Lnet/minecraftforge/fluids/FluidStack;)Z', # Integrated Terminals legacy 126 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$null$10(Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;)Z', # Integrated Terminals legacy 127 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$7(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Integrated Terminals legacy 128 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$null$2(Ljava/lang/String;Lnet/minecraft/util/text/ITextComponent;)Z', # Integrated Terminals legacy 129 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$null$4(Ljava/lang/String;Lnet/minecraft/util/ResourceLocation;)Z', # Integrated Terminals legacy 130 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$getInstanceFilterPredicate$10(Ljava/lang/String;Lnet/minecraft/tags/TagKey;)Z', # Integrated Terminals 131 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$getInstanceFilterPredicate$14(Ljava/lang/String;Lnet/minecraftforge/fluids/FluidStack;)Z', # Integrated Terminals 132 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$getInstanceFilterPredicate$8(Ljava/lang/String;Lnet/minecraftforge/fluids/FluidStack;)Z', # Integrated Terminals 133 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$1(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Integrated Terminals 134 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$2(Ljava/lang/String;Lnet/minecraft/network/chat/Component;)Z', # Integrated Terminals 135 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$4(Ljava/lang/String;Lnet/minecraft/tags/TagKey;)Z', # Integrated Terminals 136 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$8(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Integrated Terminals 137 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$getInstanceFilterPredicate$10(Ljava/lang/String;Lnet/minecraft/tags/TagKey;)Z', # Integrated Terminals since 1.4.7 138 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$getInstanceFilterPredicate$14(Ljava/lang/String;Lnet/minecraftforge/fluids/FluidStack;)Z', # Integrated Terminals since 1.4.7 139 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerFluidStack:lambda$getInstanceFilterPredicate$8(Ljava/lang/String;Lnet/minecraftforge/fluids/FluidStack;)Z', # Integrated Terminals since 1.4.7 140 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$1(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Integrated Terminals since 1.4.7 141 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$2(Ljava/lang/String;Lnet/minecraft/network/chat/Component;)Z', # Integrated Terminals since 1.4.7 142 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$4(Ljava/lang/String;Lnet/minecraft/tags/TagKey;)Z', # Integrated Terminals since 1.4.7 143 | 'org.cyclops.integratedterminals.capability.ingredient.IngredientComponentTerminalStorageHandlerItemStack:lambda$getInstanceFilterPredicate$8(Ljava/lang/String;Lnet/minecraft/world/item/ItemStack;)Z', # Integrated Terminals since 1.4.7 144 | 'com.tom.storagemod.gui.GuiStorageTerminalBase:updateSearch()V', # Toms Storage 145 | 'appeng.client.gui.me.search.SearchPredicates:lambda$createNamePredicate$2(Ljava/util/regex/Pattern;Lappeng/menu/me/common/GridInventoryEntry;)Z', #new Applied Energistics Terminals 146 | 'appeng.client.gui.me.search.SearchPredicates:lambda$createTooltipPredicate$3(Lappeng/client/gui/me/search/RepoSearch;Ljava/util/regex/Pattern;Lappeng/menu/me/common/GridInventoryEntry;)Z', #new Applied Energistics Terminals 147 | 'appeng.client.gui.me.search.SearchPredicates:lambda$createNamePredicate$3(Ljava/util/regex/Pattern;Lappeng/menu/me/common/GridInventoryEntry;)Z', # Applied Energistics Terminals since 11.7.4 148 | 'appeng.client.gui.me.search.SearchPredicates:lambda$createTooltipPredicate$4(Lappeng/client/gui/me/search/RepoSearch;Ljava/util/regex/Pattern;Lappeng/menu/me/common/GridInventoryEntry;)Z', # Applied Energistics Terminals since 11.7.4 149 | ] 150 | 151 | pattern = """// Generated 152 | function initializeCoreMod() {{ 153 | Java.type('net.minecraftforge.coremod.api.ASMAPI').loadFile('me/towdium/jecharacters/scripts/_lib.js'); 154 | return {{ 155 | 'jecharacters-gen{idx}': {{ 156 | 'target': {{ 157 | 'type': 'METHOD', 158 | 'class': '{clazz}', 159 | 'methodName': Api.mapMethod('{name}'), 160 | 'methodDesc': '{desc}' 161 | }}, 162 | 'transformer': trans{op} 163 | }} 164 | }} 165 | }} 166 | """ 167 | 168 | 169 | def decode(s): 170 | idx1 = s.index(':') 171 | idx2 = s.index('(') 172 | return { 173 | 'clazz': s[:idx1], 174 | 'name': s[idx1 + 1: idx2], 175 | 'desc': s[idx2:] 176 | } 177 | 178 | 179 | if __name__ == '__main__': 180 | total = 0 181 | file = 'src/main/resources/me/towdium/jecharacters/scripts/_gen{}.js' 182 | path = 'src/main/resources/me/towdium/jecharacters/scripts/' 183 | for i in os.listdir(path): 184 | if i.startswith('_gen'): 185 | os.remove(path + i) 186 | 187 | for i in ['contains', 'suffix', 'regExp', 'equals']: 188 | for j in globals()[i]: 189 | print(j) 190 | s = pattern.format(idx=total, **decode(j), op=i[0].capitalize() + i[1:]) 191 | with open(file.format(total), 'w') as f: 192 | f.write(s) 193 | total += 1 194 | 195 | json = '{' 196 | for i in manual: 197 | json += '\n "jecharacters-{0}": "me/towdium/jecharacters/scripts/{0}.js",'.format(i) 198 | for i in range(total): 199 | json += '\n "jecharacters-gen{0}": "me/towdium/jecharacters/scripts/_gen{0}.js",'.format(i) 200 | json = json[:-1] + '\n}\n' 201 | with open('src/main/resources/META-INF/coremods.json', 'w') as f: 202 | f.write(json) 203 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Sets default memory used for gradle commands. Can be overridden by user or command line properties. 2 | # This is required to provide enough memory for the Minecraft decompilation process. 3 | org.gradle.jvmargs=-Xmx3G 4 | org.gradle.daemon=false 5 | verspec=4.3 6 | verbuild=12 7 | verpinin=1.6.0 8 | mc_version=1.18.2 9 | forge_version=1.18.2-40.1.0 10 | loom.platform=forge -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Towdium/JustEnoughCharacters/36a9d7f72c492e7b322c551d666d7336188a4e11/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright � 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions �$var�, �${var}�, �${var:-default}�, �${var+SET}�, 36 | # �${var#prefix}�, �${var%suffix}�, and �$( cmd )�; 37 | # * compound commands having a testable exit status, especially �case�; 38 | # * various built-in commands including �command�, �set�, and �ulimit�. 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { url "https://maven.fabricmc.net/" } 4 | maven { url "https://maven.architectury.dev/" } 5 | maven { url "https://files.minecraftforge.net/maven/" } 6 | gradlePluginPortal() 7 | } 8 | } -------------------------------------------------------------------------------- /src/main/java/me/towdium/jecharacters/JechCommand.java: -------------------------------------------------------------------------------- 1 | package me.towdium.jecharacters; 2 | 3 | import com.google.gson.GsonBuilder; 4 | import com.mojang.brigadier.CommandDispatcher; 5 | import com.mojang.brigadier.ParseResults; 6 | import com.mojang.brigadier.StringReader; 7 | import com.mojang.brigadier.builder.LiteralArgumentBuilder; 8 | import com.mojang.brigadier.exceptions.CommandSyntaxException; 9 | import com.mojang.brigadier.tree.RootCommandNode; 10 | import me.towdium.jecharacters.JechConfig.Spell; 11 | import me.towdium.jecharacters.utils.Match; 12 | import me.towdium.jecharacters.utils.Profiler; 13 | import net.minecraft.client.Minecraft; 14 | import net.minecraft.client.gui.screens.ChatScreen; 15 | import net.minecraft.client.player.LocalPlayer; 16 | import net.minecraft.commands.CommandSourceStack; 17 | import net.minecraft.commands.SharedSuggestionProvider; 18 | import net.minecraft.network.chat.*; 19 | import net.minecraftforge.api.distmarker.Dist; 20 | import net.minecraftforge.client.event.ClientChatEvent; 21 | import net.minecraftforge.client.event.ScreenEvent; 22 | import net.minecraftforge.eventbus.api.SubscribeEvent; 23 | import net.minecraftforge.fml.common.Mod; 24 | 25 | import java.io.FileOutputStream; 26 | import java.io.IOException; 27 | import java.io.OutputStreamWriter; 28 | import java.util.Objects; 29 | 30 | import static me.towdium.jecharacters.JustEnoughCharacters.printMessage; 31 | import static net.minecraft.ChatFormatting.*; 32 | import static net.minecraft.network.chat.ClickEvent.Action.SUGGEST_COMMAND; 33 | 34 | 35 | @Mod.EventBusSubscriber({Dist.CLIENT}) 36 | public class JechCommand { 37 | static CommandDispatcher dispatcher; 38 | static LiteralArgumentBuilder builder; 39 | 40 | static { 41 | builder = literal("jech") 42 | .executes((c) -> { 43 | printMessage(new TranslatableComponent("jecharacters.chat.help")); 44 | return 0; 45 | }).then(literal("profile").executes(c -> profile())) 46 | .then(literal("verbose") 47 | .then(literal("true").executes(c -> { 48 | JechConfig.enableVerbose.set(true); 49 | return 0; 50 | })).then(literal("false").executes(c -> { 51 | JechConfig.enableVerbose.set(false); 52 | return 0; 53 | })) 54 | ).then(literal("silent")).executes(c -> { 55 | JechConfig.enableChat.set(false); 56 | return 0; 57 | }).then(literal("keyboard") 58 | .then(literal("quanpin").executes(c -> setKeyboard(Spell.QUANPIN))) 59 | .then(literal("daqian").executes(c -> setKeyboard(Spell.DAQIAN))) 60 | .then(literal("xiaohe").executes(c -> setKeyboard(Spell.XIAOHE))) 61 | .then(literal("ziranma").executes(c -> setKeyboard(Spell.ZIRANMA))) 62 | .then(literal("sougou").executes(c -> setKeyboard(Spell.SOUGOU))) 63 | .then(literal("guobiao").executes(c -> setKeyboard(Spell.GUOBIAO))) 64 | .then(literal("microsoft").executes(c -> setKeyboard(Spell.MICROSOFT))) 65 | .then(literal("pinyinjiajia").executes(c -> setKeyboard(Spell.PINYINPP))) 66 | .then(literal("ziguang").executes(c -> setKeyboard(Spell.ZIGUANG)))); 67 | dispatcher = new CommandDispatcher<>(); 68 | dispatcher.register(builder); 69 | } 70 | 71 | private static LiteralArgumentBuilder literal(String s) { 72 | return LiteralArgumentBuilder.literal(s); 73 | } 74 | 75 | private static int setKeyboard(Spell keyboard) { 76 | JechConfig.enumKeyboard.set(keyboard); 77 | JechConfig.enableQuote.set(false); 78 | Match.onConfigChange(); 79 | return 0; 80 | } 81 | 82 | private static int profile() { 83 | Thread t = new Thread(() -> { 84 | printMessage(new TranslatableComponent("jecharacters.chat.start")); 85 | Profiler.Report r = Profiler.run(); 86 | try (FileOutputStream fos = new FileOutputStream("logs/jecharacters.txt")) { 87 | OutputStreamWriter osw = new OutputStreamWriter(fos); 88 | osw.write(new GsonBuilder().setPrettyPrinting().create().toJson(r)); 89 | osw.flush(); 90 | printMessage(new TranslatableComponent("jecharacters.chat.saved")); 91 | } catch (IOException e) { 92 | printMessage(new TranslatableComponent("jecharacters.chat.error")); 93 | } 94 | }); 95 | t.setPriority(Thread.MIN_PRIORITY); 96 | t.start(); 97 | return 0; 98 | } 99 | 100 | @SubscribeEvent 101 | public static void onOpenGui(ScreenEvent.InitScreenEvent event) { 102 | if (event.getScreen() instanceof ChatScreen) { 103 | RootCommandNode root = getPlayer().connection.getCommands().getRoot(); 104 | if (root.getChild("jech") == null) root.addChild(builder.build()); 105 | } 106 | } 107 | 108 | @SubscribeEvent 109 | public static void onCommand(ClientChatEvent event) { 110 | CommandSourceStack cs = getPlayer().createCommandSourceStack(); 111 | String msg = event.getMessage(); 112 | if (msg.startsWith("/jech ") || msg.equals("/jech")) { 113 | event.setCanceled(true); 114 | Minecraft.getInstance().gui.getChat().addRecentChat(msg); 115 | 116 | try { 117 | StringReader stringreader = new StringReader(msg); 118 | if (stringreader.canRead() && stringreader.peek() == '/') stringreader.skip(); 119 | ParseResults parse = dispatcher.parse(stringreader, cs); 120 | dispatcher.execute(parse); 121 | } catch (CommandSyntaxException e) { 122 | // copied and modified from net.minecraft.command.Commands 123 | cs.sendFailure(ComponentUtils.fromMessage(e.getRawMessage())); 124 | if (e.getInput() != null && e.getCursor() >= 0) { 125 | int k = Math.min(e.getInput().length(), e.getCursor()); 126 | TextComponent tc1 = new TextComponent(""); 127 | tc1.withStyle(GRAY).withStyle(i -> 128 | i.withClickEvent(new ClickEvent(SUGGEST_COMMAND, event.getMessage()))); 129 | if (k > 10) tc1.append("..."); 130 | tc1.append(e.getInput().substring(Math.max(0, k - 10), k)); 131 | if (k < e.getInput().length()) { 132 | Component tc2 = (new TextComponent(e.getInput().substring(k))) 133 | .withStyle(RED, UNDERLINE); 134 | tc1.getSiblings().add(tc2); 135 | } 136 | tc1.getSiblings().add((new TranslatableComponent("command.context.here")) 137 | .withStyle(RED, ITALIC)); 138 | cs.sendFailure(tc1); 139 | } 140 | } 141 | } 142 | } 143 | 144 | @SuppressWarnings("resource") 145 | private static LocalPlayer getPlayer() { 146 | return Objects.requireNonNull(Minecraft.getInstance().player); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/me/towdium/jecharacters/JechConfig.java: -------------------------------------------------------------------------------- 1 | package me.towdium.jecharacters; 2 | 3 | import me.towdium.pinin.Keyboard; 4 | import net.minecraftforge.common.ForgeConfigSpec; 5 | import net.minecraftforge.common.ForgeConfigSpec.BooleanValue; 6 | import net.minecraftforge.common.ForgeConfigSpec.ConfigValue; 7 | import net.minecraftforge.common.ForgeConfigSpec.EnumValue; 8 | import net.minecraftforge.fml.ModLoadingContext; 9 | import net.minecraftforge.fml.loading.FMLPaths; 10 | 11 | import java.util.Collections; 12 | import java.util.List; 13 | import java.util.function.Predicate; 14 | 15 | import static net.minecraftforge.fml.config.ModConfig.Type.COMMON; 16 | 17 | public class JechConfig { 18 | public static final String PATH = "jecharacters.toml"; 19 | public static ForgeConfigSpec common; 20 | 21 | public static BooleanValue enableQuote; 22 | 23 | public static EnumValue enumKeyboard; 24 | public static BooleanValue enableFZh2z; 25 | public static BooleanValue enableFSh2s; 26 | public static BooleanValue enableFCh2c; 27 | public static BooleanValue enableFAng2an; 28 | public static BooleanValue enableFIng2in; 29 | public static BooleanValue enableFEng2en; 30 | public static BooleanValue enableFU2v; 31 | 32 | public static ConfigValue> listDumpClass; 33 | public static BooleanValue enableVerbose; 34 | public static BooleanValue enableChat; 35 | 36 | static { 37 | Predicate p = i -> i instanceof String; 38 | ForgeConfigSpec.Builder b = new ForgeConfigSpec.Builder(); 39 | b.push("General"); 40 | b.comment("Keyboard for the checker to use"); 41 | enumKeyboard = b.defineEnum("enumKeyboard", Spell.QUANPIN); 42 | b.comment("Set to true to enable fuzzy spelling zh <=> z"); 43 | enableFZh2z = b.define("enableFZh2z", false); 44 | b.comment("Set to true to enable fuzzy spelling sh <=> s"); 45 | enableFSh2s = b.define("enableFSh2s", false); 46 | b.comment("Set to true to enable fuzzy spelling ch <=> c"); 47 | enableFCh2c = b.define("enableFCh2c", false); 48 | b.comment("Set to true to enable fuzzy spelling ang <=> an"); 49 | enableFAng2an = b.define("enableFAng2an", false); 50 | b.comment("Set to true to enable fuzzy spelling ing <=> in"); 51 | enableFIng2in = b.define("enableFIng2in", false); 52 | b.comment("Set to true to enable fuzzy spelling eng <=> en"); 53 | enableFEng2en = b.define("enableFEng2en", false); 54 | b.comment("Set to true to enable fuzzy spelling u <=> v"); 55 | enableFU2v = b.define("enableFU2v", false); 56 | b.comment("Set to false to disable chat message when entering world"); 57 | enableChat = b.define("enableChat", true); 58 | b.comment("Set to true to disable JEI's split for search tokens"); 59 | enableQuote = b.define("enableQuote", false); 60 | b.pop(); 61 | 62 | b.push("Utilities"); 63 | b.comment("List of classes to dump all the functions"); 64 | listDumpClass = b.defineList("listDumpClass", Collections.emptyList(), p); 65 | b.comment("Set true to print verbose debug message"); 66 | enableVerbose = b.define("enableVerbose", false); 67 | b.pop(); 68 | 69 | common = b.build(); 70 | } 71 | 72 | static void register() { 73 | ModLoadingContext.get().registerConfig(COMMON, JechConfig.common, 74 | FMLPaths.CONFIGDIR.get().resolve(PATH).toString()); 75 | } 76 | 77 | public enum Spell { 78 | QUANPIN(Keyboard.QUANPIN), DAQIAN(Keyboard.DAQIAN), 79 | XIAOHE(Keyboard.XIAOHE), ZIRANMA(Keyboard.ZIRANMA), 80 | SOUGOU(Keyboard.SOUGOU), GUOBIAO(Keyboard.GUOBIAO), 81 | MICROSOFT(Keyboard.MICROSOFT), PINYINPP(Keyboard.PINYINPP), 82 | ZIGUANG(Keyboard.ZIGUANG); 83 | 84 | public final Keyboard keyboard; 85 | 86 | Spell(Keyboard keyboard) { 87 | this.keyboard = keyboard; 88 | } 89 | 90 | Keyboard get() { 91 | return keyboard; 92 | } 93 | } 94 | } -------------------------------------------------------------------------------- /src/main/java/me/towdium/jecharacters/JustEnoughCharacters.java: -------------------------------------------------------------------------------- 1 | package me.towdium.jecharacters; 2 | 3 | import me.towdium.jecharacters.utils.Greetings; 4 | import net.minecraft.MethodsReturnNonnullByDefault; 5 | import net.minecraft.client.Minecraft; 6 | import net.minecraft.network.chat.Component; 7 | import net.minecraft.network.chat.TranslatableComponent; 8 | import net.minecraft.world.entity.player.Player; 9 | import net.minecraftforge.event.entity.EntityJoinWorldEvent; 10 | import net.minecraftforge.eventbus.api.SubscribeEvent; 11 | import net.minecraftforge.fml.common.Mod; 12 | import net.minecraftforge.fml.event.lifecycle.FMLConstructModEvent; 13 | import org.apache.logging.log4j.LogManager; 14 | import org.apache.logging.log4j.Logger; 15 | 16 | import javax.annotation.ParametersAreNonnullByDefault; 17 | 18 | import static me.towdium.jecharacters.JechConfig.Spell.QUANPIN; 19 | import static net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD; 20 | 21 | 22 | @Mod.EventBusSubscriber(bus = MOD) 23 | @MethodsReturnNonnullByDefault 24 | @ParametersAreNonnullByDefault 25 | @Mod(JustEnoughCharacters.MODID) 26 | public class JustEnoughCharacters { 27 | public static final String MODID = "jecharacters"; 28 | public static Logger logger = LogManager.getLogger(MODID); 29 | static boolean messageSent = false; 30 | 31 | public JustEnoughCharacters() { 32 | JechConfig.register(); 33 | } 34 | 35 | @SubscribeEvent 36 | public static void onConstruct(FMLConstructModEvent event) { 37 | Greetings.send(logger, MODID); 38 | } 39 | 40 | public static void printMessage(Component message) { 41 | Minecraft.getInstance().gui.getChat().addMessage(message); 42 | } 43 | 44 | @Mod.EventBusSubscriber 45 | static class EventHandler { 46 | @SubscribeEvent 47 | public static void onPlayerLogin(EntityJoinWorldEvent event) { 48 | if (event.getEntity() instanceof Player && event.getEntity().level.isClientSide 49 | && JechConfig.enableChat.get() && !messageSent 50 | && (JechConfig.enumKeyboard.get() == QUANPIN) 51 | && Minecraft.getInstance().options.languageCode.equals("zh_tw")) { 52 | printMessage(new TranslatableComponent("jecharacters.chat.taiwan")); 53 | messageSent = true; 54 | } 55 | } 56 | } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /src/main/java/me/towdium/jecharacters/utils/Greetings.java: -------------------------------------------------------------------------------- 1 | package me.towdium.jecharacters.utils; 2 | 3 | import net.minecraftforge.fml.ModList; 4 | import org.apache.logging.log4j.Logger; 5 | 6 | import java.util.HashMap; 7 | import java.util.HashSet; 8 | import java.util.Map; 9 | import java.util.Set; 10 | 11 | public class Greetings { 12 | static final String[] MODS = {"jecharacters", "jecalculation"}; 13 | static final Set SENT = new HashSet<>(); 14 | static final Map FRIENDS = new HashMap() {{ 15 | put("kiwi", "Snownee"); 16 | put("i18nupdatemod", "TartaricAcid"); 17 | put("touhou_little_maid", "TartaricAcid"); 18 | }}; 19 | 20 | public static void send(Logger logger, String self) { 21 | boolean master = true; 22 | for (String i : MODS) { 23 | if (ModList.get().isLoaded(i)) { 24 | if (!i.equals(self)) master = false; 25 | break; 26 | } 27 | } 28 | 29 | if (master) { 30 | for (Map.Entry i : FRIENDS.entrySet()) { 31 | if (ModList.get().isLoaded(i.getKey()) && !SENT.contains(i.getValue())) { 32 | logger.info("Good to see you, {}", i.getValue()); 33 | SENT.add(i.getValue()); 34 | } 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/main/java/me/towdium/jecharacters/utils/Match.java: -------------------------------------------------------------------------------- 1 | package me.towdium.jecharacters.utils; 2 | 3 | import me.towdium.jecharacters.JechConfig; 4 | import me.towdium.jecharacters.JustEnoughCharacters; 5 | import me.towdium.pinin.DictLoader; 6 | import me.towdium.pinin.PinIn; 7 | import me.towdium.pinin.searchers.TreeSearcher; 8 | import mezz.jei.core.search.suffixtree.GeneralizedSuffixTree; 9 | import net.minecraft.MethodsReturnNonnullByDefault; 10 | import net.minecraft.client.searchtree.SuffixArray; 11 | import net.minecraftforge.eventbus.api.SubscribeEvent; 12 | import net.minecraftforge.fml.common.Mod; 13 | import net.minecraftforge.fml.event.config.ModConfigEvent; 14 | 15 | import javax.annotation.ParametersAreNonnullByDefault; 16 | import java.util.Collections; 17 | import java.util.List; 18 | import java.util.Set; 19 | import java.util.WeakHashMap; 20 | import java.util.function.BiConsumer; 21 | import java.util.regex.Matcher; 22 | import java.util.regex.Pattern; 23 | 24 | import static me.towdium.pinin.searchers.Searcher.Logic.CONTAIN; 25 | import static net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus.MOD; 26 | 27 | @Mod.EventBusSubscriber(bus = MOD) 28 | @ParametersAreNonnullByDefault 29 | @MethodsReturnNonnullByDefault 30 | public class Match { 31 | public static final PinIn context = new PinIn(new Loader()).config().accelerate(true).commit(); 32 | static final Pattern p = Pattern.compile("a"); 33 | static Set> searchers = Collections.newSetFromMap(new WeakHashMap<>()); 34 | 35 | private static TreeSearcher searcher() { 36 | TreeSearcher ret = new TreeSearcher<>(CONTAIN, context); 37 | searchers.add(ret); 38 | return ret; 39 | } 40 | 41 | // Psi 42 | public static int rank(Object o, String s1, String s2) { 43 | return contains(s1, s2) ? 1 : 0; 44 | } 45 | 46 | public static String wrap(String s) { 47 | return JechConfig.enableQuote.get() ? '"' + s + '"' : s; 48 | } 49 | 50 | public static boolean contains(String s, CharSequence cs) { 51 | boolean b = context.contains(s, cs.toString()); 52 | if (JechConfig.enableVerbose.get()) 53 | JustEnoughCharacters.logger.info("contains(" + s + ',' + cs + ")->" + b); 54 | return b; 55 | } 56 | 57 | public static boolean contains(CharSequence a, CharSequence b, boolean c) { 58 | if (c) return contains(a.toString().toLowerCase(), b.toString().toLowerCase()); 59 | else return contains(a, b); 60 | } 61 | 62 | public static boolean equals(String s, Object o) { 63 | boolean b = o instanceof String && context.matches(s, (String) o); 64 | if (JechConfig.enableVerbose.get()) 65 | JustEnoughCharacters.logger.info("contains(" + s + ',' + o + ")->" + b); 66 | return b; 67 | } 68 | 69 | public static boolean contains(CharSequence a, CharSequence b) { 70 | return contains(a.toString(), b); 71 | } 72 | 73 | public static Matcher matcher(Pattern test, CharSequence name) { 74 | boolean result; 75 | if ((test.flags() & Pattern.CASE_INSENSITIVE) != 0 || (test.flags() & Pattern.UNICODE_CASE) != 0) { 76 | result = matches(name.toString().toLowerCase(), test.toString().toLowerCase()); 77 | } else { 78 | result = matches(name.toString(), test.toString()); 79 | } 80 | return result ? p.matcher("a") : p.matcher(""); 81 | } 82 | 83 | public static boolean matches(String s1, String s2) { 84 | boolean start = s2.startsWith(".*"); 85 | boolean end = s2.endsWith(".*"); 86 | if (start && end && s2.length() < 4) end = false; 87 | if (start || end) s2 = s2.substring(start ? 2 : 0, s2.length() - (end ? 2 : 0)); 88 | return contains(s1, s2); 89 | } 90 | 91 | @SubscribeEvent 92 | public static void onConfigChange(ModConfigEvent e) { 93 | onConfigChange(); 94 | } 95 | 96 | public static void onConfigChange() { 97 | context.config().keyboard(JechConfig.enumKeyboard.get().keyboard) 98 | .fAng2An(JechConfig.enableFAng2an.get()).fEng2En(JechConfig.enableFEng2en.get()) 99 | .fIng2In(JechConfig.enableFIng2in.get()).fZh2Z(JechConfig.enableFZh2z.get()) 100 | .fCh2C(JechConfig.enableFCh2c.get()).fSh2S(JechConfig.enableFSh2s.get()) 101 | .fU2V(JechConfig.enableFU2v.get()).commit(); 102 | searchers.forEach(TreeSearcher::refresh); 103 | } 104 | 105 | public static class FakeTree extends GeneralizedSuffixTree { 106 | 107 | TreeSearcher tree = searcher(); 108 | 109 | @Override 110 | public void getSearchResults(String word, Set results) { 111 | if (JechConfig.enableVerbose.get()) { 112 | JustEnoughCharacters.logger.info("FakeTree:search(" + word + ')'); 113 | } 114 | results.addAll(tree.search(word)); 115 | } 116 | 117 | @Override 118 | public void put(String key, T value) { 119 | if (JechConfig.enableVerbose.get()) { 120 | JustEnoughCharacters.logger.info("FakeTree:put(" + key + ',' + value + ')'); 121 | } 122 | tree.put(key, value); 123 | } 124 | 125 | @Override 126 | public void getAllElements(Set results) { 127 | results.addAll(tree.search("")); 128 | } 129 | 130 | } 131 | 132 | public static class FakeArray extends SuffixArray { 133 | TreeSearcher tree = searcher(); 134 | 135 | @Override 136 | public void add(T v, String k) { 137 | if (JechConfig.enableVerbose.get()) 138 | JustEnoughCharacters.logger.info("FakeArray:put(" + v + ',' + k + ')'); 139 | tree.put(k, v); 140 | } 141 | 142 | @Override 143 | public void generate() { 144 | } 145 | 146 | @Override 147 | public List search(String k) { 148 | if (JechConfig.enableVerbose.get()) 149 | JustEnoughCharacters.logger.info("FakeArray:search(" + k + ')'); 150 | return tree.search(k); 151 | } 152 | } 153 | 154 | static class Loader extends DictLoader.Default { 155 | @Override 156 | public void load(BiConsumer feed) { 157 | super.load(feed); 158 | feed.accept('\u9FCF', new String[]{"mai4"}); // 钅麦 159 | feed.accept('\u9FD4', new String[]{"ge1"}); // 钅哥 160 | feed.accept('\u9FED', new String[]{"ni3"}); // 钅尔 161 | feed.accept('\u9FEC', new String[]{"tian2"}); // 石田 162 | feed.accept('\u9FEB', new String[]{"ao4"}); // 奥气 163 | feed.accept('\uE900', new String[]{"lu2"}); // 钅卢 164 | feed.accept('\uE901', new String[]{"du4"}); // 钅杜 165 | feed.accept('\uE902', new String[]{"xi3"}); // 钅喜 166 | feed.accept('\uE903', new String[]{"bo1"}); // 钅波 167 | feed.accept('\uE904', new String[]{"hei1"}); // 钅黑 168 | feed.accept('\uE906', new String[]{"da2"}); // 钅达 169 | feed.accept('\uE907', new String[]{"lun2"}); // 钅仑 170 | feed.accept('\uE910', new String[]{"fu1"}); // 钅夫 171 | feed.accept('\uE912', new String[]{"li4"}); // 钅立 172 | } 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /src/main/java/me/towdium/jecharacters/utils/Profiler.java: -------------------------------------------------------------------------------- 1 | package me.towdium.jecharacters.utils; 2 | 3 | import com.electronwill.nightconfig.core.Config; 4 | import com.electronwill.nightconfig.core.file.FileConfig; 5 | import com.google.gson.Gson; 6 | import net.minecraft.client.searchtree.SuffixArray; 7 | import org.objectweb.asm.ClassReader; 8 | import org.objectweb.asm.Handle; 9 | import org.objectweb.asm.Opcodes; 10 | import org.objectweb.asm.tree.*; 11 | 12 | import java.io.File; 13 | import java.io.IOException; 14 | import java.io.InputStream; 15 | import java.io.InputStreamReader; 16 | import java.nio.file.Files; 17 | import java.nio.file.Path; 18 | import java.util.*; 19 | import java.util.function.Consumer; 20 | import java.util.zip.ZipFile; 21 | 22 | import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; 23 | import static me.towdium.jecharacters.JustEnoughCharacters.logger; 24 | 25 | /** 26 | * Author: Towdium 27 | * Date: 14/06/17 28 | */ 29 | public class Profiler { 30 | private static final Analyzer[] ANALYZERS = new Analyzer[]{ 31 | new Analyzer.Construct(Type.SUFFIX, SuffixArray.class.getCanonicalName().replace('.', '/')), 32 | new Analyzer.Invoke( 33 | Type.CONTAINS, false, "java/lang/String", "contains", 34 | "(Ljava/lang/CharSequence;)Z" 35 | ), 36 | new Analyzer.Invoke( 37 | Type.CONTAINS, true, "kotlin/text/StringsKt", "contains", 38 | "(Ljava/lang/CharSequence;Ljava/lang/CharSequence;Z)Z" 39 | ), 40 | new Analyzer.Invoke( 41 | Type.CONTAINS, true, "kotlin/text/StringsKt", "contains", 42 | "(Ljava/lang/CharSequence;Ljava/lang/CharSequence)Z" 43 | ), 44 | new Analyzer.Invoke( 45 | Type.EQUALS, false, "java/lang/String", "equals", 46 | "(Ljava/lang/Object;)Z" 47 | ), 48 | new Analyzer.Invoke( 49 | Type.REGEXP, false, "java/lang/String", "matches", 50 | "(Ljava/lang/String;)Z" 51 | ), 52 | new Analyzer.Invoke( 53 | Type.REGEXP, false, "java/util/regex/Pattern", "matcher", 54 | "(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;" 55 | ), 56 | }; 57 | 58 | public static Report run() { 59 | File modDirectory = new File("mods"); 60 | Report r = new Report(); 61 | r.jars = scanDirectory(modDirectory); 62 | return r; 63 | } 64 | 65 | private static ArrayList scanDirectory(File f) { 66 | File[] files = f.listFiles(); 67 | ArrayList jcs = new ArrayList<>(); 68 | Consumer callback = jcs::add; 69 | if (files != null) { 70 | for (File file : files) { 71 | if (file.isFile() && file.getName().endsWith(".jar")) { 72 | try (ZipFile mod = new ZipFile(file)) { 73 | scanJar(mod, callback); 74 | } catch (IOException e) { 75 | e.printStackTrace(); 76 | } 77 | } else if (file.isDirectory()) { 78 | jcs.addAll(scanDirectory(file)); 79 | } 80 | } 81 | } 82 | return jcs; 83 | } 84 | 85 | private static ModContainer[] readInfoOld(InputStream is) { 86 | Gson gson = new Gson(); 87 | try { 88 | return gson.fromJson(new InputStreamReader(is), ModContainer[].class); 89 | } catch (Exception e) { 90 | return new ModContainer[]{gson.fromJson(new InputStreamReader(is), ModContainer.class)}; 91 | } 92 | } 93 | 94 | private static ModContainer[] readInfoNew(InputStream is) { 95 | Path p = null; 96 | try { 97 | p = Files.createTempFile("jecharacters", ".toml"); 98 | Files.copy(is, p, REPLACE_EXISTING); 99 | FileConfig c = FileConfig.of(p); 100 | c.load(); 101 | Collection mods = c.get("mods"); 102 | return mods.stream().map(i -> { 103 | ModContainer mc = new ModContainer(); 104 | mc.modid = i.get("modId"); 105 | mc.name = i.get("displayName"); 106 | mc.version = i.get("version"); 107 | return mc; 108 | }).toArray(ModContainer[]::new); 109 | } catch (IOException e) { 110 | e.printStackTrace(); 111 | return null; 112 | } finally { 113 | if (p != null && !p.toFile().delete()) { 114 | logger.info("Failed to delete temp file."); 115 | } 116 | } 117 | } 118 | 119 | private static void scanJar(ZipFile f, Consumer cbkJar) { 120 | EnumMap> methods = new EnumMap<>(Type.class); 121 | for (Type t : Type.values()) methods.put(t, new TreeSet<>()); 122 | 123 | JarContainer ret = new JarContainer(); 124 | f.stream().forEach(entry -> { 125 | try (InputStream is = f.getInputStream(entry)) { 126 | if ("META-INF/mods.toml".equals(entry.getName())) ret.mods = readInfoNew(is); 127 | else if ("mcmod.info".equals(entry.getName())) ret.mods = readInfoOld(is); 128 | else if (entry.getName().endsWith(".class")) { 129 | long size = entry.getSize() + 4; 130 | if (size > Integer.MAX_VALUE) { 131 | logger.info("Class file " + entry.getName() + " in jar file " + f.getName() + " is too large, skip."); 132 | } else scanClass(is, methods); 133 | } 134 | } catch (IOException e) { 135 | logger.info("Fail to read file " + entry.getName() + " in jar file " + f.getName() + ", skip."); 136 | } 137 | }); 138 | 139 | if (methods.values().stream().anyMatch(i -> !i.isEmpty())) { 140 | ret.contains = new ArrayList<>(methods.get(Type.CONTAINS)); 141 | ret.regExp = new ArrayList<>(methods.get(Type.REGEXP)); 142 | ret.suffix = new ArrayList<>(methods.get(Type.SUFFIX)); 143 | ret.equals = new ArrayList<>(methods.get(Type.EQUALS)); 144 | cbkJar.accept(ret); 145 | } 146 | } 147 | 148 | private static void scanClass(InputStream is, EnumMap> methods) 149 | throws IOException { 150 | ClassNode classNode = new ClassNode(); 151 | ClassReader classReader = new ClassReader(is); 152 | try { 153 | classReader.accept(classNode, 0); 154 | } catch (Exception e) { 155 | if (classNode.name != null) { 156 | logger.info("File decoding of class " + classNode.name + " failed. Try to continue."); 157 | } else throw new IOException(e); 158 | } 159 | classNode.methods.forEach(methodNode -> { 160 | for (AbstractInsnNode node : methodNode.instructions) { 161 | Arrays.stream(ANALYZERS).forEach(i -> i.analyze(node, classNode, methodNode, methods)); 162 | } 163 | }); 164 | } 165 | 166 | public static class Report { 167 | List jars; 168 | } 169 | 170 | @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") 171 | private static class JarContainer { 172 | ModContainer[] mods; 173 | List contains; 174 | List regExp; 175 | List suffix; 176 | List equals; 177 | } 178 | 179 | @SuppressWarnings("unused") 180 | private static class ModContainer { 181 | String modid; 182 | String name; 183 | String version; 184 | } 185 | 186 | private static abstract class Analyzer { 187 | Type type; 188 | 189 | public Analyzer(Type type) { 190 | this.type = type; 191 | } 192 | 193 | public void analyze(AbstractInsnNode insn, ClassNode clazz, MethodNode method, 194 | EnumMap> methods) { 195 | if (match(insn)) { 196 | methods.get(type).add(clazz.name.replace('/', '.') + ":" + method.name + method.desc); 197 | } 198 | } 199 | 200 | abstract boolean match(AbstractInsnNode insn); 201 | 202 | private static class Invoke extends Analyzer { 203 | String owner; 204 | String name; 205 | String desc; 206 | int op; 207 | int tag; 208 | 209 | public Invoke(Type type, boolean isStatic, String owner, String name, String desc) { 210 | super(type); 211 | op = isStatic ? Opcodes.INVOKESTATIC : Opcodes.INVOKEVIRTUAL; 212 | tag = isStatic ? Opcodes.H_INVOKESTATIC : Opcodes.H_INVOKEVIRTUAL; 213 | this.owner = owner; 214 | this.name = name; 215 | this.desc = desc; 216 | } 217 | 218 | @Override 219 | boolean match(AbstractInsnNode insn) { 220 | if (insn instanceof MethodInsnNode node) { 221 | return node.getOpcode() == op && node.owner.equals(owner) && 222 | node.name.equals(name) && node.desc.equals(desc); 223 | } else if (insn instanceof InvokeDynamicInsnNode din) { 224 | if (din.bsmArgs.length != 3) return false; 225 | Object arg = din.bsmArgs[1]; 226 | if (arg instanceof Handle handle) { 227 | return handle.getTag() == tag && handle.getOwner().equals(owner) && 228 | handle.getName().equals(name) && handle.getDesc().equals(desc); 229 | } 230 | } 231 | return false; 232 | } 233 | } 234 | 235 | private static class Construct extends Analyzer { 236 | String clazz; 237 | 238 | public Construct(Type type, String clazz) { 239 | super(type); 240 | this.clazz = clazz; 241 | } 242 | 243 | @Override 244 | boolean match(AbstractInsnNode insn) { 245 | if (insn instanceof TypeInsnNode tin) { 246 | return tin.getOpcode() == Opcodes.NEW && tin.desc.equals(clazz); 247 | } else return false; 248 | } 249 | } 250 | } 251 | 252 | enum Type { 253 | CONTAINS, 254 | EQUALS, 255 | REGEXP, 256 | SUFFIX 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/mods.toml: -------------------------------------------------------------------------------- 1 | modLoader="javafml" 2 | loaderVersion="[39,)" 3 | issueTrackerURL="https://github.com/Towdium/JustEnoughCharacters/issues" 4 | license="The MIT License (MIT)" 5 | 6 | [[mods]] 7 | modId="jecharacters" 8 | version="${version}" 9 | displayName="Just Enough Characters" 10 | displayURL="https://github.com/Towdium/JustEnoughCharacters" 11 | credits="Thanks to TartaricAcid, 3TUSK, Seraph_JACK, Snownee and many people for their efforts for development of the Chinese modding community." 12 | authors="Towdium, yzl210, Death-123" 13 | description="Pinyin search for JEI and more." 14 | -------------------------------------------------------------------------------- /src/main/resources/assets/jecharacters/lang/en_us.json: -------------------------------------------------------------------------------- 1 | { 2 | "jecharacters.chat.start": "Start profiling", 3 | "jecharacters.chat.saved": "Done! Output saved to logs/jecharacters.txt.", 4 | "jecharacters.chat.error": "Oops! An error occurred when writing the file.", 5 | "jecharacters.chat.taiwan": "Internal error.", 6 | "jecharacters.chat.help": "/jech [profile] / [verbose true/false]" 7 | } -------------------------------------------------------------------------------- /src/main/resources/assets/jecharacters/lang/zh_cn.json: -------------------------------------------------------------------------------- 1 | { 2 | "jecharacters.chat.start":"开始分析模组文件。", 3 | "jecharacters.chat.saved":"搞定!报告已导出至 logs/jecharacters.txt。", 4 | "jecharacters.chat.error":"卧槽,写入文件时出现了一个问题。", 5 | "jecharacters.chat.taiwan":"内部错误。", 6 | "jecharacters.chat.help":"/jech [profile] / [verbose true/false]" 7 | } -------------------------------------------------------------------------------- /src/main/resources/assets/jecharacters/lang/zh_tw.json: -------------------------------------------------------------------------------- 1 | { 2 | "jecharacters.chat.start": "開始分析模組文件。", 3 | "jecharacters.chat.saved": "完成!分析報告已保存至 logs/jecharacters.txt。", 4 | "jecharacters.chat.error": "寫入文檔時出現了一個問題。", 5 | "jecharacters.chat.taiwan":" §e[Just Enough Characters] §f檢測到您正在使用繁體中文。\n 切換至注音輸入法,請執行 /jech keyboard daqian\n 关闭此消息,請執行 /jech silent", 6 | "jecharacters.chat.help": "/jech [profile] / [verbose true/false]" 7 | } -------------------------------------------------------------------------------- /src/main/resources/me/towdium/jecharacters/scripts/_lib.js: -------------------------------------------------------------------------------- 1 | var Ops = Java.type('org.objectweb.asm.Opcodes'); 2 | var InsnMethod = Java.type('org.objectweb.asm.tree.MethodInsnNode'); 3 | var InsnDynamic = Java.type('org.objectweb.asm.tree.InvokeDynamicInsnNode'); 4 | var Handle = Java.type('org.objectweb.asm.Handle'); 5 | var Api = Java.type('net.minecraftforge.coremod.api.ASMAPI'); 6 | 7 | function transConstruct(method, src, dst) { 8 | var i = method.instructions.iterator(); 9 | while (i.hasNext()) { 10 | var n = i.next(); 11 | if (n.getOpcode() === Ops.NEW) { 12 | if (n.desc === src) { 13 | n.desc = dst; 14 | } 15 | } else if (n.getOpcode() === Ops.INVOKESPECIAL) { 16 | if (n.owner === src) n.owner = dst; 17 | } 18 | } 19 | } 20 | 21 | function transInvoke(method, srcOwner, srcName, srcDesc, dstOwner, dstName, dstDesc) { 22 | var i = method.instructions.iterator(); 23 | while (i.hasNext()) { 24 | var n = i.next(); 25 | var op = n.getOpcode(); 26 | if (n instanceof InsnMethod && n.owner === srcOwner && n.name === srcName && n.desc === srcDesc 27 | && (Ops.INVOKEVIRTUAL === op || Ops.INVOKESPECIAL === op || Ops.INVOKESTATIC === op)) { 28 | n.setOpcode(Ops.INVOKESTATIC); 29 | n.owner = dstOwner; 30 | n.name = dstName; 31 | n.desc = dstDesc 32 | } else if (n instanceof InsnDynamic && op === Ops.INVOKEDYNAMIC) { 33 | var h = n.bsmArgs[1]; 34 | if (h instanceof Handle) { 35 | if (h.getOwner() === srcOwner && h.getName() === srcName && h.getDesc() === srcDesc) 36 | n.bsmArgs[1] = new Handle(Ops.H_INVOKESTATIC, dstOwner, dstName, dstDesc); 37 | } 38 | } 39 | } 40 | } 41 | 42 | function transInvokeLambda(method, srcOwner, srcName, srcDesc, dstOwner, dstName, dstDesc){ 43 | var i = method.instructions.iterator(); 44 | while (i.hasNext()) { 45 | var n = i.next(); 46 | var op = n.getOpcode(); 47 | if (n instanceof InsnDynamic && op === Ops.INVOKEDYNAMIC) { 48 | var h = n.bsmArgs[1]; 49 | if (h.getOwner() === srcOwner && h.getName() === srcName && h.getDesc() === srcDesc) 50 | n.bsmArgs[1] = new Handle(h.tag, dstOwner, dstName, dstDesc); 51 | } 52 | } 53 | } 54 | 55 | var transContains = function (method) { 56 | transInvoke(method, 57 | 'java/lang/String', 58 | 'contains', 59 | '(Ljava/lang/CharSequence;)Z', 60 | 'me/towdium/jecharacters/utils/Match', 61 | 'contains', 62 | '(Ljava/lang/String;Ljava/lang/CharSequence;)Z' 63 | ); 64 | transInvoke(method, 65 | 'kotlin/text/StringsKt', 66 | 'contains', 67 | '(Ljava/lang/CharSequence;Ljava/lang/CharSequence;Z)Z', 68 | 'me/towdium/jecharacters/utils/Match', 69 | 'contains', 70 | '(Ljava/lang/CharSequence;Ljava/lang/CharSequence;Z)Z' 71 | ); 72 | transInvoke(method, 73 | 'kotlin/text/StringsKt', 74 | 'contains', 75 | '(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Z', 76 | 'me/towdium/jecharacters/utils/Match', 77 | 'contains', 78 | '(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Z' 79 | ); 80 | return method; 81 | }; 82 | 83 | var transSuffix = function (method) { 84 | transConstruct(method, 85 | 'net/minecraft/client/searchtree/SuffixArray', 86 | 'me/towdium/jecharacters/utils/Match$FakeArray' 87 | ); 88 | return method; 89 | }; 90 | 91 | var transRegExp = function (method) { 92 | transInvoke(method, 93 | 'java/util/regex/Pattern', 94 | 'matcher', 95 | '(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;', 96 | 'me/towdium/jecharacters/utils/Match', 97 | 'matcher', 98 | '(Ljava/util/regex/Pattern;Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;' 99 | ); 100 | transInvoke(method, 101 | 'java/lang/String', 102 | 'matches', 103 | '(Ljava/lang/String;)Z', 104 | 'me/towdium/jecharacters/utils/Match', 105 | 'matches', 106 | '(Ljava/lang/String;Ljava/lang/String;)Z' 107 | ); 108 | return method; 109 | }; 110 | 111 | var transEquals = function (method) { 112 | transInvoke(method, 113 | 'java/lang/String', 114 | 'equals', 115 | '(Ljava/lang/Object;)Z', 116 | 'me/towdium/jecharacters/utils/Match', 117 | 'equals', 118 | '(Ljava/lang/String;Ljava/lang/Object;)Z' 119 | ); 120 | return method; 121 | }; 122 | -------------------------------------------------------------------------------- /src/main/resources/me/towdium/jecharacters/scripts/jei1.js: -------------------------------------------------------------------------------- 1 | function initializeCoreMod() { 2 | Java.type('net.minecraftforge.coremod.api.ASMAPI').loadFile('me/towdium/jecharacters/scripts/_lib.js'); 3 | return { 4 | 'jecharacters-jei9-1': { 5 | 'target': { 6 | 'type': 'METHOD', 7 | 'class': 'mezz.jei.search.ElementPrefixParser', 8 | 'methodName': "", 9 | 'methodDesc': '()V' 10 | }, 11 | 'transformer': function (method) { 12 | transInvokeLambda(method, 13 | 'mezz/jei/core/search/suffixtree/GeneralizedSuffixTree', 14 | '', 15 | '()V', 16 | 'me/towdium/jecharacters/utils/Match$FakeTree', 17 | '', 18 | '()V' 19 | ); 20 | return method; 21 | } 22 | }, 23 | 'jecharacters-jei10-1' :{ 24 | 'target': { 25 | 'type': 'METHOD', 26 | 'class': 'mezz.jei.common.search.ElementPrefixParser', 27 | 'methodName': "", 28 | 'methodDesc': '()V' 29 | }, 30 | 'transformer': function (method) { 31 | transInvokeLambda(method, 32 | 'mezz/jei/core/search/suffixtree/GeneralizedSuffixTree', 33 | '', 34 | '()V', 35 | 'me/towdium/jecharacters/utils/Match$FakeTree', 36 | '', 37 | '()V' 38 | ); 39 | return method; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/resources/me/towdium/jecharacters/scripts/jei2.js: -------------------------------------------------------------------------------- 1 | function initializeCoreMod() { 2 | Java.type('net.minecraftforge.coremod.api.ASMAPI').loadFile('me/towdium/jecharacters/scripts/_lib.js'); 3 | return { 4 | 'jecharacters-jei9-2': { 5 | 'target': { 6 | 'type': 'METHOD', 7 | 'class': 'mezz.jei.search.ElementPrefixParser', 8 | 'methodName': '', 9 | 'methodDesc': '()V' 10 | }, 11 | 'transformer': function (method) { 12 | transInvokeLambda(method, 13 | 'mezz/jei/core/search/suffixtree/GeneralizedSuffixTree', 14 | '', 15 | '()V', 16 | 'me/towdium/jecharacters/utils/Match$FakeTree', 17 | '', 18 | '()V' 19 | ); 20 | return method; 21 | } 22 | }, 23 | 'jecharacters-jei10-2': { 24 | 'target': { 25 | 'type': 'METHOD', 26 | 'class': 'mezz.jei.common.search.ElementPrefixParser', 27 | 'methodName': '', 28 | 'methodDesc': '()V' 29 | }, 30 | 'transformer': function (method) { 31 | transInvokeLambda(method, 32 | 'mezz/jei/core/search/suffixtree/GeneralizedSuffixTree', 33 | '', 34 | '()V', 35 | 'me/towdium/jecharacters/utils/Match$FakeTree', 36 | '', 37 | '()V' 38 | ); 39 | return method; 40 | } 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/main/resources/me/towdium/jecharacters/scripts/jei3.js: -------------------------------------------------------------------------------- 1 | var insn = Java.type('org.objectweb.asm.tree.MethodInsnNode'); 2 | var opcodes = Java.type('org.objectweb.asm.Opcodes'); 3 | 4 | function initializeCoreMod() { 5 | return { 6 | 'jecharacters-jei9-3': { 7 | 'target': { 8 | 'type': 'METHOD', 9 | 'class': 'mezz.jei.ingredients.IngredientFilter', 10 | 'methodName': 'parseSearchTokens', 11 | 'methodDesc': '(Ljava/lang/String;)Lmezz/jei/ingredients/IngredientFilter$SearchTokens;' 12 | }, 13 | 'transformer': function (method) { 14 | transformMethod(method); 15 | return method; 16 | } 17 | }, 18 | 'jecharacters-jei10-3': { 19 | 'target': { 20 | 'type': 'METHOD', 21 | 'class': 'mezz.jei.common.ingredients.IngredientFilter', 22 | 'methodName': 'parseSearchTokens', 23 | 'methodDesc': '(Ljava/lang/String;)Lmezz/jei/ingredients/IngredientFilter$SearchTokens;' 24 | }, 25 | 'transformer': function (method) { 26 | transformMethod(method); 27 | return method; 28 | } 29 | } 30 | } 31 | } 32 | 33 | function transformMethod(method) { 34 | var list = method.instructions; 35 | for (var i = 0; i < list.size(); i++) { 36 | var node = list.get(i); 37 | if (node.getOpcode() === opcodes.INVOKEVIRTUAL) { 38 | var methodInsn = node; 39 | if (methodInsn.owner === 'java/util/regex/Pattern' && methodInsn.name === 'matcher' && methodInsn.desc === '(Ljava/lang/CharSequence;)Ljava/util/regex/Matcher;') { 40 | list.insert(node.getPrevious(), new insn(opcodes.INVOKESTATIC, 41 | "me/towdium/jecharacters/utils/Match", "wrap", 42 | "(Ljava/lang/String;)Ljava/lang/String;", false)); 43 | return method; 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/main/resources/me/towdium/jecharacters/scripts/psi.js: -------------------------------------------------------------------------------- 1 | function initializeCoreMod() { 2 | Java.type('net.minecraftforge.coremod.api.ASMAPI').loadFile('me/towdium/jecharacters/scripts/_lib.js'); 3 | return { 4 | 'jecharacters-psi': { 5 | 'target': { 6 | 'type': 'METHOD', 7 | 'class': 'vazkii.psi.client.gui.widget.PiecePanelWidget', 8 | 'methodName': 'ranking', 9 | 'methodDesc': '(Ljava/lang/String;Lvazkii/psi/api/spell/SpellPiece;)I' 10 | }, 11 | 'transformer': function (method) { 12 | transInvoke(method, 13 | 'vazkii/psi/client/gui/widget/PiecePanelWidget', 14 | 'rankTextToken', 15 | '(Ljava/lang/String;Ljava/lang/String;)I', 16 | 'me/towdium/jecharacters/utils/Match', 17 | 'rank', 18 | '(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;)I' 19 | ); 20 | return method; 21 | } 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/main/resources/pack.mcmeta: -------------------------------------------------------------------------------- 1 | { 2 | "pack": { 3 | "description": "jecharacters resources", 4 | "pack_format": 8 5 | } 6 | } 7 | --------------------------------------------------------------------------------