本文整理汇总了Java中net.minecraft.launchwrapper.Launch类的典型用法代码示例。如果您正苦于以下问题:Java Launch类的具体用法?Java Launch怎么用?Java Launch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Launch类属于net.minecraft.launchwrapper包,在下文中一共展示了Launch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLaunchArguments
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@Override
public String[] getLaunchArguments() {
ArrayList args = (ArrayList)Launch.blackboard.get("ArgumentList");
if(args.isEmpty()) args.addAll(this.args);
this.args = null;
return new String[0];
}
示例2: convert
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@NotNull
@SuppressWarnings("unchecked")
static <T extends IClassTransformer> Class<T> convert(@NotNull Class<? extends OrionTransformer> transformer) {
if(Arrays.asList(transformer.getInterfaces()).contains(IClassTransformer.class))
return (Class<T>) transformer; /* no-op */
// Orion transformer name
String rawTransformerName = transformer.getName().replace('.', '/');
// New wrapper class name
String newWrapperName = getNewName(transformer);
// Start generating new TransformerWrapper
ClassReader cr = new ClassReader(TW_DATA);
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
ClassNode cn = new ClassNode();
cr.accept(cn, 0);
cn.accept(new WrapperGenerator(cw, TW_TYPE.getInternalName(), newWrapperName.replace('.', '/'), rawTransformerName));
return requireNonNull((Class<T>) ClassLoaderTools.defineClass(Launch.classLoader, newWrapperName, cw.toByteArray()));
}
示例3: onPreInit
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@Mod.EventHandler
public void onPreInit(FMLPreInitializationEvent event)
{
try
{
instance = this;
this.logger = event.getModLog();
this.conf = new File(Launch.minecraftHome, "authlibloginhelper-accounts.json");
if (this.conf.createNewFile())
{
String path = this.conf.getAbsolutePath();
this.logger.info("AuthlibLoginHelper: Successfully created " + path);
}
MinecraftForge.EVENT_BUS.register(this);
}
catch (IOException e)
{
throw Throwables.propagate(e);
}
}
示例4: transform
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@Override
public byte[] transform(String name, String transformedName, byte[] classBuffer) {
String internalClassName = name.replace('.', '/');
for (ClassFileTransformer transformer : AuthlibInjectorTweaker.transformers) {
byte[] result = null;
try {
result = transformer.transform(Launch.classLoader, internalClassName, null, null, classBuffer);
} catch (IllegalClassFormatException e) {
log("exception while invoking {0}: {1}", transformer, e);
e.printStackTrace();
}
if (result != null) {
classBuffer = result;
}
}
return classBuffer;
}
示例5: checkAddClass
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
private void checkAddClass(String resource) {
try {
String classname = resource.replace(".class", "").replace("\\", ".").replace("/", ".");
byte[] bytes = Launch.classLoader.getClassBytes(classname);
if (bytes == null)
return;
ClassNode cnode = ASMHelper.createClassNode(bytes);
for (String superclass : superclasses)
if (!cnode.interfaces.contains(superclass) && !cnode.superName.equals(superclass))
return;
addClass(classname);
} catch (IOException e) {
CodeChickenCorePlugin.logger.error("Unable to load class: " + resource, e);
}
}
示例6: evaluate
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@Override
public void evaluate() throws Throwable {
startGame();
waitForGameHasBeenStarted();
// Make sure to get the "right" WolTestEnvironment (that has been loaded by Minecraft's
// classloader)
Class<?> cls = Launch.classLoader.findClass(WolTestEnvironment.class.getName());
try {
Method m = cls.getMethod("runTest", String.class, String.class);
Object result = m.invoke(cls, method.getDeclaringClass().getName(), method.getName());
if (result != null) {
throw (Throwable) result;
}
} catch (Throwable e) {
e.printStackTrace(System.out);
throw e;
}
}
示例7: parseModList
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
static void parseModList(File minecraftDirectory)
{
FMLRelaunchLog.fine("Attempting to load commandline specified mods, relative to %s", minecraftDirectory.getAbsolutePath());
mcDirectory = minecraftDirectory;
@SuppressWarnings("unchecked")
Map<String,String> args = (Map<String, String>) Launch.blackboard.get("launchArgs");
String listFile = args.get("--modListFile");
if (listFile != null)
{
parseListFile(listFile);
}
String extraMods = args.get("--mods");
if (extraMods != null)
{
String[] split = extraMods.split(",");
for (String modFile : split)
{
tryAddFile(modFile, null, modFile);
}
}
}
示例8: getCommonSuperClass
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@Override
protected String getCommonSuperClass(String type1, String type2) {
Class<?> c, d;
ClassLoader classLoader = Launch.classLoader;
try {
c = Class.forName(type1.replace('/', '.'), false, classLoader);
d = Class.forName(type2.replace('/', '.'), false, classLoader);
} catch (Exception e) {
throw new RuntimeException(e.toString());
}
if (c.isAssignableFrom(d)) {
return type1;
}
if (d.isAssignableFrom(c)) {
return type2;
}
if (c.isInterface() || d.isInterface()) {
return "java/lang/Object";
} else {
do {
c = c.getSuperclass();
} while (!c.isAssignableFrom(d));
return c.getName().replace('.', '/');
}
}
示例9: injectIntoClassLoader
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@Override
public void injectIntoClassLoader(LaunchClassLoader classLoader) {
// Mixin system already loaded early so don't load twice
@SuppressWarnings("unchecked")
List<String> tweakClasses = (List<String>) Launch.blackboard.get("TweakClasses");
boolean duplicateMixin = false;
while (tweakClasses.remove("org.spongepowered.asm.launch.MixinTweaker")) {
duplicateMixin = true;
}
// Another mod is using mixin system
if (duplicateMixin) {
try {
// This feels wrong but it works
// For some reason 'register' gets called before 'preInit'
// even though MixinTweaker calls preInit in constructor
Class<?> c = Class.forName("org.spongepowered.asm.launch.MixinBootstrap");
Field init = c.getDeclaredField("initialised");
init.setAccessible(true);
init.set(null, true);
tweakClasses.add("org.spongepowered.asm.launch.MixinTweaker");
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例10: searchClassPath
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
/**
* Registers the class path mods.
*
* @param duplicates the duplicates
* @param modList the unsorted mods
* @throws Exception the exception
*/
private void searchClassPath() throws Exception {
URL roots;
Enumeration<URL> metas = Launch.classLoader.getResources("META-INF");
while (metas.hasMoreElements()) {
roots = metas.nextElement();
File root = new File(roots.getPath());
File[] files = root.listFiles();
if (files != null) {
for (File file : files) {
if (file.getName().equals("MANIFEST.MF") || (OMLStrippableTransformer.getEnvironment() == Environment.DEVELOPMENT && file.getName().endsWith(".MF"))) {
FileInputStream stream = new FileInputStream(file);
registerMod(file.getParentFile().getParentFile(), new Manifest(stream));
stream.close();
} else if (file.getName().endsWith(".at")) {
OMLAccessTransformer.loadAccessTransformers(FileUtils.readLines(file));
}
}
}
}
}
示例11: getMainClass
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
public Class<?> getMainClass() {
if (classString == null) {
return null;
}
if (this.mainClass == null) {
try {
this.mainClass = Class.forName(this.classString, true, Launch.classLoader);
if (!Mod.class.isAssignableFrom(mainClass)) {
throw new RuntimeException("Mod class '" + mainClass.getName() + "' for mod '" + name + " does not implement " + Mod.class.getName());
}
} catch (ClassNotFoundException e) {
if (e.getCause() instanceof RuntimeException && e.getCause().getMessage().equals("Loading class " + classString + " on wrong side " + OpenModLoader.getSidedHandler().getSide())) {
throw new RuntimeException("Mod '" + getName() + " is using @Strippable(side = X) on its main class. Use the Side field in the manifest instead!", e);
}
throw new RuntimeException("Could not find mod class '" + classString + "' for mod '" + name + '\'', e);
}
}
return mainClass;
}
示例12: scan
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@Override
public Iterable<ResourceLocation> scan(String name) {
Set<ResourceLocation> resources = Sets.newHashSet();
for (Path dir : modDirectories) {
resources.addAll(getResourcesFromDir(dir, name));
}
for (Path resPack : modResourcePacks) {
resources.addAll(scanZip(resPack, name));
}
for (final URL element : Launch.classLoader.getSources()) {
if (!element.getProtocol().equals("file"))
continue;
try {
Path elemPath = Paths.get(element.toURI());
if (Files.isDirectory(elemPath)) {
resources.addAll(getResourcesFromDir(elemPath, name));
} else {
resources.addAll(scanZip(elemPath, name));
}
} catch (URISyntaxException e) {
logger.debug("could not scan an element of the classpath");
}
}
return resources;
}
示例13: addConfiguration
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
public static void addConfiguration(String... configs) {
for (String config : configs) {
MixinConfig mixinConfig = GSON.fromJson(new InputStreamReader(Launch.classLoader.getResourceAsStream(config)), MixinConfig.class);
for (String mixin : mixinConfig.getMixins()) {
try {
final CtClass mixinClass = ClassPool.getDefault().get(mixinConfig.getPackageName() + "." + mixin);
if (!mixinClass.hasAnnotation(Mixin.class)) continue;;
final Mixin mixinAnnot = (Mixin) mixinClass.getAnnotation(Mixin.class);
final List<CtClass> mixins = MIXINS.getOrDefault(mixinClass.getName(), Lists.newArrayList());
mixins.add(mixinClass);
MIXINS.put(mixinAnnot.value().getName(), mixins);
} catch (NotFoundException | ClassNotFoundException e) {
e.printStackTrace();
}
}
}
}
示例14: launch
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
protected void launch(String[] args) throws Throwable {
Class<GradleStartCommon> common = GradleStartCommon.class;
System.setProperty("net.minecraftforge.gradle.GradleStart.srgDir", Tool.<File>$(common, "SRG_DIR").getCanonicalPath());
System.setProperty("net.minecraftforge.gradle.GradleStart.srg.notch-srg", Tool.<File>$(common, "SRG_NOTCH_SRG").getCanonicalPath());
System.setProperty("net.minecraftforge.gradle.GradleStart.srg.notch-mcp", Tool.<File>$(common, "SRG_NOTCH_MCP").getCanonicalPath());
System.setProperty("net.minecraftforge.gradle.GradleStart.srg.srg-mcp", Tool.<File>$(common, "SRG_SRG_MCP").getCanonicalPath());
System.setProperty("net.minecraftforge.gradle.GradleStart.srg.mcp-srg", Tool.<File>$(common, "SRG_MCP_SRG").getCanonicalPath());
System.setProperty("net.minecraftforge.gradle.GradleStart.srg.mcp-notch", Tool.<File>$(common, "SRG_MCP_NOTCH").getCanonicalPath());
System.setProperty("net.minecraftforge.gradle.GradleStart.csvDir", Tool.<File>$(common, "CSV_DIR").getCanonicalPath());
setDefaultArguments($(this, "argMap"));
$(this, "parseArgs", args);
preLaunch($(this, "argMap"), $(this, "extras"));
System.setProperty("fml.ignoreInvalidMinecraftCertificates", "true");
searchCoremods(this);
args = $(this, "getArgs");
$(this, "argMap<", null);
$(this, "extras<", null);
System.gc();
$("L" + getBounceClass(), "new");
Launch.blackboard.put("Tweaks", Lists.newArrayList());
$("L" + getBounceClass(), "main", args);
}
示例15: Meddle
import net.minecraft.launchwrapper.Launch; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Meddle()
{
// Prevent classloader collisions, mostly due to keeping
// the deprecated DynamicMappings class.
Launch.classLoader.addClassLoaderExclusion("org.objectweb.asm.");
blacklistedTweaks.add(Meddle.class.getName());
// Launchwrapper adds the package without a period on the end, which
// covers any similarly-named packages. We could solve by putting
// Meddle's tweak class in a deeper package, but this works too
// while maintaining backwards compatibility.
try {
Field exceptionsField = LaunchClassLoader.class.getDeclaredField("classLoaderExceptions");
exceptionsField.setAccessible(true);
classloaderExceptions = (Set<String>) exceptionsField.get(Launch.classLoader);
} catch (Exception e) { e.printStackTrace(); }
classloaderExceptions.remove("net.fybertech.meddle");
classloaderExceptions.add("net.fybertech.meddle.");
}