Skip to main content

Python client code for Knoxcraft Mod. Basically 3D Logo for Minecraft, with parallelism.

Project description

Knoxcraft

Python library for Knoxcraft Mod

Knoxcraft enables students to write code in Java, Python, Blockly, or other languages that build 3D structures inside Minecraft using a Logo-like set of instructions.

Student code can have multiple "threads" of execution.

Students can upload their code to a modded server, run their programs, and watch their Terrapin turtles (or Terps) move around to build their structures.

NOTE You need a Minecraft server modded with Knoxcraftmod. See https://github.com/jspacco/knoxcraftmod for more details.

Example Serial (single-threaded) Python code

from pyterp import Terp, TerpBlockType

# Get the URL from your instructor
# Or just run the mod yourself
url = 'http://localhost:8080/upload'
# Your minecraft playername
minecraftPlayername = 'spacdog'
# If your instructor has username/password enabled
# These are very basic
username = 'test'
password = 'foobar123'

# this draws a pyramid that is 10x10 at the base, and then tapers
t = Terp("pyramid", "Draw a pyramid")
for base in range(10, -1, -2):
    for i in range(base):
        for j in range(base):
            t.forward()
            t.set_block(TerpBlockType.SANDSTONE)
        for h in range(base):
            t.back()
        t.right()
    for i in range(base):
        t.left()
    t.forward()
    t.right()
    t.up()

# upload to the server
response = t.upload(url, minecraftPlayername, username, password)
print(response)

Example Parallel (multithreaded) Python code

from knoxcraft import ParallelTerp, TerpBlockType

# Get the URL from your instructor
# Or just run the mod yourself
url = 'http://localhost:8080/upload'
# Your minecraft playername
minecraftPlayername = 'spacdog'
# If your instructor has username/password enabled
# These are very basic
username = 'test'
password = 'foobar123'

programName = "ptunnel"
description = "Draw a tunnel IN PARALLEL"

# 
terp = ParallelTerp(programName, description)
def thread1(t):
    t.left()
    for _ in range(3):
        t.forward()
        t.set_block(TerpBlockType.DIRT)
def thread2(t):
    t.right()
    for _ in range(3):
        t.forward()
        t.set_block(TerpBlockType.STONE)
def thread3(t):
    t.up()
    for _ in range(3):
        t.forward()
        t.set_block(TerpBlockType.SANDSTONE)

def thread4(t):
    t.down()
    for _ in range(3):
        t.forward()
        t.set_block(TerpBlockType.BRICKS)

terp.add_thread(thread1)
terp.add_thread(thread2)
terp.add_thread(thread3)
terp.add_thread(thread4)

# upload to the server
response = terp.upload(terp, url, minecraftPlayername, username, password)
print(response)

Project details


Download files

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

Source Distribution

knoxcraft-0.0.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

knoxcraft-0.0.2-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file knoxcraft-0.0.2.tar.gz.

File metadata

  • Download URL: knoxcraft-0.0.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for knoxcraft-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b74ff220908b0493d8bf32d8967ec36ed7a68345b6fdfc7aa51df7d0c33448b8
MD5 0cb6f2cc6e5d26607cba04106586967d
BLAKE2b-256 c81d01307fa304a6ef54e1ae1409f8d83a06da9c0c371216b3e56324aca94741

See more details on using hashes here.

File details

Details for the file knoxcraft-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: knoxcraft-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for knoxcraft-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b200b4f9a2c4d46aa1ab581a8b7a50988f218fa3a121083ae2f37696f6c07d30
MD5 fd0a7272016c5b11b2c399f140d204ba
BLAKE2b-256 cef32d6839e467239dd5dfa0ad69cd63d154805010da50a2f764430d87ea7392

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page