SpongePowered / Mixin

Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
MIT License
1.42k stars 193 forks source link

Trying to launch mixin in 1.13 | No mixin host service is available #286

Closed 1zun4 closed 6 years ago

1zun4 commented 6 years ago

Hey,

i currently try to launch mixin in 1.13 with LaunchWrapper... It works fine in my workspace, but if I export my jar and try to launch it with the json... Mixin don't find the mixin service. I didn't found the reason yet. Anyone have a idea, why it don't work?

Launch json

{
   "id":"LiquidBounce1.13",
   "time":"2018-07-18T15:11:46+00:00",
   "releaseTime":"2018-07-18T15:11:46+00:00",
   "type":"release",
   "inheritsFrom":"1.13",
   "jar":"1.13",
   "mainClass":"net.minecraft.launchwrapper.Launch",
   "arguments":{
      "game":[
         "--tweakClass",
         "net.ccbluex.liquidbounce.injection.Tweaker"
      ]
   },
   "libraries":[
      {
         "name":"net.ccbluex:liquidbounce:1.13-b1"
      },
      {
         "name":"net.minecraft:launchwrapper:1.12",
         "serverreq":true
      },
      {
         "name":"org.ow2.asm:asm-all:5.2",
         "url":"http://files.minecraftforge.net/maven/",
         "checksums":[
            "2ea49e08b876bbd33e0a7ce75c8f371d29e1f10a"
         ],
         "serverreq":true,
         "clientreq":true
      }
   ]
}

Tweaker

public class Tweaker implements ITweaker {

    private final List<String> list = new ArrayList<>();

    @Override
    public void acceptOptions(final List<String> args, final File gameDir, final File assetsDir, final String profile) {
        list.addAll(args);

        if(!args.contains("--version") && profile != null)
            list.addAll(Arrays.asList("--version", profile));

        if(!args.contains("--assetDir") && assetsDir != null)
            list.addAll(Arrays.asList("--assetDir", assetsDir.getAbsolutePath()));

        if(!args.contains("--gameDir") && gameDir != null)
            list.addAll(Arrays.asList("--gameDir", gameDir.getAbsolutePath()));
    }

    @Override
    public void injectIntoClassLoader(final LaunchClassLoader classLoader) {
        MixinBootstrap.init();
        Mixins.addConfiguration("mixins.liquidbounce.json");
        MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
    }

    @Override
    public String getLaunchTarget() {
        return "net.minecraft.client.main.Main";
    }

    @Override
    public String[] getLaunchArguments() {
        return this.list.toArray(new String[0]);
    }
}

Exception

20:49:36 | game | Exception in thread "main" org.spongepowered.asm.service.ServiceNotAvailableError: No mixin host service is available
20:49:36 | game | at org.spongepowered.asm.service.MixinService.getServiceInstance(MixinService.java:113)
20:49:36 | game | at org.spongepowered.asm.service.MixinService.getService(MixinService.java:106)
20:49:36 | game | at org.spongepowered.asm.launch.MixinBootstrap.<clinit>(MixinBootstrap.java:77)
20:49:36 | game | at net.ccbluex.liquidbounce.injection.Tweaker.injectIntoClassLoader(Tweaker.java:39)
20:49:36 | game | at net.minecraft.launchwrapper.Launch.launch(Launch.java:115)
20:49:36 | game | at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
Mumfrey commented 6 years ago

LaunchWrapper is not being used for 1.13, work is underway to transition to ModLauncher.

1zun4 commented 6 years ago
public class LaunchService implements ILaunchHandlerService {

    @Override
    public String name() {
        return "liquidbounce";
    }

    @Override
    public Path[] identifyTransformationTargets() {
        return new Path[0];
    }

    @Override
    public Callable<Void> launchService(String[] arguments, ITransformingClassLoader launchClassLoader) {
        return () -> {
            // TODO: Fix exception (org.spongepowered.asm.service.ServiceNotAvailableError: No mixin host service is available)
            MixinBootstrap.init();
            Mixins.addConfiguration("mixins.liquidbounce.json");
            MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);

            // Working fine (from DefaultLaunchHandlerService)
            final Class<?> mcClass = Class.forName("net.minecraft.client.main.Main", true, launchClassLoader.getInstance());
            final Method mcClassMethod = mcClass.getMethod("main", String[].class);
            mcClassMethod.invoke(null, (Object) arguments);
            return null;
        };
    }
}

Same issue with ModLauncher.

Mumfrey commented 6 years ago

ModLauncher support is underway, it's not supported yet.

1zun4 commented 6 years ago

Oh, okay. Do you any ideas how I could use mixin to modify 1.13?

Mumfrey commented 6 years ago

If you do use it on 1.13 you are on your own. If you actually had the common sense to search for the issue you're having you would discover that this question about the service host has been asked and answered already.

You are literally going to put yourself in a position where you're incompatible with everything else for 1.13 though so I would vehemently recommend against it.