Skip to content

Commit 39303fc

Browse files
authored
feat: option to automatically set max parallels in Parallel Hatches (#18)
2 parents 9de4ffc + fb1f1cf commit 39303fc

File tree

6 files changed

+52
-3
lines changed

6 files changed

+52
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Current features:
88
* 64A Energy Converters
99
* The Wireless Active Transformer (WAT)
1010
* Has an opt-in coolant system, where the WAT requires coolant to be used, or it'll explode (or just stop if GTm is set to have harmless active transformers)
11+
* Automatically set placed Parallel Hatches to their maximum parallels
1112

1213
All features can be enabled or disabled in the config.
1314

build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ sourceSets {
1414
}
1515
}
1616

17+
mixin {
18+
add sourceSets.main, "mixins.${mod_id}.refmap.json"
19+
config "${mod_id}.mixins.json"
20+
}
21+
1722
repositories {
1823
mavenLocal()
1924
mavenCentral()
@@ -138,6 +143,9 @@ apply from: "$rootDir/gradle/scripts/spotless.gradle"
138143
dependencies {
139144
compileOnly("org.jetbrains:annotations:26.0.1")
140145

146+
// Apply Mixin AP
147+
annotationProcessor('org.spongepowered:mixin:0.8.5:processor')
148+
141149
// JEI, EMI, Jade
142150
modCompileOnly("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
143151
modCompileOnly("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")

src/main/java/net/neganote/gtutilities/config/UtilConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public static class FeatureConfigs {
4949
@Configurable.Comment({ "Whether the Wireless Active Transformer is enabled." })
5050
public boolean pterbEnabled = true;
5151

52+
@Configurable
53+
@Configurable.Comment({
54+
"Whether placed Parallel Hatches should be automatically set to their maximum parallels." })
55+
public boolean parallelHatchAutoConfigure = false;
56+
5257
@Configurable
5358
@Configurable.Comment({ "Base amount of WAT coolant to drain every second.",
5459
"(Setting both this amount and the IO multiplier to 0 disables the coolant mechanic.)" })
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package net.neganote.gtutilities.mixin;
2+
3+
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
4+
import com.gregtechceu.gtceu.common.machine.multiblock.part.ParallelHatchPartMachine;
5+
6+
import net.neganote.gtutilities.config.UtilConfig;
7+
8+
import org.spongepowered.asm.mixin.Final;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.Shadow;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
import org.spongepowered.asm.mixin.injection.Inject;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
14+
15+
@Mixin(ParallelHatchPartMachine.class)
16+
public abstract class ParallelHatchPartMachineMixin {
17+
18+
@Shadow
19+
public abstract void setCurrentParallel(int parallelAmount);
20+
21+
@Shadow
22+
@Final
23+
private int maxParallel;
24+
25+
@Inject(
26+
method = "<init>",
27+
at = @At("TAIL"))
28+
public void constructor(IMachineBlockEntity holder, int tier, CallbackInfo ci) {
29+
if (UtilConfig.INSTANCE.features.parallelHatchAutoConfigure)
30+
this.setCurrentParallel(this.maxParallel);
31+
}
32+
}

src/main/resources/META-INF/mods.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ GregTech Utilities
2323
A GregTech Modern addon, adding some nice quality-of-life features.
2424
'''
2525

26+
[[mixins]]
27+
config="${mod_id}.mixins.json"
28+
2629
[[dependencies.${mod_id}]]
2730
modId = "forge"
2831
mandatory = true
@@ -40,4 +43,4 @@ A GregTech Modern addon, adding some nice quality-of-life features.
4043
mandatory = true
4144
versionRange = "[${gtceu_version},)"
4245
ordering = "AFTER"
43-
side = "BOTH"
46+
side = "BOTH"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"required": true,
3-
"package": "com.example.examplemod.mixin",
3+
"package": "net.neganote.gtutilities.mixin",
44
"compatibilityLevel": "JAVA_17",
5-
"minVersion": "0.8",
65
"mixins": [
6+
"ParallelHatchPartMachineMixin"
77
],
88
"client": [
99
],

0 commit comments

Comments
 (0)