#How would i create custom weapons using VSC

1 messages · Page 1 of 1 (latest)

untold heron
#

like create a custom item where when you right click you get certain effects? Does anyone have an example or somethign?

young dome
#

you would use an item componenet and use an effect for the playerinteract event

untold heron
#

do you have an example?

young dome
#

so you have your item right?

{
    "format_version": "1.21.90",
    "minecraft:item": {
        "description": {
            "identifier": "ns:custom_weapon",
            "menu_category": {
                "category": "items"
            }
        },
        "components": {
          "ns:custom_weapon": {}
        }
    }
}```
this applies the component `ns:custom_weapon` which you would then register
```js
import { world, system } from "@minecraft/server";

const CustomWeaponComponent = {
    onUse(event) {
      event.source.addEffect(/*...*/)
  }
};

system.beforeEvents.startup.subscribe(({ itemComponentRegistry }) => {
    itemComponentRegistry.registerCustomComponent("ns:custom_weapon", CustomWeaponComponent);
});```
untold heron
#

okay but how would i add effects to it on right click with a cooldown

young dome
untold heron
#

yea

#

so they cant spam the ability

young dome
#

you would add the cooldown componeent and the use_modifier componenet

{
    "format_version": "1.21.90",
    "minecraft:item": {
        "description": {
            "identifier": "ns:custom_weapon",
            "menu_category": {
                "category": "items"
            }
        },
        "components": {
          "minecraft:use_modifiers": {
            "use_duration": 0.1 // time for the weapon to use in secs
          },
          "minecraft:cooldown": {
            "category": "effect_use", // you can put anything in here
            "duration": 2 // time for the weapon to cooldown in seconds
          },
          "ns:custom_weapon": {}
        }
    }
}```

and in the script turn the `onUse` to `onCompleteUse`
#

so script would look like this:

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

const CustomWeaponComponent = {
    onCompleteUse(event) { // changed
      event.source.addEffect(/*...*/)
  }
};

system.beforeEvents.startup.subscribe(({ itemComponentRegistry }) => {
    itemComponentRegistry.registerCustomComponent("ns:custom_weapon", CustomWeaponComponent);
});```
#

@untold heron

untold heron
#

okay thank you

#

ill try this out once i figure out why my thing is saying this

young dome
#

are you not using the development directories?

untold heron
#

wdym

young dome
untold heron
#

no i dont think so

young dome
#

oh no

untold heron
#

oh these

young dome
#

oh yeah

untold heron
#

no

young dome
#

you;re not??

untold heron
#

i change the zip to .mcpack and download it like that

young dome
#

you should put your BP and RP in them

#

it basically loads faster

#

and no need to import .mcpack

untold heron
#

how is it empty

young dome
#

put your BP and RP directories respectovely in them

young dome
untold heron
#

oh there was 2 of them

#

that didnt do anything

young dome
untold heron
#

its still not in minecraft

young dome
untold heron
young dome
#

first of all

#

put it in DEVELOPMENT, not the normal

#

and second of all

#

unzip ot

#

its supposed to be the raw directory

untold heron
#

okay i extracted it

#

so i put it in the dev ones right

young dome
#

ye

untold heron
#

okay imma try it

#

if this doesnt work are we able to vc and i can ss to you

young dome
#

i cant vc rn sry

untold heron
#

its okay but its still not here

young dome
#

can you click inside

#

the directory

untold heron
#

this is inside

young dome
#

its not supposed to be liek that]

untold heron
#

theres like 3 of them in one

young dome
#

oh damn

untold heron
#

okay i took it out

young dome
#

it should be once you see inside the folder it should be like scripts, items, manifest right?

untold heron
young dome
#

try now

untold heron
#

i am

#

yessss its here now

#

okay lemme check if i updated it

#

yo has anyone told you your hella smart

young dome
#

really why

#

?

untold heron
#

idk cause your helpin me!

untold heron
young dome
untold heron
young dome
untold heron
#

yea i just changed it to that someone in off topic told me to change it to 2.2.0 😭

young dome
#

oh lol

untold heron
#

its still erroring me

#

but its on 2.1.0

young dome
#

ok

#

@minecraft/server is 2.2.0-beta
@minecraft/server-ui is 2.1.0-beta

untold heron
#

ohh okay lemme try it

#

its still erroring me like what

young dome
#

wait what

#

did you save the file

untold heron
#

im pressing ctrl s

#

so yea i think so

young dome
#

same error?

untold heron
#

yea

young dome
#

are you editing the file that exists in the dveelopment directory?

#

do /reload all

untold heron
#

i did /reload all

#

still same error

#

@young dome

fringe dust
#

yup

young dome
untold heron
#

i fixed it

#

i wanna work on a custom item

#

@young dome so can you give me a full example on a custom sword so i could copy and paste it and work on from it please?

balmy sierra