Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.7.81-GTNH:dev')
compileOnly('com.github.GTNewHorizons:Controlling:2.1.2:dev')
shadowImplementation("dev.ghostflyby:PinIn:1.7.2")
shadowImplementation 'org.luaj:luaj-jse:3.0.1'
runtimeOnlyNonPublishable('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-684-GTNH:dev')
api('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.4.113-gtnh:dev') {
exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
}
// compile('com.github.GTNewHorizons:VisualProspecting:1.5.3:dev')
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-684-GTNH:dev')
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:Controlling:2.1.2:dev')
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:AE2FluidCraft-Rework:1.4.113-gtnh:dev') {
// exclude group: 'com.github.GTNewHorizons', module: 'Applied-Energistics-2-Unofficial'
// }
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:VisualProspecting:1.5.3:dev')
// runtimeOnlyNonPublishable(files('libs/journeymap-1.7.10-5.2.10-dev.jar'))
// runtimeOnlyNonPublishable('com.github.GTNewHorizons:GT5-Unofficial:5.09.51.389:dev')
// runtimeOnlyNonPublishable("com.github.GTNewHorizons:GTNHLib:0.6.37:dev")
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ apiPackage =
accessTransformersFile =

# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = false
usesMixins = true

# Set to a non-empty string to configure mixins in a separate source set under src/VALUE, instead of src/main.
# This can speed up compile times thanks to not running the mixin annotation processor on all input sources.
Expand All @@ -90,7 +90,7 @@ mixinPlugin =
# Specify the package that contains all of your Mixins. The package must exist or
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
# it must match with this or the build will fail.
mixinsPackage =
mixinsPackage = core.mixins

# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatibility only
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/asdflj/nech/core/NechLatePlugin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.asdflj.nech.core;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.gtnewhorizon.gtnhmixins.ILateMixinLoader;
import com.gtnewhorizon.gtnhmixins.LateMixin;

@LateMixin
public class NechLatePlugin implements ILateMixinLoader {

@Override
public String getMixinConfig() {
return "mixins.nech.late.json";
}

@Override
public List<String> getMixins(Set<String> loadedMods) {
ArrayList<String> mixins = new ArrayList<>();
if (loadedMods.contains("controlling")) {
mixins.add("controlling.MixinSearchType");
}

return mixins;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.asdflj.nech.core.mixins.controlling;

import java.util.function.Predicate;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Pseudo;

import com.asdflj.nech.API;
import com.blamejared.controlling.client.gui.GuiNewKeyBindingList;
import com.blamejared.controlling.client.gui.SearchType;

@Pseudo
@Mixin(SearchType.class)
public abstract class MixinSearchType {

/**
* @author asdflj
* @reason 按键控制界面添加拼音搜索支持,由于技术上问题,无法支持高亮显示匹配的文本
* require vcwdfca
* url <a href="https://github.com/asdflj/NeverEnoughCharacters-Rework/issues/7">...</a>
*/
@Overwrite(remap = false)
public Predicate<GuiNewKeyBindingList.KeyEntry> getPredicate(String searchText) {
SearchType type = (SearchType) (Object) this;
String lowerSearchText = searchText.toLowerCase();
if (type == SearchType.ALL) {
return key -> {
// 检查分类名
String category = net.minecraft.util.StatCollector.translateToLocal(
key.getKeybinding()
.getKeyCategory())
.toLowerCase();
// 检查按键描述
String keyDesc = key.getKeyDesc()
.toLowerCase();
// 检查按键显示名称
String keyDisplay = net.minecraft.client.settings.GameSettings.getKeyDisplayString(
key.getKeybinding()
.getKeyCode())
.toLowerCase();

return API.INSTANCE.contains(category, lowerSearchText)
|| API.INSTANCE.contains(keyDesc, lowerSearchText)
|| API.INSTANCE.contains(keyDisplay, lowerSearchText);
};
} else if (type == SearchType.CATEGORY_NAME) {
return key -> API.INSTANCE.contains(
net.minecraft.util.StatCollector.translateToLocal(
key.getKeybinding()
.getKeyCategory())
.toLowerCase(),
lowerSearchText);
} else if (type == SearchType.KEYBIND_NAME) {
return key -> API.INSTANCE.contains(
key.getKeyDesc()
.toLowerCase(),
lowerSearchText);
} else if (type == SearchType.KEY_NAME) {
return key -> API.INSTANCE.contains(
net.minecraft.client.settings.GameSettings.getKeyDisplayString(
key.getKeybinding()
.getKeyCode())
.toLowerCase(),
lowerSearchText);
} else {
throw new IllegalStateException("Unknown SearchType");
}
}
}
10 changes: 10 additions & 0 deletions src/main/resources/mixins.nech.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"required": true,
"minVersion": "0",
"refmap": "mixins.ae2thing.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [],
"client": [],
"server": []
}
15 changes: 15 additions & 0 deletions src/main/resources/mixins.nech.late.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"required": false,
"minVersion": "0",
"package": "com.asdflj.nech.core.mixins",
"refmap": "mixins.nech.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
],
"server": [

]
}