Create a Minecraft starter from scratch (C ++ open source ),

Source: Internet
Author: User


Create a Minecraft starter from scratch (C ++ open source ),

Create from scratchMinecraftStarter(C ++Open Source)

 

A newbie is driving fast ~~~, The source code of the MC starter is released, and you can create your own dedicated MC starter as you like. This is not easy language. It is C ++... The analysis principle and the key source code are annotated in detail. After the code is compiled, it is packed and sent, so it is messy...

 

:

Baidu Network Disk: http://pan.baidu.com/s/1i3UDOXn

CSDN download: http://download.csdn.net/detail/u010661060/9376136

 

MClauncher (Public edition) starter interface:

 

 

 

The code is all open-source and has detailed comments:

 

 

 

Tested platforms: 64-bit Windows 7 and Windows XP can run on both platforms.

 

Test the MC startup version: Both Minecraft1.7.10 and Minecraft1.7.10 forge versions can be started. Otherwise, other versions of the game may be started...

 

Note:


 

 

After a great deal of hard work, I finally got my own starter. Although there are countless bugs, I can at least use it...

 

I didn't know anything at the beginning. I searched for MC starter source code and MC startup principles on the Internet. There are still a lot of source code to be searched, but most of them are written in easy language. However, the hacker does not understand how to start the program. After thinking about Google, find some source code, but there is a GFW, you can't afford a VPN, many web pages cannot be opened, and the most critical thing is that Nima cannot understand English. Later, I saw a reply in a forum, saying that it was about to start MC and analyze the JSON file in it. When I saw this sentence, I finally got an eye on it.

 

First, analyze the MC starter startup parameters. Refer to the melody starter and turn on the debugging switch of the melody starter to obtain the parameters that the starter sends to the game. Of course, you can also open cmd and enter the "wmic process where caption =" javaw.exe "get caption, commandline/value> D: \ canshu.txt" parameter at startup to obtain the initiator parameters.

 

Before reading the MC initiator parameters, let's take a look at the parameter transfer and dependency analysis of running the jar package.

Previously, we made a small java program to simulate MC Games in order to clarify the passing of MC parameters, so we don't have to perform this small parameter test on a large MC game.

 

Mini-game STARTUP script:

Java-Xmx1024m-Dplayer. name = BlueCat-cp HelloFrame. jar HelloFrame

Parameter Analysis:

-Xmx1024m: indicates the maximum JVM heap memory value (do not understand, just copy it according to others ...)

 

-Dplayer. name :( use-D <name >=< value> to set the System property value) here to pass game parameters, in java programs can use: System. getProperty ("player. name ") to display the player name in the test window.

 

-Cp: The Class search path of the Directory and zip/jar file. The following parameters are the jar package on which the main function is executed, and the jar package where the package is located. There is no sequence of order.

 

Last parameter: Specify the HelloFrame class of the main function. If the class is in the package, add the package name before it. Otherwise, only the class name is required.

 

Now let's take a look at the real Minecraft startup parameters. It's too long. Let's take a look at them in segments.

 

Section 1:

C: \ Program Files \ Java \ jre7 \ bin \ javaw.exe

(Javaw.exe with full coverage)

 

Section 2:

-Xmx1024m

-Dfml. ignoreInvalidMinecraftCertificates = true

-Dfml. ignorePatchDiscrepancies = true

-Djava. library. path = ". minecraft \ natives"

(Heap memory and related system variable settings)

 

Section 3:

-Cp "... (10 thousand jar packages are omitted here)... 1.7.10-Forge10.13.2.1230.jar"

(Dependent jar package)

 

Section 4:

Net. minecraft. launchwrapper. Launch

(Main class)

 

Section 5:

-- Username BlueCat

-- Version 1.7.10-Forge10.13.2.1230

-- GameDir. minecraft

-- AssetsDir. minecraft \ assets

-- AssetIndex 1.7.10

-- Uuid $ {auth_uuid}

-- AccessToken $ {auth_access_token}

-- UserProperties {}

-- UserType legacy

-- TweakClass cpw. Mod. fml. common. launcher. FMLTweaker

(Game parameters, minecraftArguments in the json file)

 

In the simulation applet, except for the fifth segment, the simulation is similar.

When you start a game, you can pass these parameters to start the game. These parameters can be obtained from the JSON file. Of course, some parameters are fixed and some are set by yourself. For example, set the game name by yourself.

 

The JSON file is in 1.7.10.json under the. minecraft \ versions \ 1.7.10 \ directory.

 

Important parameters are all here, so what the initiator needs to do is parse the JSON file, obtain the value, convert it to the startup parameter, and pass it to the JVM. Therefore, the most frequently used starter is string processing. I am a chicken, and C ++ and Qt are both half-hanging. I don't know any good methods. It is silly in many places, and the code is also messy. When I think of anything, I can't even figure out my own ideas, the source code may be confusing, but the key methods are annotated. Remember one when reading the source code. All you do is to convert a string of characters in JSON into appropriate startup parameters. So when you see code repeating in blind JB or suddenly dropping 1, do not repeat it ,~ _~. For more information about how the starter works, see the source code ~~~.

 

Oh, by the way, there are still some things.

1, is hope you help test the starter, BUG sent to my mailbox 1425078914@qq.com, grateful!

The BUG may not be fixed as soon as possible, because there are more important things to do, and it should not touch the starter for a long time.

 

2. Existing bugs of the public version starters:

(1) There is a window slide BUG when selecting the Start version, similar.

 

I can't do anything about this BUG for the time being. I am just a chicken and I am constantly learning...

(2) The automatically set memory option is false, that is, it is fixed to 1024 m, and I still don't know how to get it.

(3) the java PATH automatic search algorithm still needs to be strengthened, which is not a BUG. Currently, it is only used to find the java PATH contained in PATH in the system environment variable, tests on other computers have failed.

 

3. A question about some pain points in the preparation of the starter

First, the initiator interface is merged on Qt4. Most of the buttons adopt fake connections, and then Qt4 does not have JSON-related classes when it comes to parsing JSON files, JSON-related classes start with Qt5. So I ran to the official website and got the latest version of Qt5.5.1 (minGW version). Once the program was compiled, it caused Qt Creater to be unresponsive. Later, I switched to Qt5.0.2 to avoid this problem. However, the Release version compiled in this version is difficult to run on a computer without Qt installed. It requires a lot more library files. As a result, another Qt5.5.0 problem still persists. So, we finally use Qt5.0.2 for compilation and debugging, and then use Qt5.5.0 for compilation and testing on other computers...

 

4. For the last point, refer to the natives folder in the melody launcher, which contains some dll files. I don't know how to use it. If the melody is missing, it is downloaded. Program.

 

The starter was launched from scratch. It is not very understandable in many places, and it is also a bit silly in some places. I hope you can give me some advice. Thank you very much !!!


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.