#Item scripts not working in 1.21.x?

1 messages · Page 1 of 1 (latest)

weak acorn
weak acorn
#

BP/scripts/script_name.js

import {
    world,
} from "@minecraft/server";


const Test = {
    onUse(event) {
        world.sendMessage("test");
    }
};

system.beforeEvents.startup.subscribe(({
    itemComponentRegistry
}) => {
    itemComponentRegistry.registerCustomComponent("namespace:script_name", Test);
});

item

{
  "format_version": "1.21.50",
  "minecraft:item": {
    "description": {
      "identifier": "namespace:custom_item",
      "menu_category": {
        "category": "items"
      }
    },
    "components": {
      "minecraft:glint": true,
      "minecraft:allow_off_hand": true,
      "minecraft:hand_equipped": true,
      "minecraft:fuel": {
        "duration": 0.15
      },
      "minecraft:durability": {
        "max_durability": 3
      },
      "minecraft:use_modifiers": {
        "use_duration": 1.6,
        "movement_modifier": 1
      },
      "minecraft:icon": "custom_item",
      "behaviorpak:ghk": {}
    }
  }
}

BP manifest contains

...
  "modules": [
...
    {
      "uuid": "5f79049b-875f-329b-9d8c-0709088495e0",
      "version": [
        1,
        0,
        0
      ],
      "type": "script",
      "language": "javascript",
      "entry": "scripts/script_name.js"
    }
  ],
...
#

Same approach works for blocks

#

Searching discord, there are quite some people also asking this without a clear resolution, but bug tracker also does not contain this

cursive badger
weak acorn
#

I also tried with 1.21.80, 90, and many others with the same outcome

#

For blocks, all good, though

#

Ah, my bad, I changed format in the wrong file

#

Let me test again