diff options
author | Linnea Gräf <nea@nea.moe> | 2025-01-08 14:38:48 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2025-01-08 14:38:48 +0100 |
commit | c59693dff859845e43dde361a61ef98a84f7490f (patch) | |
tree | 95e525908344cc10c6a5f5a1673c191510e1aef0 | |
parent | 16bba767b55eca4531e89f3ac70fdf0f16573913 (diff) | |
download | LocalTransactionLedger-c59693dff859845e43dde361a61ef98a84f7490f.tar.gz LocalTransactionLedger-c59693dff859845e43dde361a61ef98a84f7490f.tar.bz2 LocalTransactionLedger-c59693dff859845e43dde361a61ef98a84f7490f.zip |
fix: Classes and resources being entangled
-rw-r--r-- | build.gradle.kts | 12 | ||||
-rw-r--r-- | src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java | 66 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt (renamed from src/main/java/moe/nea/ledger/events/RegistrationFinishedEvent.kt) | 0 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.java | 8 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt | 4 |
5 files changed, 71 insertions, 19 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 2fbbd99..a6ee08c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -59,6 +59,7 @@ loom { log4jConfigs.from(file("log4j2.xml")) launchConfigs { "client" { + property("ledger.bonusresourcemod", sourceSets.main.get().output.resourcesDir!!.absolutePath) property("mixin.debug", "true") arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") arg("--tweakClass", "io.github.notenoughupdates.moulconfig.tweaker.DevelopmentResourceTweaker") @@ -82,16 +83,6 @@ loom { } } -tasks.compileJava { - dependsOn(tasks.processResources) -} - -sourceSets.main { - output.setResourcesDir(sourceSets.main.flatMap { it.java.classesDirectory }) - java.srcDir(layout.projectDirectory.dir("src/main/kotlin")) - kotlin.destinationDirectory.set(java.destinationDirectory) -} - allprojects { repositories { mavenCentral() @@ -229,7 +220,6 @@ val remapJar by tasks.named<net.fabricmc.loom.task.RemapJarTask>("remapJar") { tasks.jar { archiveClassifier.set("without-deps") - dependsOn(tasks.processResources) // Why is this needed? destinationDirectory.set(layout.buildDirectory.dir("badjars")) } diff --git a/src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java b/src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java new file mode 100644 index 0000000..e925d18 --- /dev/null +++ b/src/main/java/moe/nea/ledger/mixin/RegisterModResourcesPatch.java @@ -0,0 +1,66 @@ +package moe.nea.ledger.mixin; + +import com.google.common.eventbus.EventBus; +import net.minecraftforge.fml.client.FMLFileResourcePack; +import net.minecraftforge.fml.common.DummyModContainer; +import net.minecraftforge.fml.common.LoadController; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.ModMetadata; +import net.minecraftforge.fml.common.discovery.ASMDataTable; +import net.minecraftforge.fml.common.discovery.ContainerType; +import net.minecraftforge.fml.common.discovery.ModCandidate; +import net.minecraftforge.fml.common.discovery.ModDiscoverer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import java.io.File; +import java.util.Collections; +import java.util.List; + +@Mixin(value = ModDiscoverer.class, remap = false) +public class RegisterModResourcesPatch { + @Shadow + private List<ModCandidate> candidates; + + @Inject(method = "identifyMods", at = @At("HEAD"), remap = false) + private void addCandidate(CallbackInfoReturnable<List<ModContainer>> cir) { + String bonusResourceMod = System.getProperty("ledger.bonusresourcemod"); + if (bonusResourceMod == null) return; + File file = new File(bonusResourceMod); + if (!file.isDirectory()) return; + ModMetadata modMetadata = new ModMetadata(); + modMetadata.modId = "ledger-bonus"; + modMetadata.name = "Ledger Bonus Resources"; + modMetadata.autogenerated = true; + ModContainer container = new DummyModContainer(modMetadata) { + @Override + public Object getMod() { + return new Object(); + } + + @Override + public boolean registerBus(EventBus bus, LoadController controller) { + return true; + } + + @Override + public File getSource() { + return file; + } + + @Override + public Class<?> getCustomResourcePackClass() { + return FMLFileResourcePack.class; + } + }; + candidates.add(new ModCandidate(file, file, ContainerType.DIR) { + @Override + public List<ModContainer> explore(ASMDataTable table) { + return Collections.singletonList(container); + } + }); + } +} diff --git a/src/main/java/moe/nea/ledger/events/RegistrationFinishedEvent.kt b/src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt index d36e0c7..d36e0c7 100644 --- a/src/main/java/moe/nea/ledger/events/RegistrationFinishedEvent.kt +++ b/src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt diff --git a/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.java b/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.java deleted file mode 100644 index f432130..0000000 --- a/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.java +++ /dev/null @@ -1,8 +0,0 @@ -package moe.nea.ledger.utils; - -import kotlin.annotation.AnnotationRetention; -import kotlin.annotation.Retention; - -@Retention(AnnotationRetention.BINARY) -public @interface NoSideEffects { -} diff --git a/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt b/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt new file mode 100644 index 0000000..9b0e7a3 --- /dev/null +++ b/src/main/kotlin/moe/nea/ledger/utils/NoSideEffects.kt @@ -0,0 +1,4 @@ +package moe.nea.ledger.utils + +@Retention(AnnotationRetention.BINARY) +annotation class NoSideEffects |