Skip to content

Commit

Permalink
Update Jupyter notebook to install node 18, update the server in exam…
Browse files Browse the repository at this point in the history
…ple (PrismarineJS#3176)

* Update Jupyter notebook to install node 18, update the server in example

* revert unintended metadata changes
  • Loading branch information
extremeheat authored Aug 31, 2023
1 parent d4db399 commit e8a967d
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions docs/mineflayer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"source": [
"# Using mineflayer in Python\n",
"\n",
"This is a tutorial on how to use mineflayer in Python. This example will connect you to the PrismarineJS test server. You can join it with prismarine-viewer or your Minecraft client at server IP **95.111.249.143:10000**.\n",
"This is a tutorial on how to use mineflayer in Python. This example will connect you to the PrismarineJS test server. You can join it with prismarine-viewer or your Minecraft client at server IP **pjs.deptofcraft.com:25565**.\n",
"\n",
"If you're new to Jupyter Notebooks, you can press the \"Play\" button at the left of each code block to run it. Make sure that you run the blocks in a correct order."
]
Expand All @@ -56,32 +56,35 @@
"id": "K2ol06QOhL6s"
},
"source": [
"First, make sure you have Python version 3.7 and Node.js version 14 or newer installed"
"First, make sure you have Python version 3.10 and Node.js version 18 or newer installed. You can get Node.js 18 it from https://nodejs.org/en/download or use [Node.js version managers](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-version-manager-to-install-nodejs-and-npm) like [`nvm`](https://github.com/creationix/nvm) or [`n`](https://github.com/tj/n) to install via the command line. Here we'll use `n` to install Node.js v18, then check our Node and Python versions:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "8zCSpx8Bif5m",
"outputId": "f8888a33-03e7-4497-9776-ef6c34d9d337"
"outputId": "90ebac14-fc75-4136-f81d-34c5b2033da0"
},
"source": [
"!python --version\n",
"!node --version"
],
"execution_count": null,
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Python 3.7.11\n",
"v14.16.0\n"
],
"name": "stdout"
"v18.17.1\n",
"Python 3.10.12\n"
]
}
],
"source": [
"# Use `n` to install nodejs 18, if it's not already installed:\n",
"!curl -fsSL https://raw.githubusercontent.com/tj/n/master/bin/n | bash -s lts > /dev/null\n",
"# Now write the Node.js and Python version to the console\n",
"!node --version\n",
"!python --version"
]
},
{
Expand Down Expand Up @@ -121,7 +124,7 @@
"source": [
"If all is well, we can import the `javascript` library. We can then import the `require` function which works similarly to the `require` function in Node.js, but does the dependency management for us.\n",
"\n",
"You may notice the extra imports : On, Once, off and AsyncTask. These will be discussed later on. \n",
"You may notice the extra imports : On, Once, off and AsyncTask. These will be discussed later on.\n",
"\n",
"\n"
]
Expand Down Expand Up @@ -170,21 +173,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1gfZSAUCDVMg"
},
"outputs": [],
"source": [
"random_number = id([]) % 1000 # Give us a random number upto 1000\n",
"BOT_USERNAME = f'colab_{random_number}'\n",
"\n",
"bot = mineflayer.createBot({ 'host': '95.111.249.143', 'port': 10000, 'username': BOT_USERNAME, 'hideErrors': False })\n",
"bot = mineflayer.createBot({ 'host': 'pjs.deptofcraft.com', 'port': 25565, 'username': BOT_USERNAME, 'hideErrors': False })\n",
"\n",
"# The spawn event \n",
"# The spawn event\n",
"once(bot, 'login')\n",
"bot.chat('I spawned')"
],
"execution_count": null,
"outputs": []
]
},
{
"cell_type": "markdown",
Expand Down

0 comments on commit e8a967d

Please sign in to comment.