#index.js stopped working

1 messages · Page 1 of 1 (latest)

sturdy wind
#

some months ago i wrote a index.js with chatgpt and everything worked as intended: custom chat prefixes and preventing the usage of some items (like axes on logs) . this script doesnt work anymore and after the long time i forgot the basics of the script api, could someone help please? also maybe something iswrong with the manifest.json if someone could direct me to a tutorial what uuids to use

vagrant mangoBOT
#
Debug Result

There are 4 errors in this [code](#1148909648427089980 message):

index.js:1:10 - error TS2300: Duplicate identifier 'world'.

1 import { world, system, Player } from "@minecraft/server";
           ~~~~~

``````ansi
index.js:2:13 - error TS2300: Duplicate identifier 'world'.

2 import * as world from "@minecraft/server";
              ~~~~~

``````ansi
index.js:4:7 - error TS2339: Property 'events' does not exist on type 'World'.

4 world.events.beforeItemUseOn.subscribe((beforeItemUseOn) => {
        ~~~~~~

``````ansi
index.js:59:7 - error TS2339: Property 'events' does not exist on type 'World'.

59 world.events.beforeChat.subscribe((data) => {
         ~~~~~~

sturdy wind
tough nymph
#

world.beforeEvents.itemUseOn

#

world.beforeEvents.chatSend

sturdy wind
#

is this new? where are all those changes listed?

sturdy wind
#

i renamed it to main.js to test if that helped, but nope

#
    "dependencies": [
        {
          "module_name": "@minecraft/server",
          "version": "1.5.0-beta"
        },
        {
          "module_name": "@minecraft/server-gametest",
          "version": "1.0.0-beta"
        },
        {
          "module_name": "@minecraft/server-ui",
          "version": "1.2.0-beta"
        }
      ],
  "format_version": 2,
  "header": {
      "name": "§g§lBase",
      "description": "§7Base",
      "uuid": "14e467b4-e3aa-49d3-8352-f8439fd7b2ee",
      "version": [0, 0, 1],
      "min_engine_version": [1, 20, 0]
  },
  "modules": [
      {
          "type": "data",
          "uuid": "854b16b0-cf13-4711-af75-1e3014ccbaac",
          "version": [
              1,
              0,
              0
          ]
      },
      {
        "language": "javascript",
        "description": "script",
        "type": "script",
        "uuid": "7c7e693f-99f4-41a9-95e0-1f57b37e1e12",
        "version": [0, 0, 1],
        "entry": "scripts/main.js"
      }
  ]
}``` this is the manifest
#

in the addon i also have a custom entity, custom blocks and custom loot tables. theywork fine though

#

except for the script

tough nymph
#
const player = beforeItemUseOn.source;
const item = beforeItemUseOn.itemStack;
sturdy wind
#

is this the only ting thats wrong?

#

like when ichange it it should work?

#

thanks for replying tho :)

tough nymph
#

for script, yes

#

r u using preview?

sturdy wind
#

no

#

im on 1.20.15

#

and sadlyits still not working :(

#

both the chat prefixes and the item use preventer

tough nymph
#
"module_name": "@minecraft/server",
"version": "1.4.0-beta"
sturdy wind
#

okay one second

#

OMG it worked

#

thank you somuch

tough nymph
#

bao_foxxo_smilethats great then

sturdy wind
#

yayy

#

do i need to close this post somehow?