-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added features (a cluster of mixins) - added configuration for disabling features/mixins - added restricting annotations to depTools
- Loading branch information
Showing
12 changed files
with
182 additions
and
111 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ repositories { | |
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains:annotations:24.0.0") | ||
} | ||
|
||
tasks.test { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
depTools/src/main/java/cn/taskeren/gtnn/tools/annotations/DepNotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cn.taskeren.gtnn.tools.annotations; | ||
|
||
import org.intellij.lang.annotations.Pattern; | ||
|
||
/** | ||
* Used to hint the dependency notation string error. | ||
* <p> | ||
* Examples: | ||
* <p> | ||
* <code>com.example:example-artifact</code> | ||
* <code>com.example:example-artifact:</code> | ||
* <code>com.example:example-artifact::dev</code> | ||
* <code>com.example:example-artifact:%version%-suffix:dev</code> | ||
*/ | ||
@Pattern("([^:]+):([^:]+)(?::([^:]*))?(?::([^:]+))?") | ||
public @interface DepNotation { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cn.taskeren.gtnn.mixinplugin; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collection; | ||
|
||
public enum Feature { | ||
|
||
ReturnDisassembler( | ||
"Add disassemblers back to the game.", | ||
Mixin.GTLoaderMachinesMixin, | ||
Mixin.GTShapedRecipe, | ||
Mixin.GTShapelessRecipe | ||
), | ||
|
||
NoLightningRodDestruction( | ||
"Remove the destruction when generating EU.", | ||
Mixin.GTMetaTileEntityLightningRod | ||
), | ||
|
||
LargeEssentiaGeneratorLaserHatchCompat( | ||
"Make Large Essentia Generators laser hatches compatible.", | ||
Mixin.LargeEssentiaGeneratorMixin | ||
), | ||
|
||
LegacyEyeOfHarmony( | ||
"Replace new Eye of Harmony with legacy one.", | ||
Mixin.EyeOfHarmonyMixin | ||
), | ||
|
||
LegacySupercriticalTurbine( | ||
"Replace new Supercritical Steam Turbine with legacy one.", | ||
Mixin.XLPlasmaTurbineMixin, | ||
Mixin.XLSCTurbineMixin | ||
), | ||
; | ||
|
||
public final String desc; | ||
public final Mixin[] mixins; | ||
|
||
Feature(String desc, Mixin... mixins) { | ||
this.desc = desc; | ||
this.mixins = mixins; | ||
} | ||
|
||
public boolean isEnabled() { | ||
return MixinConfig.isFeatureEnabled(this); | ||
} | ||
|
||
public boolean isTargetedModsLoad(Collection<TargetedMod> loadedMods) { | ||
return Arrays.stream(mixins).allMatch(mixin -> mixin.shouldLoad(loadedMods)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/cn/taskeren/gtnn/mixinplugin/MixinConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cn.taskeren.gtnn.mixinplugin; | ||
|
||
import com.google.common.collect.Maps; | ||
import net.minecraftforge.common.config.Configuration; | ||
|
||
import java.io.File; | ||
import java.util.Map; | ||
|
||
public class MixinConfig { | ||
|
||
private static final Configuration CONF = new Configuration(new File("gtnn.cfg")); | ||
private static final String CATEGORY_MIXIN = "mixin"; | ||
|
||
private static final Map<Feature, Boolean> VALUES = Maps.newHashMap(); | ||
|
||
public static void init() { | ||
CONF.load(); | ||
VALUES.clear(); | ||
|
||
for(var feature : Feature.values()) { | ||
var value = CONF.getBoolean("Enable" + feature.name(), CATEGORY_MIXIN, true, feature.desc); | ||
VALUES.put(feature, value); | ||
} | ||
|
||
CONF.save(); | ||
} | ||
|
||
public static boolean isFeatureEnabled(Feature feature) { | ||
return VALUES.getOrDefault(feature, true); | ||
} | ||
|
||
} |
Oops, something went wrong.