当前位置: 首页>>代码示例>>Java>>正文


Java Launcher类代码示例

本文整理汇总了Java中net.minecraft.Launcher的典型用法代码示例。如果您正苦于以下问题:Java Launcher类的具体用法?Java Launcher怎么用?Java Launcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Launcher类属于net.minecraft包,在下文中一共展示了Launcher类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import net.minecraft.Launcher; //导入依赖的package包/类
public static void main(String[] args) {
	String username = args[0];
	String sessionid = args[1];
	String serverName = args[2];
	File instPath = new File(args[3]);
	File lwjglPath = new File(args[4]);
	int width = Integer.parseInt(args[6]);
	int height = Integer.parseInt(args[7]);
	String serverAddress = args[8];
	boolean doConnect = Boolean.parseBoolean(args[9]);
	ImageIcon icon = null;
	try {
		icon = new ImageIcon(new URL(args[5]));
	} catch (MalformedURLException e) {
		System.out.println("No valid icon URL specified in server pack");
	} catch (IndexOutOfBoundsException ignored) {}
	if (icon == null) { icon = new ImageIcon(Launcher.class.getResource("/minecraft.png")); }

	MinecraftFrame me = new MinecraftFrame("MCUpdater - " + serverName, icon);
	Dimension windowSize = new Dimension(width, height); //new Dimension(1280, 720)
	me.launch(instPath, lwjglPath, username, sessionid, serverAddress, windowSize, doConnect);
}
 
开发者ID:MCUpdater,项目名称:MCU-Launcher,代码行数:23,代码来源:MinecraftFrame.java

示例2: launch

import net.minecraft.Launcher; //导入依赖的package包/类
public void launch(File instance, File lwjgl, String username, String sessionid, String serverAddress, Dimension windowSize, boolean doConnect) {
	try {
		URI address;
		String port;
		address = new URI("my://" + serverAddress);
		if (address.getPort() != -1) {
			port = Integer.toString(address.getPort());
		} else {
			port = Integer.toString(25565);
		}
		applet = new Launcher(instance, lwjgl, username, sessionid, address.getHost(), port, doConnect);
		System.setProperty("minecraft.applet.TargetDirectory", instance.toString());
		System.setProperty("org.lwjgl.librarypath", new File(lwjgl, "natives").getAbsolutePath());
		System.setProperty("net.java.games.input.librarypath", new File(lwjgl, "natives").getAbsolutePath());
		this.add(applet);
		applet.setPreferredSize(windowSize);
		this.pack();
		this.setLocationRelativeTo(null);
		this.setResizable(true);
		validate();
		applet.init();
		applet.start();
		setVisible(true);

	} catch (URISyntaxException e) {
		e.printStackTrace();
	}

}
 
开发者ID:MCUpdater,项目名称:MCU-Launcher,代码行数:30,代码来源:MinecraftFrame.java

示例3: startMinecraft

import net.minecraft.Launcher; //导入依赖的package包/类
public void startMinecraft( String dir, String clientName, AuthData authData, String server, String port, Frame frame ) {
	if ( dir == null || clientName == null || authData == null || frame == null ) throw new NullPointerException();
	if( port == null ) port = "25565";
		else if ( port.equals( "" ) ) port = "25565";

	String bin = OSManager.getClientFolder(dir, clientName).getAbsolutePath() + File.separator;
	
	URL[] urls = new URL[4];
	try {
		urls[0] = new File(bin, "minecraft.jar").toURI().toURL();
		urls[1] = new File(bin, "lwjgl.jar").toURI().toURL();
		urls[2] = new File(bin, "jinput.jar").toURI().toURL();
		urls[3] = new File(bin, "lwjgl_util.jar").toURI().toURL();
	} catch (MalformedURLException e) {
		e.printStackTrace();
	}

	final Launcher mcapplet = new Launcher(bin, urls, authData);
	mcapplet.customParameters.put("username", authData.getLogin());
	mcapplet.customParameters.put("sessionid", authData.getSession());
	mcapplet.customParameters.put("stand-alone", "true");
	if (server != null) {
		mcapplet.customParameters.put("server", server);
		mcapplet.customParameters.put("port", port);
	}

	frame.setVisible( false );
	frame.dispose();
	
	if( fullscreen ) {
		temp.setExtendedState( JFrame.MAXIMIZED_BOTH );
		temp.setMinimumSize( new Dimension( 800, 600 ) );
	}else
		temp.setSize( new Dimension( width, height ) );
	
	temp.setLayout( new BorderLayout() );
	temp.setLocationRelativeTo( null );
	temp.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );

	mcapplet.setForeground(Color.BLACK);
	mcapplet.setBackground(Color.BLACK);

	temp.add( mcapplet, BorderLayout.CENTER );
	temp.validate();
	temp.setVisible( true );

	System.setProperty("minecraft.applet.WrapperClass", "net.minecraft.Launcher");
	
	if( output ) {
		System.setErr(new PrintStream( new NulledStream()) );
		System.setOut(new PrintStream( new NulledStream()) );
	}

	mcapplet.init();
	mcapplet.start();
}
 
开发者ID:Sinrel,项目名称:SinrelLauncherEngine-Dev,代码行数:57,代码来源:MinecraftAppletStarter.java


注:本文中的net.minecraft.Launcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。