#Item scripts not working in 1.21.x?
1 messages · Page 1 of 1 (latest)
Where code?
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
Format version needs to be 1.21.80 or higher