-
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.
- Loading branch information
Showing
6 changed files
with
63 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
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
19 changes: 19 additions & 0 deletions
19
src/main/kotlin/cn/elytra/mod/gtnn/inject/module/ModAdvancedAssemblyLineSubtick.kt
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,19 @@ | ||
package cn.elytra.mod.gtnn.inject.module | ||
|
||
import cn.elytra.mod.gtnn.inject.IMixinModule | ||
import cn.elytra.mod.gtnn.inject.TargetMod | ||
import net.minecraftforge.common.config.Configuration | ||
|
||
object ModAdvancedAssemblyLineSubtick : IMixinModule { | ||
|
||
override var enabled: Boolean = true | ||
override val mixins: Set<String> = setOf("ggfab.AALSubTick_MTEAdvAssLine_Mixin") | ||
|
||
override fun readConfig(config: Configuration) { | ||
enabled = config.getBoolean("enabled", "aal-subtick", enabled, "") | ||
} | ||
|
||
override fun isTargetModsLoaded(loadedMods: List<TargetMod>): Boolean { | ||
return TargetMod.GregTech in loadedMods | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/mixin/java/cn/taskeren/gtnn/mixin/ggfab/AALSubTick_MTEAdvAssLine_Mixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package cn.taskeren.gtnn.mixin.ggfab; | ||
|
||
import com.llamalad7.mixinextras.sugar.Local; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; | ||
import ggfab.mte.MTEAdvAssLine; | ||
import gregtech.api.recipe.check.CheckRecipeResult; | ||
import gregtech.api.util.GTUtility; | ||
import gregtech.api.util.OverclockCalculator; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(value = MTEAdvAssLine.class, remap = false) | ||
public class AALSubTick_MTEAdvAssLine_Mixin { | ||
|
||
@Inject(method = "checkProcessing", at = @At(value = "INVOKE", target = "Lggfab/mte/MTEAdvAssLine;isBatchModeEnabled()Z", ordinal = 0)) | ||
private void nn$setMaxParallel(CallbackInfoReturnable<CheckRecipeResult> cir, @Local(ordinal = 2) LocalIntRef maxParallelBeforeBatchMode, @Local(ordinal = 1) LocalIntRef maxParallel, @Local(ordinal = 1) OverclockCalculator calculator) { | ||
double tickTimeAfterOC = calculator.calculateDurationUnderOneTick(); | ||
if(tickTimeAfterOC < 1) { | ||
// get the value of updated time | ||
int value = GTUtility.safeInt((long) (maxParallel.get() / tickTimeAfterOC), 0); | ||
|
||
// set both variable to the value, since we are injecting at the isBatchModeEnabled(), | ||
// the maxParallelBeforeBatchMode is already assigned to the maxParallel, so we need to manually update it as well. | ||
maxParallel.set(value); | ||
maxParallelBeforeBatchMode.set(value); | ||
} | ||
} | ||
|
||
} |