Minecraft python api windows

Installing Minecraft¶

README¶

The software used for this course is provided as companion to the book Learn to Program with Minecraft. It is recommended that the students purchase the book.

To get things running, you will need:

  1. Minecraft
  2. Python 3
  3. Java
  4. Minecraft Python API
  5. The Minecraft server

Minecraft¶

Visit the Minecraft homepage to download. If you do not have an account, please email me and I will make sure you are provided with one.

Python 3 Distribution¶

Python 3 is the distribution we will be using. If you have Python 2, it is recommended that you uninstall Python 2 and install Python 3. If you don’t, there will be some inconsitencies that could be devestatingly confusing. Also, Python 3 has a lot of really cool, new features that aren’t in Python 2.

There are several ways to get Python. I personally recommend the Anaconda distribution. It has a bunch of things packaged with it above and beyond Python that make it useful. Anaconda comes with the Spyder editor. It is a decent editor, but I would recommend:

  • PyCharm.
    • If you download PyCharm, make sure you download the Community Edition.
  • Sublime Text
    • This is my personal favorite. It is lightweight and has many extensions.
    • However, it does not run or debug Python files as easily as PyCharm.
  • Atom
    • Very similar to Sublime

You should have both Minecraft and Python installed at this point. You need to set Java up in order to run the server.

If you are on Windows:

  1. Click the Start Menu (or press the Windows key)
  2. Type “cmd” to find the program called cmd. Open this.
  • This is the command prompt. It is also called a terminal or console.
  1. Type java -version at the prompt
  2. If you see an output describing the version of Java, you already have it and can continue to the next section.
  3. If you don’t, or it can’t find java, then go to here: http://www.java.com/en/download/
  4. Click Free Java Download. Then click Agree and Start
  5. When it is finished downloading, install this.
  6. IMPORTANT: If it asks you to install extra things or set Yahoo! as your homepage, click no.
  • This is the annoying feature about installed Java.
  1. Retry steps 1-3. If they succeed, move on. If they don’t, email me.

Minecraft Python API and Minecraft Spigot server¶

An API is an interface. We will use it as a library that lets us communicate with the Minecraft server. We will not be able to edit the server in any way, but instead, just tell it instructions.

We will be using the Spigot server because it allows for the API to talk to it. Standard Minecraft does not.

Читайте также:  Не отображаются контакты windows phone

To install both of these:

  1. Go to https://www.nostarch.com/pythonwithminecraft/
  2. Download the MinecraftTools.zip for your operating system.
  3. When it has finished downloading, you can open it.
  • a zip file is known as a compressed file
  • it allows you to compress a set of files to make them smaller for downloading
  • all operating systems let you open these files
  1. Important Although it looks like you have a folder, the contents of the Zip file are not a folder
  2. Create a folder somewhere convenient and name it MinecraftTools.
  3. Inside the Zip file, you can click “Extract all” or similar button.
  4. Extract it to your MinecraftTools folder.
  5. Go to the folder and double click the Install_API file.
  6. Now, you can run the server.
  7. There is a file called Start_Server. Running this will start the server.
  8. If you have any trouble, email me.

© Copyright 2016, Brian McMahan. Revision 94fef083 .

Minecraft python api windows

Minecraft Server Python Interpreter

minecraft-python is a Spigot plugin providing the ability to control Minecraft using Python. Contrary to other approaches, this project aims to expose the whole Bukkit API to Python, instead of only providing a few commands by hardcoding or wrapping these in a Spigot plugin.

More background information on how this project came to be can be found on this blog post (a bit outdated at the moment).

You can watch a Youtube video showing off some of the possibilities (also a bit outdated by now but gets the idea across).

The implementation is based on Jython. This has the benefit that the complete Python interpreter system runs inside of the JVM, but comes with the drawback that it only supports Python 2.

With the Jython based system, you have the ability to interact with a Jython interpreter through a telnet server, websocket server, and through chat commands ( /py , /pyload and /pyrestart ). /py runs a line of Python code on a Jython intepreter (each player gets their own interpreter). A . (dot) at the beginning of the line can be used in case indentation with whitespace needs to be provided (the Minecraft server removes whitespace so this is provided as a workaround). /pyrestart restarts the Jython interpreter. /pyload takes a local Python file (in the running directory or on the Desktop of the server) and executes it in the Jython interpreter.

Alternatively, remote-client.py can be used to set up a Python REPL that will send commands to the remote Jython interpreter over a websocket connection.

Finally, a Telnet client can be used to connect to a telnet-based interface to the remote interpreter.

A built-in Python module, mcapi.py , provides some predefined handy commands which can be imported in the remote interpreter. Putting .py files in a python-plugins directory runs these as «plugins» when starting up the plugin. This interpreter keeps running and can be used to set up global hooks. Other interpreters will be cleaned out after some period of inactivity.

Читайте также:  Windows не видит ssd mac

A Word on Python 3

Jython only supports Python 2 for now, and it seems it’ll remain that way for a long while longer. There are various Python 3 JVM interop projects available, though none of which seem to offer the ease-of-use of a full Python on JVM implementation as Jython does.

Py4j comes close, and an earlier commit did provide a way to interact with Minecraft using this library. However, the Py4J implementation relies heavily on callbacks between Python and a JVM, which are sent over the network. Combining this with lots of thread-juggling and Spigot’s internal thread model is daunting to say the least. The implementation works, but is very unstable when trying to perform lots of actions on the Spigot server, so I ultimately removed it from the code base for now. See this commit to get an idea where things ended up — I might add this back in in a separate branch later on.

At one point in time, I also investigated Lua support, but also put this on the backlog for the time being.

The explicit goal of this project is to allow programming Minecraft using Python and to provide the full Bukkit API in this environment without resorting to manually wrapping these through a Spigot plugin. Other interesting projects in this space are:

  • https://github.com/ammaraskar/pyCraft: modern, Python3-compatible, well-documented library for communication with a MineCraft server. This is on the networking level, however, and rather low-level.
  • https://github.com/r1chardj0n3s/pycode-minecraft: similar to command blocks, this plugin allows to code scripts on «Python Blocks». Also uses Jython internally.
  • http://www.computercraft.info/: an amazing project adding computers and more to Minecraft, provind a coding interface using Lua. This is all in-game, however, comparable to command blocks or pycode-minecraft . A fine way to work with computers in Minecraft, though less so to work with Minecraft in computers.
  • https://github.com/martinohanlon/mcpi: combines https://github.com/py3minepi/py3minepi and https://github.com/martinohanlon/minecraft-stuff. Exposes only some basic commands by sending them over the wire to a Minecraft: Pi Edition server.
  • https://github.com/zhuowei/RaspberryJuice: a plugin that implements the Minecraft Pi Edition API, so that mcpi above can be used together with a normal Minecraft server. https://github.com/wensheng/JuicyRaspberryPie extends this a little bit. https://www.nostarch.com/programwithminecraft uses RaspberryJuice + mcpi to write its examples. A nice approach, with the downside that many «cool» Spigot commands are not available (fireworks, spawning, explosions, . ).
  • http://scriptcraftjs.org/: similar approach, but uses JavaScript and adds more boilerplate code between the JS engine Java interaction. A bit out of date, sadly.

As of its latest version, the plugin is installed just like any other Spigot plugin. You’ll need Java 8 at least.

On boot, lib-common and python directories will be created automatically. If you want to access other Minecraft plugins in your Python scripts, their JAR files can be copied over to a lib-custom directory.

Below is a short example of what you can do with the interpreter:

Plugins works similarly (place this as a .py file in a python-plugins directory):

This project is distributed as BSD 3-Clause License software. See LICENSE.txt for details.

Читайте также:  Как запустить файл windows 10 вирус

About

A Jython driven plugin and interpreter system for Minecraft (on top of Spigot)

Программирование на Python в игре Minecraft — бесплатные видеоуроки

Minecraft — это компьютерная инди-игра в жанре песочницы. Python (Питон, Пайтон) — высокоуровневый язык программирования общего назначения. А вместе они представляют невероятно удобную платформу для обучения детей основам программирования.

Мы собрали для вас пошаговые видеоуроки по освоению программирования в Minecraft. Короткие видео уроки будут интересны начинающим ученикам, которые хотят постепенно перейти от простого к сложному.

Minecraft — программирование на Python для детей — Урок 0: Установка Minecraft и Python


Minecraft — программирование на Python для детей — Урок 1: Знакомство с Python

Minecraft — программирование на Python для детей — Урок 2: Вывод координат персонажа в чат и цикл

Minecraft — программирование на Python для детей — Урок 3: Переменная, условие, создание первой игры

Minecraft — программирование на Python для детей — Урок 4: Создание блоков кодом

Minecraft — программирование на Python для детей — Урок 5: Строительство улицы из домов

Minecraft — программирование на Python для детей – Урок 6: Создание 2D-фигур

Minecraft — программирование на Python для детей – Урок 7: Создание 3D фигур

Minecraft — программирование на Python для детей – Урок 8: Создание многоугольников

Minecraft — программирование на Python для детей – Урок 9: Искусственный интеллект

Minecraft — программирование на Python для детей – Урок 10: Применение случайных чисел в ИИ

Плейлист видеоуроков постоянно дополняется, подписывайтесь на канал и следите за обновлениями.

Нужен наставник? Записывайтесь на онлайн-уроки программирования для детей в школе «Пиксель»: полный курс Minecraft

mcpi 1.2.0

pip install mcpi Copy PIP instructions

Released: Apr 19, 2020

Python library for the Minecraft Pi edition and RaspberryJuice API

Statistics

View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery

License: MIT License (MIT)

Maintainers

Classifiers

  • Development Status
    • 5 — Production/Stable
  • Intended Audience
    • Developers
    • Education
  • License
    • OSI Approved :: MIT License
  • Programming Language
    • Python :: 2
    • Python :: 2.7
    • Python :: 3
    • Python :: 3.3
    • Python :: 3.4
    • Python :: 3.5
    • Python :: 3.6
    • Python :: 3.7
    • Python :: 3.8
  • Topic
    • Education
    • Games/Entertainment

Project description

Minecraft: Pi edition API Python Library

mcpi Python library for communicating with Minecraft: Pi edition and RaspberryJuice.

Project details

Statistics

View statistics for this project via Libraries.io, or by using our public dataset on Google BigQuery

License: MIT License (MIT)

Maintainers

Classifiers

  • Development Status
    • 5 — Production/Stable
  • Intended Audience
    • Developers
    • Education
  • License
    • OSI Approved :: MIT License
  • Programming Language
    • Python :: 2
    • Python :: 2.7
    • Python :: 3
    • Python :: 3.3
    • Python :: 3.4
    • Python :: 3.5
    • Python :: 3.6
    • Python :: 3.7
    • Python :: 3.8
  • Topic
    • Education
    • Games/Entertainment

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you’re not sure which to choose, learn more about installing packages.

Оцените статью