JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q36488F
  • License MIT

Code minecraft education edition using nodeJS. An attempt to improve on Microsoft Code Connection.

Package Exports

  • codeconnection
  • codeconnection/codeController.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (codeconnection) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Code connection for Minecraft Education Edition clone using NodeJS.

To turn on the server run:

(npx) codeserver-start

To turn off the server run:

(npx) codeserver-stop

The server runs an expressJS server (port 3001) and a websocket (port 3000). Minecraft connects to port 3000 using the /connect localhost:3000 slash command.

The player script automatically sends http requests to express that relays them to Minecraft. Minecraft responds (eventually) with some JSON data that is parsed with true/false/useful data being sent back to the player.


Scripts should start with

const { agent, d, blocks } = require('codeconnection')

agent - this gives access to the agent to send commands d - this gives quick access to direction commands LEFT, RIGHT, UP, DOWN, FORWARD, BACK blocks - a list of blocks so yo don't have to type them

Possible agent commands:

Command Details
agent.move(direction, distance) moves agent number of steps in given direction. Returns true/false
agent.turn(direction, times) turns left or right given number of times. Always returns true
agent.getPosition() returns JSON object with x,y,z co-ordinates of the agent
agent.getPlayerPosition() returns JSON object with x,y,z co-ordinates of the player
agent.orientation() returns direction agent is facing
agent.inspect(direction) return block information of block in direction given form the agent perspective
agent.destroy(direction) agent destroys block in given direction. Returns true/false
agent.collect() agent picks thins up nearby
agent.inventory() returns JSON object with inventory data for agent (id aligns with blocks list)
agent.till(direction) agent tills soil in direction given. Returns true/false
agent.attack(direction) agent attacks in direction given
agent.dropAll(direction) agent drops all inventory in direction given
agent.drop(slot,quantity,direction) drops given number of items from the slot in the direction given (will not allow inventory to go negative)
agent.place(direction,slot) agent places item from given inventory slot in direction indicated
agent.detect() detects if any block in given direction (returns true/false)
agent.detectRedstone(direction) detects if redstone in direction given
agent.transfer(from slot, to slot, quantity) self explanatory I hope
agent.tpToPlayer() teleports agent to player
agent.face(direction) makes agent face either NORTH, SOUTH, EAST or WEST
agent.radar(block) will attempt to see if there are any potential matching blocks within 16 blocks on the same vertical height in the world as the agent. It runs the /getchunkdata command to get the colour values of nearby blocks and checks these against a list. Many blocks have the same colour value (e.g. all stone and ore blocks are the same) so they may not help you find diamonds easily....