#[RESOLVED] Custom commands(old way with message detection)

1 messages · Page 1 of 1 (latest)

shadow light
#

I'm trying with a behavior pack script to run commands with switch statements reading the chat messages and executing commands according to that. I'm in Minecraft 1.26.21.1. My codes:

manifest.json:

{
    "format_version": 2,
    "header": {
        "name": "Easy Creative",
        "description": "make the creative commands shorter an easier",
        "uuid": "c8c3239f-027f-4e80-890f-880eba65027d",
        "min_engine_version": [1, 26, 21],
        "version": [1, 0, 0]
    },
    "modules": [
        {
            "description": "Behavior Pack Module",
            "type": "data",
            "uuid": "cd2cd41a-1849-410e-8f0a-5d30fde4bd9a",
            "version": [1, 0, 0]
        },
        {
            "description": "Gametest Module",
            "type": "script",
            "language": "javascript",
            "entry": "scripts/index.js",
            "uuid": "f626740d-50a6-49f1-a24a-834983b72134",
            "version": [1, 0, 0]
        }
    ],
    "dependencies": [
        {
            // Minecraft native module - needed to use the "@minecraft/server" module
            "module_name": "@minecraft/server",
            "version": "2.7.0"
        }
  ]
}
#

when i load into a world with the pack activated, I get:

12:21:46[Scripting][verbose]-Plugin Discovered [Easy Creative] PackId [c8c3239f-027f-4e80-890f-880eba65027d_1.0.0] ModuleId [f626740d-50a6-49f1-a24a-834983b72134]

12:21:46[Scripting][error]-[Easy Creative] TypeError: cannot read property 'subscribe' of undefined    at <anonymous> (index.js:3)


12:21:46[Scripting][error]-Plugin [Easy Creative - 1.0.0] - [index.js] ran with error: [TypeError: cannot read property 'subscribe' of undefined    at <anonymous> (index.js:3)
]
#

Can someone help me debug this

haughty nymph
#

chatSend is an experimental API. You'll need to use a beta script API version in your manifest.json, as well as enabling the Beta APIs experiment on your world.

So for your manifest.json, you'll need to have this instead:

"dependencies": [
        {
            "module_name": "@minecraft/server",
            "version": "beta"
        }
  ]

Contents of the @minecraft/server.ChatSendBeforeEvent class.

#

You also cannot use runCommandAsync anymore. That has been removed since @minecraft/server version 2.0.0.

You can instead use:

system.run(() => {
  player.runCommand(<Your command>)
})
#

If you use the new custom command syntax, then you won't have to enable Beta APIs. You might have already seen this tutorial for it.

shadow light
#

Ohh

#

Thank you for answering, I'll test and let know how it goes

shadow light
#

@haughty nymph

shadow light
#

it works thanks