org.spongepowered.asm.mixin.Mixins Java Examples

The following examples show how to use org.spongepowered.asm.mixin.Mixins. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MixinProcessor.java    From Mixin with MIT License 6 votes vote down vote up
/**
 * Add configurations from the supplied mixin environment to the configs set
 * 
 * @param environment Environment to query
 */
private void selectConfigs(MixinEnvironment environment) {
    for (Iterator<Config> iter = Mixins.getConfigs().iterator(); iter.hasNext();) {
        Config handle = iter.next();
        try {
            MixinConfig config = handle.get();
            if (config.select(environment)) {
                iter.remove();
                MixinProcessor.logger.log(this.verboseLoggingLevel, "Selecting config {}", config);
                config.onSelect();
                this.pendingConfigs.add(config);
            }
        } catch (Exception ex) {
            MixinProcessor.logger.warn(String.format("Failed to select mixin config: %s", handle), ex);
        }
    }
    
    Collections.sort(this.pendingConfigs);
}
 
Example #2
Source File: MixinProcessor.java    From Mixin with MIT License 6 votes vote down vote up
private List<IMixinErrorHandler> getErrorHandlers(Phase phase) {
    List<IMixinErrorHandler> handlers = new ArrayList<IMixinErrorHandler>();
    
    for (String handlerClassName : Mixins.getErrorHandlerClasses()) {
        try {
            MixinProcessor.logger.info("Instancing error handler class {}", handlerClassName);
            Class<?> handlerClass = this.service.getClassProvider().findClass(handlerClassName, true);
            IMixinErrorHandler handler = (IMixinErrorHandler)handlerClass.newInstance();
            if (handler != null) {
                handlers.add(handler);
            }
        } catch (Throwable th) {
            // skip bad handlers
        }
    }
    
    return handlers;
}
 
Example #3
Source File: OptifabricSetup.java    From OptiFabric with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void run() {
	if(!validateLoaderVersion()) return;
	if(!validateMods()) return;

	try {
		OptifineSetup optifineSetup = new OptifineSetup();
		Pair<File, ClassCache> runtime = optifineSetup.getRuntime();

		//Add the optifine jar to the classpath, as
		ClassTinkerers.addURL(runtime.getLeft().toURI().toURL());

		OptifineInjector injector = new OptifineInjector(runtime.getRight());
		injector.setup();

		optifineRuntimeJar = runtime.getLeft();
	} catch (Throwable e) {
		if(!OptifabricError.hasError()){
			OptifineVersion.jarType = OptifineVersion.JarType.INCOMPATIBE;
			OptifabricError.setError("Failed to load optifine, check the log for more info \n\n " + e.getMessage());
		}
		throw new RuntimeException("Failed to setup optifine", e);
	}

	if(FabricLoader.getInstance().isModLoaded("fabric-renderer-indigo")){
		validateIndigoVersion();
		Mixins.addConfiguration("optifabric.indigofix.mixins.json");
	}

	Mixins.addConfiguration("optifabric.optifine.mixins.json");
}
 
Example #4
Source File: MixinLoader.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public MixinLoader() {
    System.out.println("[LiquidBounce] Injecting with IFMLLoadingPlugin.");

    MixinBootstrap.init();
    Mixins.addConfiguration("liquidbounce.forge.mixins.json");
    MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
}
 
Example #5
Source File: TweakerMixinLoader.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
    System.out.println("[LiquidBounce] Injecting with TweakerMixinLoader.");

    MixinBootstrap.init();
    Mixins.addConfiguration("liquidbounce.vanilla.mixins.json");
    MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);

    classLoader.registerTransformer(AbstractJavaLinkerTransformer.class.getName());
}
 
Example #6
Source File: HyperiumTweaker.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
    Hyperium.LOGGER.info("[Addons] Loading Addons...");

    Hyperium.LOGGER.info("Initialising Bootstraps...");
    MixinBootstrap.init();
    AddonBootstrap.INSTANCE.init();

    Hyperium.LOGGER.info("Applying transformers...");

    MixinEnvironment environment = MixinEnvironment.getDefaultEnvironment();
    Mixins.addConfiguration("mixins.hyperium.json");

    if (isRunningOptifine) {
        environment.setObfuscationContext("notch"); // Switch's to notch mappings
    }

    if (environment.getObfuscationContext() == null) {
        environment.setObfuscationContext("notch"); // Switch's to notch mappings
    }

    try {
        classLoader.addURL(new File(System.getProperty("java.home"), "lib/ext/nashorn.jar").toURI().toURL());
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }

    environment.setSide(MixinEnvironment.Side.CLIENT);
}
 
Example #7
Source File: VanillaFixLoadingPlugin.java    From VanillaFix with MIT License 5 votes vote down vote up
private static void initMixin() {
    MixinBootstrap.init();

    if (config.bugFixes) Mixins.addConfiguration("mixins.vanillafix.bugs.json");
    if (config.crashFixes) Mixins.addConfiguration("mixins.vanillafix.crashes.json");
    if (config.profiler) Mixins.addConfiguration("mixins.vanillafix.profiler.json");
    if (config.textureFixes) Mixins.addConfiguration("mixins.vanillafix.textures.json");
    if (config.modSupport) Mixins.addConfiguration("mixins.vanillafix.modsupport.json");
    if (config.blockStates) Mixins.addConfiguration("mixins.vanillafix.blockstates.json");
    if (config.dynamicResources) Mixins.addConfiguration("mixins.vanillafix.dynamicresources.json");
}
 
Example #8
Source File: MixinLoaderForge.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
public MixinLoaderForge() {
    System.out.println("\n\n\nValkyrien Skies mixin init\n\n");
    MixinBootstrap.init();
    Mixins.addConfiguration("mixins.valkyrienskies.json");
    MixinEnvironment.getDefaultEnvironment().setObfuscationContext("searge");
    System.out.println(MixinEnvironment.getDefaultEnvironment().getObfuscationContext());
}
 
Example #9
Source File: MixinPlatformManager.java    From Mixin with MIT License 5 votes vote down vote up
/**
 * Add a config from a jar manifest source or the command line. Supports
 * config declarations in the form <tt>filename.json</tt> or alternatively
 * <tt>filename.json&#064;PHASE</tt> where <tt>PHASE</tt> is a
 * case-sensitive string token representing an environment phase.
 * 
 * @param config config resource name, does not require a leading /
 */
final void addConfig(String config) {
    if (config.endsWith(".json")) {
        MixinPlatformManager.logger.debug("Registering mixin config: {}", config);
        Mixins.addConfiguration(config);
    } else if (config.contains(".json@")) {
        throw new MixinError("Setting config phase via manifest is no longer supported: " + config + ". Specify target in config instead");
    }
}
 
Example #10
Source File: MixinProcessor.java    From Mixin with MIT License 5 votes vote down vote up
private void checkSelect(MixinEnvironment environment) {
    if (this.currentEnvironment != environment) {
        this.select(environment);
        return;
    }
    
    int unvisitedCount = Mixins.getUnvisitedCount();
    if (unvisitedCount > 0 && this.transformedCount == 0) {
        this.select(environment);
    }
}
 
Example #11
Source File: MixinLoader.java    From Happy_MinecraftClient with GNU General Public License v3.0 4 votes vote down vote up
public MixinLoader() {
    MixinBootstrap.init();
    Mixins.addConfiguration("mixins.SexLingzhou.json");
    MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
}
 
Example #12
Source File: MixinLoader.java    From ClientBase with MIT License 4 votes vote down vote up
public MixinLoader() {
    MixinBootstrap.init();
    Mixins.addConfiguration("mixins.clientbase.json");
    MixinEnvironment.getDefaultEnvironment().setSide(MixinEnvironment.Side.CLIENT);
}
 
Example #13
Source File: FabricMixinBootstrap.java    From fabric-loader with Apache License 2.0 4 votes vote down vote up
static void addConfiguration(String configuration) {
	Mixins.addConfiguration(configuration);
}
 
Example #14
Source File: Tweaker.java    From BoundingBoxOutlineReloaded with MIT License 4 votes vote down vote up
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
    MixinBootstrap.init();
    MixinEnvironment.getDefaultEnvironment().setSide(isClient() ? MixinEnvironment.Side.CLIENT : MixinEnvironment.Side.SERVER);
    Mixins.addConfiguration("mixins.bbor.json");
}
 
Example #15
Source File: PLSetup.java    From Production-Line with MIT License 4 votes vote down vote up
@Override
public Void call() throws Exception {
    MixinBootstrap.init();
    Mixins.addConfiguration("mixins.productionline.core.json");
    return null;
}