Giter VIP home page Giter VIP logo

program-minecraft's Introduction

Learn to Program with Minecraft - Docker Edition

So you've bought "Learn to Program with Minecraft" and need to set up your computer to run through the exercises. While the book gives detailed instructions to set everything up, this repo gives you what you need to run the Minecraft server and a Python development container to execute the exercises. Before proceeding, you'll need to install:

  1. Java - Required to run Minecraft. http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Minecraft - To play the Game. https://minecraft.net/en-us/download/
  3. MultiMC - Optional but recommened. https://multimc.org/
  4. Docker - You'll use this to run the Minecraft Server and Python development container. https://www.docker.com/get-docker
  5. Visual Studio Code - Not required, but provides an excellent text editor for programming. This provides the same (and more) functionality to IDLE which is referenced in the book. https://code.visualstudio.com/download

Getting started

Once you've installed the above clone this repo using git, or download this repo using the button above. If you download a ZIP, you'll want to extract it to a folder of your choice. Open a terminal (or command line) and change into the folder. Run docker-compose up to start the Minecraft Server as well as a container with Python installed. That's it! You're now able to start coding the exercises in the book.

Source Code Location

Throughout the book you'll create small snippets of code to execute. Any code you create will need to be placed in the src directory. You can make sure you're saving things in the correct location by starting Visual Studio Code (Code for short), clicking the File menu, then clicking "Open Workspace". Select the src folder as the workspace and click open.

Executing Your Python Scripts

The book will tell you to write your code in IDLE and then hit F5 to run it. In this environment you'll do things differently. Write your code in Code, save it to the src directory, then from a command line (or terminal) run docker exec -it mc-pi-dev bash. This will give you a terminal inside the Python development container. From here you can run python <myscript> where <myscript> is the name of the file containing your code. You can leave this terminal up while you're going through the exercises.

Restarting the Server

For any numnber of reasons you may need to restart the server and Python container. If the server is still running and your terminal is showing the console logs of the server, simply hit ctrl-c to stop the server. Then run docker-compose down to delete the old server instance, and then run docker-compose up to start a new instance. You'll need to be in the folder containing the docker-compose.yml file in this repository. This will not delete any of your server's data (see below on how to do that).

Minecraft Data

All data for the Minecraft server is stored in the data directory. To reset the server, stop the server (docker-compose down), then remove all the files and folders in the data folder. The Minecraft Server will recreate these files when it starts. Note that this will also delete any Worlds you've created!

Accessing the Minecraft Console

You might want to have access to the Minecraft Server's console to execute commands. You can run docker exec -it mc-pi-srv rcon-cli from a terminal to open the console. You can then issue server commands as you normally would on a Minecraft Server.

Increasing the Memory Available to Minecraft

Depending on your system and depending on what you're building, you might need to increase the memory of the Minecraft Server. Edit the docker-compose.yml file, changing the server's environment variable "MEMORY". Currently it is set to 1G.

program-minecraft's People

Contributors

mfdii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

program-minecraft's Issues

Merge mc-pi-dev image with VSCode browser image

First of all, thanks for this repository. I had an amazing time coding with my little brother.

I discovered that VSCode has a browser version (and they have Docker image!).

So I am trying to merge the sysdiglabs/mc-pi-dev image your provide with codercom/code-server:latest so my brother can code and run experiments while I host the Minecraft server remotely since VSCode has an embedded terminal.

The problem is that I don't have the Dockerfile you used for mc-pi-dev. Can you help?

I added this to the docker-compose.yml but obviously the VSCode container can't access mc-pi-dev:

vscode:
    image: codercom/code-server:latest
    ports:
      - "8080:8080"
    volumes:
      - ./code:/code
      - ./:/home/coder/.config/code-server/
    user: "1000:1000"

Thanks!!

Enric

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.