@spyglassmc/mcfunction
TypeScript icon, indicating that this package has built-in type declarations

0.2.7 • Public • Published

@spyglassmc/mcfunction

banner

npm

This package contains parsers and processors for mcfunction.

Usage

import * as mcf from '@spyglassmc/mcfunction'

// Register the command tree for a specific version.
mcf.CommandTreeRegistry.instance.register('1.15', vanillaCommandTreeFor1_15, customCommandTreePatchFor1_15)

// Define a function that returns the corresponding parser for the provided argument tree node.
const argument: mcf.parser.ArgumentParserGetter = (treeNode: mcf.ArgumentTreeNode) => {
	switch (treeNode.parser) {
		case 'brigadier:double':
			return parser1
		case 'brigadier:int':
			return parser2
		// ...
		default:
			// Unsupported parser.
			// Just return `undefined`.
			return undefined
	}
}

// Get the command parser.
const commandParser = mcf.parser.command('1.15', argument)

// Or the mcfunction parser.
const mcfunctionParser = mcf.parser.entry('1.15', argument)

Contributions

Languages

  • mcfunction language that is associated with the .mcfunction file extension.

AST Nodes

Processors

Readme

Keywords

none

Package Sidebar

Install

npm i @spyglassmc/mcfunction

Weekly Downloads

37

Version

0.2.7

License

MIT

Unpacked Size

27.8 kB

Total Files

34

Last publish

Collaborators

  • spgoding