diff options
author | Linnea Gräf <nea@nea.moe> | 2024-02-22 23:32:11 +0100 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-02-22 23:32:11 +0100 |
commit | a8a87765885905b603a9c121ed5260da51ae3a77 (patch) | |
tree | dcbe2349b3c7e3dd1566af871e6f57e431461d75 | |
parent | aef074886b587745bd814fe965d55e7b4cf11a07 (diff) | |
download | Kowalski-a8a87765885905b603a9c121ed5260da51ae3a77.tar.gz Kowalski-a8a87765885905b603a9c121ed5260da51ae3a77.tar.bz2 Kowalski-a8a87765885905b603a9c121ed5260da51ae3a77.zip |
-rw-r--r-- | build.gradle.kts | 3 | ||||
-rw-r--r-- | src/main/java/moe/nea/kowalski/init/EventClassTransformer.java | 1 | ||||
-rw-r--r-- | src/main/java/moe/nea/kowalski/init/KowalskiTweaker.java | 23 | ||||
-rw-r--r-- | src/main/kotlin/moe/nea/kowalski/Kowalski.kt | 6 | ||||
-rw-r--r-- | src/main/resources/mcmod.info | 4 |
5 files changed, 26 insertions, 11 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 018de40..b615a51 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -30,7 +30,6 @@ loom { // If you don't want mixins, remove these lines property("mixin.debug", "true") property("asmhelper.verbose", "true") - arg("--tweakClass", "org.spongepowered.asm.launch.MixinTweaker") arg("--tweakClass", "moe.nea.kowalski.init.KowalskiTweaker") } } @@ -108,7 +107,7 @@ tasks.withType(Jar::class) { this["ForceLoadAsMod"] = "true" // If you don't want mixins, remove these lines - this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker" + this["TweakClass"] = "moe.nea.kowalski.init.KowalskiTweaker" this["MixinConfigs"] = "mixins.$modid.json" } } diff --git a/src/main/java/moe/nea/kowalski/init/EventClassTransformer.java b/src/main/java/moe/nea/kowalski/init/EventClassTransformer.java index a80a5b5..c28116b 100644 --- a/src/main/java/moe/nea/kowalski/init/EventClassTransformer.java +++ b/src/main/java/moe/nea/kowalski/init/EventClassTransformer.java @@ -35,6 +35,7 @@ public class EventClassTransformer implements IClassTransformer { continue; } method.instructions.insert(insn, buildCallKowalski()); + break; } } diff --git a/src/main/java/moe/nea/kowalski/init/KowalskiTweaker.java b/src/main/java/moe/nea/kowalski/init/KowalskiTweaker.java index 4cb836c..5af17ee 100644 --- a/src/main/java/moe/nea/kowalski/init/KowalskiTweaker.java +++ b/src/main/java/moe/nea/kowalski/init/KowalskiTweaker.java @@ -1,20 +1,41 @@ package moe.nea.kowalski.init; import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.LaunchClassLoader; +import net.minecraftforge.fml.relauncher.CoreModManager; +import org.spongepowered.asm.launch.MixinBootstrap; import java.io.File; +import java.net.URISyntaxException; +import java.net.URL; import java.util.List; public class KowalskiTweaker implements ITweaker { @Override public void acceptOptions(List<String> args, File gameDir, File assetsDir, String profile) { +// ((List<String>) Launch.blackboard.get("TweakClasses")).add("org.spongepowered.asm.launch.MixinTweaker"); + URL location = KowalskiTweaker.class.getProtectionDomain().getCodeSource().getLocation(); + if (location == null) return; + if (!"file".equals(location.getProtocol())) return; + try { + MixinBootstrap.getPlatform().addContainer(location.toURI()); + String file = new File(location.toURI()).getName(); + CoreModManager.getIgnoredMods().remove(file); + CoreModManager.getReparseableCoremods().add(file); + } catch (URISyntaxException e) { + System.err.println("Kowalski could not re-add itself as mod."); + e.printStackTrace(); + } + } + static { + Launch.classLoader.registerTransformer("moe.nea.kowalski.init.EventClassTransformer"); } @Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { -classLoader.registerTransformer("moe.nea.kowalski.init.EventClassTransformer"); + } @Override diff --git a/src/main/kotlin/moe/nea/kowalski/Kowalski.kt b/src/main/kotlin/moe/nea/kowalski/Kowalski.kt index 2bede19..68c69ec 100644 --- a/src/main/kotlin/moe/nea/kowalski/Kowalski.kt +++ b/src/main/kotlin/moe/nea/kowalski/Kowalski.kt @@ -35,12 +35,6 @@ class Kowalski { } - @SubscribeEvent - fun cancelMessages(event: ClientChatReceivedEvent) { - if (event.message.unformattedText.contains("verboten")) - event.isCanceled = true - } - @Mod.EventHandler fun init(event: FMLInitializationEvent) { ClientCommandHandler.instance.registerCommand(KowalskiCommand) diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index ab6d5dd..42c934f 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -1,8 +1,8 @@ [ { "modid": "${modid}", - "name": "Xample Mod", - "description": "A mod that is used as an example.", + "name": "Kowalski", + "description": "Analyse stuff", "version": "${version}", "mcversion": "${mcversion}", "url": "https://github.com/romangraef/Forge1.8.9Template/", |