Skip to content

Commit

Permalink
Rewrite Mixin loading and it should fix #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Taskeren committed Aug 25, 2024
1 parent 8de1bc6 commit 5072c47
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 156 deletions.
13 changes: 12 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ accessTransformersFile = op_at.cfg
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
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.
# Mixin classes will have access to "main" classes, but not the other way around.
separateMixinSourceSet =

# Adds some debug arguments like verbose output and class export.
usesMixinDebug = true

Expand Down Expand Up @@ -108,9 +113,15 @@ minimizeShadowedDependencies = true
# If disabled, won't rename the shadowed classes.
relocateShadowedDependencies = true

# Adds the GTNH maven, CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
# Adds CurseMaven, Modrinth, and some more well-known 1.7.10 repositories.
includeWellKnownRepositories = true

# A list of repositories to exclude from the includeWellKnownRepositories setting. Should be a space separated
# list of strings, with the acceptable keys being(case does not matter):
# cursemaven
# modrinth
excludeWellKnownRepositories =

# Change these to your Maven coordinates if you want to publish to a custom Maven repository instead of the default GTNH Maven.
# Authenticate with the MAVEN_USER and MAVEN_PASSWORD environment variables.
# If you need a more complex setup disable maven publishing here and add a publishing repository to addon.gradle.
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.taskeren.op.mixin;
package cn.taskeren.op.mixin.late;

import cn.taskeren.op.OP_Logger;
import com.gtnewhorizons.modularui.api.screen.ModularWindow;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.taskeren.op.mixin;
package cn.taskeren.op.mixin.late;

import cn.taskeren.op.insurance.InsuranceManager;
import gregtech.api.metatileentity.BaseMetaTileEntity;
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/cn/taskeren/op/forge/OP_Mod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object OP_Mod : OP_Logger {
// #en &6&lTaskeren
// #zh &6&lTaskeren(楓)
// #tw &6&lTaskeren(楓)
logger.info("Overpowering " + t("Overpowered_Author_Taskeren") + " !")
logger.info("Overpowering ${t("Overpowered_Author_Taskeren")} ${Tags.VERSION}!")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.util.UUID
/**
* Everything about Insurance is here.
*
* All the machines that explode will be registered here, from [cn.taskeren.op.mixin.Insurance_BaseMetaTileEntity_Mixin].
* All the machines that explode will be registered here, from [cn.taskeren.op.mixin.late.Insurance_BaseMetaTileEntity_Mixin].
* Players will have chances to refund their machines back by costing a bunch of resources like Emeralds.
*
* Players can see their exploded machines using command `/insurance list`. The listed numbers are the MetaTileEntity IDs.
Expand Down
37 changes: 37 additions & 0 deletions src/main/kotlin/cn/taskeren/op/mixin_plugin/OP_LateMixin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@file:Suppress("SpellCheckingInspection")

package cn.taskeren.op.mixin_plugin

import com.gtnewhorizon.gtnhmixins.ILateMixinLoader
import com.gtnewhorizon.gtnhmixins.LateMixin
import net.minecraft.launchwrapper.Launch
import org.apache.logging.log4j.LogManager

@LateMixin
class OP_LateMixin : ILateMixinLoader {

val logger = LogManager.getLogger("OP:LateMixin")
val dev = Launch.blackboard["fml.deobfuscatedEnvironment"] as Boolean

override fun getMixinConfig(): String? {
return "mixins.Overpowered.late.json"
}

override fun getMixins(loadedMods: Set<String>): List<String> {
logger.info("Initializing Late Mixins")
if(dev) {
loadedMods.forEach { logger.info("Loaded Mod: {}", it) }
}

val mixinClasses = mutableListOf<String>()
if("gregtech" in loadedMods) {
mixinClasses += "Insurance_BaseMetaTileEntity_Mixin"
}
if("modularui" in loadedMods) {
mixinClasses += "CrashProof_ModularGui_Mixin"
}

mixinClasses.forEach { logger.info("Applied Mixin: {}", it) }
return mixinClasses
}
}
46 changes: 0 additions & 46 deletions src/main/kotlin/cn/taskeren/op/mixin_plugin/OP_Mixin.kt

This file was deleted.

98 changes: 0 additions & 98 deletions src/main/kotlin/cn/taskeren/op/mixin_plugin/OP_MixinPlugin.kt

This file was deleted.

9 changes: 4 additions & 5 deletions src/main/resources/mixins.Overpowered.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"required": true,
"minVersion": "0.8.3-GTNH",
"package": "cn.taskeren.op.mixin",
"plugin": "cn.taskeren.op.mixin_plugin.OP_MixinPlugin",
"mixins": [
],
"client": [
]
"refmap": "mixins.Overpowered.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}
8 changes: 8 additions & 0 deletions src/main/resources/mixins.Overpowered.late.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"required": true,
"minVersion": "0.8.3-GTNH",
"package": "cn.taskeren.op.mixin.late",
"refmap": "mixins.Overpowered.refmap.json",
"target": "@env(DEFAULT)",
"compatibilityLevel": "JAVA_8"
}

0 comments on commit 5072c47

Please sign in to comment.