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.2a1.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.2a1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: knoxcraft-0.0.2a1.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.2a1.tar.gz
Algorithm Hash digest
SHA256 41ff89f31d3fd129e8b241a751e4b59fa253f40fbff710bab5989a68a2043829
MD5 0b6bd7f720f870922f8c920d7588ccba
BLAKE2b-256 9c6184a37d9e1f127507d8903b37f6f2814da7806f5184fdbc2348835ac9e6ad

See more details on using hashes here.

File details

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

File metadata

  • Download URL: knoxcraft-0.0.2a1-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.2a1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4a1f0b96a702219a6b4894df203b6af683ab703a1ce7b2aa92a5a5e2df3449b
MD5 69194f0767f3cfaf85733eee8505106d
BLAKE2b-256 15e493c4bbba6aabc2d78d30e99bd756c3c683103706a68299a4aefc3818c375

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