org.spongepowered.asm.launch.MixinBootstrap Java Examples

The following examples show how to use org.spongepowered.asm.launch.MixinBootstrap. 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: MixinEnvironment.java    From Mixin with MIT License 6 votes vote down vote up
MixinEnvironment(Phase phase) {
    this.service = MixinService.getService();
    this.phase = phase;
    this.configsKey = Keys.of(GlobalProperties.Keys.CONFIGS + "." + this.phase.name.toLowerCase(Locale.ROOT));
    
    // Sanity check
    Object version = this.getVersion();
    if (version == null || !MixinBootstrap.VERSION.equals(version)) {
        throw new MixinException("Environment conflict, mismatched versions or you didn't call MixinBootstrap.init()");
    }
    
    // More sanity check
    this.service.checkEnv(this);
    
    this.options = new boolean[Option.values().length];
    for (Option option : Option.values()) {
        this.options[option.ordinal()] = option.getBooleanValue();
    }
    
    if (MixinEnvironment.showHeader) {
        MixinEnvironment.showHeader = false;
        this.printHeader(version);
    }
}
 
Example #2
Source File: AnnotatedMixins.java    From Mixin with MIT License 6 votes vote down vote up
/**
 * Private constructor, get instances using {@link #getMixinsForEnvironment}
 */
private AnnotatedMixins(ProcessingEnvironment processingEnv) {
    this.env = this.detectEnvironment(processingEnv);
    this.processingEnv = processingEnv;
    
    MessageRouter.setMessager(processingEnv.getMessager());

    String pluginVersion = this.checkPluginVersion(this.getOption(SupportedOptions.PLUGIN_VERSION));
    String pluginVersionString = pluginVersion != null ? String.format(" (MixinGradle Version=%s)", pluginVersion) : "";
    this.printMessage(Kind.NOTE, "SpongePowered MIXIN Annotation Processor Version=" + MixinBootstrap.VERSION + pluginVersionString);

    this.targets = this.initTargetMap();
    this.obf = new ObfuscationManager(this);
    this.obf.init();

    this.validators = ImmutableList.<IMixinValidator>of(
        new ParentValidator(this),
        new TargetValidator(this)
    );
    
    this.initTokenCache(this.getOption(SupportedOptions.TOKENS));
}
 
Example #3
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 #4
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 #5
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 #6
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 #7
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 #8
Source File: FabricMixinBootstrap.java    From fabric-loader with Apache License 2.0 5 votes vote down vote up
public static void init(EnvType side, FabricLoader loader) {
	if (initialized) {
		throw new RuntimeException("FabricMixinBootstrap has already been initialized!");
	}

	if (FabricLauncherBase.getLauncher().isDevelopment()) {
		MappingConfiguration mappingConfiguration = FabricLauncherBase.getLauncher().getMappingConfiguration();
		TinyTree mappings = mappingConfiguration.getMappings();

		if (mappings != null) {
			List<String> namespaces = mappings.getMetadata().getNamespaces();
			if (namespaces.contains("intermediary") && namespaces.contains(mappingConfiguration.getTargetNamespace())) {
				System.setProperty("mixin.env.remapRefMap", "true");

				try {
					MixinIntermediaryDevRemapper remapper = new MixinIntermediaryDevRemapper(mappings, "intermediary", mappingConfiguration.getTargetNamespace());
					MixinEnvironment.getDefaultEnvironment().getRemappers().add(remapper);
					LOGGER.info("Loaded Fabric development mappings for mixin remapper!");
				} catch (Exception e) {
					LOGGER.error("Fabric development environment setup error - the game will probably crash soon!");
					e.printStackTrace();
				}
			}
		}
	}

	MixinBootstrap.init();
	getMixinConfigs(loader, side).forEach(FabricMixinBootstrap::addConfiguration);
	initialized = true;
}
 
Example #9
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 #10
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 #11
Source File: FabricTweaker.java    From fabric-loader with Apache License 2.0 4 votes vote down vote up
@Override
public void injectIntoClassLoader(LaunchClassLoader launchClassLoader) {
	isDevelopment = Boolean.parseBoolean(System.getProperty("fabric.development", "false"));
	Launch.blackboard.put("fabric.development", isDevelopment);
	setProperties(Launch.blackboard);

	this.launchClassLoader = launchClassLoader;
	launchClassLoader.addClassLoaderExclusion("org.objectweb.asm.");
	launchClassLoader.addClassLoaderExclusion("org.spongepowered.asm.");
	launchClassLoader.addClassLoaderExclusion("net.fabricmc.loader.");

	launchClassLoader.addClassLoaderExclusion("net.fabricmc.api.Environment");
	launchClassLoader.addClassLoaderExclusion("net.fabricmc.api.EnvType");

	GameProvider provider = new MinecraftGameProvider();
	provider.acceptArguments(arguments);

	if (!provider.locateGame(getEnvironmentType(), launchClassLoader)) {
		throw new RuntimeException("Could not locate Minecraft: provider locate failed");
	}

	@SuppressWarnings("deprecation")
	FabricLoader loader = FabricLoader.INSTANCE;
	loader.setGameProvider(provider);
	loader.load();
	loader.freeze();

	launchClassLoader.registerTransformer("net.fabricmc.loader.launch.FabricClassTransformer");

	if (!isDevelopment) {
		// Obfuscated environment
		Launch.blackboard.put("fabric.development", false);
		try {
			String target = getLaunchTarget();
			URL loc = launchClassLoader.findResource(target.replace('.', '/') + ".class");
			JarURLConnection locConn = (JarURLConnection) loc.openConnection();
			File jarFile = UrlUtil.asFile(locConn.getJarFileURL());
			if (!jarFile.exists()) {
				throw new RuntimeException("Could not locate Minecraft: " + jarFile.getAbsolutePath() + " not found");
			}

			FabricLauncherBase.deobfuscate(provider.getGameId(), provider.getNormalizedGameVersion(), provider.getLaunchDirectory(), jarFile.toPath(), this);
		} catch (IOException | UrlConversionException e) {
			throw new RuntimeException("Failed to deobfuscate Minecraft!", e);
		}
	}

	FabricLoader.INSTANCE.getAccessWidener().loadFromMods();

	MinecraftGameProvider.TRANSFORMER.locateEntrypoints(this);

	// Setup Mixin environment
	MixinBootstrap.init();
	FabricMixinBootstrap.init(getEnvironmentType(), FabricLoader.INSTANCE);
	MixinEnvironment.getDefaultEnvironment().setSide(getEnvironmentType() == EnvType.CLIENT ? MixinEnvironment.Side.CLIENT : MixinEnvironment.Side.SERVER);

	EntrypointUtils.invoke("preLaunch", PreLaunchEntrypoint.class, PreLaunchEntrypoint::onPreLaunch);
}
 
Example #12
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 #13
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;
}
 
Example #14
Source File: EnvironmentStateTweaker.java    From Mixin with MIT License 4 votes vote down vote up
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
    MixinBootstrap.getPlatform().inject();
}