I am going to write some posts about Project Malmo, Minecraft and Visual Studio 2017. I still do not have very clear the order in which I will do them, so I will write and update them as I go along with my learning process.
Once we have installed all the necessary prerequisites and Apps to be able to work with Visual Studio 2017 and Minecraft, it is time to begin to understand some basic concepts about how to program against the game.
It all starts with the creation of an AgentHost(), that is the main object to perform the command communication between a .Net App and Minecraft. The next thing we must do is define the environment in which we want to interact, we define this as a mission with the MissionSpec() object. A couple of important details here is that we can define the duration of the same and the resolution with which we want to work (lines 17 and 18).
If we also want to have a recording of each of the steps that are made in our game, in addition to several execution logs, we can use an object of the MissionRecordSpec() type for this. The only necessary step at this point is to start the mission (lines 21 to 27) where we can see something similar to the following
A couple of details to keep in mind when the game is running
- Minecraft must load the game environment, so we must wait for it to be up and running before we add and run some game logic. An example on how to do this can be seen on lines 29 to 38
- It is also important to control the time in which the mission is running. Missions are usually time based, so mission start and end time are important. Lines 41 to 48
Sample Source Code
Greetings @ Toronto
- El Bruno, Learning to code with Minecraft? start with Hour of Code, MakeCode and Project Malmo
- GitHub, Project Malmo
- GitHub, Install Dependencies
- GitHub, C# Tutorial