I recommend you to use the code actions of datapack-language-server to update your newer datapacks.
SPU is believed to be the abbreviation of SPU Performs Updating. It's a npm package that provides method to update Minecraft: Java Edition commands.
- Update commands from 1.8, 1.9(1.10), 1.11, 1.12, 1.13 and 1.14 to any later version.
- Support all commands.
- Support all kinds of parameters. e.g. NBT, entity selector.
- The author is still alive so if you find something not working as your intention, feel free to open an issue!
You can use SPU to update your Minecraft commands via the official website, the CLI (command line interface) or importing it to your project.
Open the official website.
The website is built with Angular and hosted on GitHub.
That's all.
- Installation.
npm i spu -g
- Run the CLI through command
spu <from> <to>
.<from>
: The version of the input command. e.g.12
stands for Minecraft: Java Edition 1.12. Should be one of the following values:8
,9
,11
,12
and13
.<to>
: The version of the output command. e.g.12
stands for Minecraft: Java Edition 1.12. Should be one of the following values:9
,11
,12
,13
and14
. Should be greater than<from>
.
- Type one of your commands and press ENTER, the CLI will return the updated result in real time.
I will enable the CLI to update whole mcfunction files if anyone requests. Feel free to open an issue!
- Installation.
npm i spu
- Import.
import { update } from 'spu'
- Update.
e.g.
update(commands: string[], from: number, to: number) => { commands: string[], logs: string[], state: 'success' | 'warning' | 'error'}
update(['/kill'], 12, 13) // { commands: ['/kill @s'], ... } update(['setblock ~ ~ ~ minecraft:sign 0 replace'], 12, 14) // { commands: ['setblock ~ ~ ~ minecraft:oak_sign replace'], ... }
src
: Source code written in TypeScript.lib
: Output JavaScript files.
The WheelChief system will try to parse your command(s) when you called 'update()'. All commands is stored in a CmdNode
, whose format is very similiar to the format of the commands.json
file that data generator provides:
interface CmdNode {
type: 'root' | 'literal' | 'argument'
children?: { [nodeName: string]: CmdNode }
parser?: string
properties?: { [propertyName: string]: any }
updater?: string
executable?: boolean
redirect?: string[]
spu_script?: string
}
e.g. The input is foobar @a {baz:qux}
and it can be parsed in the following nodes:
{
type: 'root',
children: {
foobar: {
type: 'literal',
children: {
entity: {
type: 'argument',
parser: 'minecraft:entity',
properties: {
amount: 'multiple',
type: 'entities'
},
children: {
nbt: {
type: 'argument',
parser: 'minecraft:nbt',
updater: 'spgoding:entity_nbt',
executable: true,
spu_script: '%0 $setNbtToSelector%1%2'
}
}
}
}
}
}
}
And then the WheelChief will return this (if no updater
is specific in the CmdNode
, the WheelChief will store its parser
in updater
):
{
command: {
args: [
{ value: 'foobar', updater: undefined },
{ value: '@a', updater: 'minecraft:entity' },
{ value: '{baz:qux}', updater: 'spgoding:entity_nbt' }
],
spu_script: '%0 $setNbtToSelector%1%2'
},
...
}
The WheelChief will update every argument according to its updater
. All updaters are defined in src/utils/wheel_chief/updater.ts
and src/**to**/updater.ts
. After updating all arguments we will get this (well, it just adds some quotes in this example):
{
command: {
args: [
{ value: 'foobar', updater: undefined },
{ value: '@a', updater: 'minecraft:entity' },
{ value: '{baz:"qux"}', updater: 'spgoding:entity_nbt' }
],
spu_script: '%0 $setNbtToSelector%1%2'
},
...
}
Finally the spu_script
will be executed. %0
will be replaced with the first argument of the command(args[0].value
), %1
will be the second(args[1].value
), and so on. A token that begins with $
will be executed as a function with following %n
as its parameter(s). So finally you will get foobar @a[nbt={baz:"qux"}]
.
I'm thrilled to hear that you'd like to contribute to this project. It's no doubt that spu will be better with your help!
-
Fork this this repo and clone it to your local.
-
Install dependencies.
npm i
-
Edit files in
./src
. -
If you add new features, it's strongly recommend to write tests for them. All tests should be put under
./src/test
. -
Commit and push your changes.
-
Open a Pull Request. The circle ci will build and test your changes automatically.
There must be lots of mistakes and bad practice in this repository. If you find something not good or not sure whether it's not good, please don't hesitate to tell me!