#how to register a custom components for items ?

1 messages · Page 1 of 1 (latest)

eager dawn
#

sry if its the wrong channel

inner dockBOT
#
HCF Removal and Custom Components

The Holiday Creator Features experimental toggle has been removed. Along with it includes JSON block and item events. This functionality has been replaced with custom components.

Please take a look at the following links to learn more about custom components:

Bedrock Wiki

MS Docs

mental ore
eager dawn
#

thx

#

so

#

const UnbreakableItemComponent = {
    onBeforeDurabilityDamage(event) {
        event.durabilityDamage = 0;
    },
};

world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
    itemComponentRegistry.registerCustomComponent("wiki:unbreakable", UnbreakableItemComponent);
})```
eager dawn
#

the durability components

#

?

mental ore
#

Correct, I think. I'll have to check the onBeforeDurabiltiyDamage event but that structure is right

eager dawn
#

wait

eager dawn
mental ore
#

Notice how you're using yes:mining_durability_damage but in the script you gave me above is registering wiki:unbreakable

eager dawn
#

euh

#

export const functions = {
miningDurabilityDamage: miningDurabilityDamage,
onUse: onUse,
onHit: onHit,
hitDurabilityDamage: hitDurabilityDamage
//onPlayerDestroy: onPlayerDestroy
};

#

this ?

mental ore
#

What?

eager dawn
#

i dont understand js

#

im bad with this thing

mental ore
eager dawn
#

why mojand decide to remove on use

#

wiki:unbreakable

#

?

#

i think my translate is bad

#

xx

mental ore
#

Not sure where the disconnect is, might be a language barrier thing, but you're using the wrong id in your item

#

Your script says wiki:unbreakable but your item is using yes:mining_durability_damage

eager dawn
#

yh

#

so it suppose to work ?

#

yes:mining_durability_damage is not registred

mental ore
eager dawn
#

the durability wont work

#

but when i hit mobs it work

eager dawn
#

my pickaxe is only workin with mobs

mental ore
#

That's because onBeforeDurabilityDamage only works when you're hitting entities

eager dawn
#

it work if i put it on main.js ?

mental ore
eager dawn
#

is working with a tzg ?

#

tag

mental ore
#

Nope, please dont just copy/paste stuff you dont understand

#

Just use my library and read the docs and readme to understand how it works

eager dawn
eager dawn
#

i copy mc fortify

#

for pickaxes

mental ore
#

What are you doing?

eager dawn
#

idk

#

im trying to use my brain xx

eager dawn
#

ur script is not working

mental ore
#

You're not using it correctly

eager dawn
#

let this channel open

#

i need to off

#

i will check it tomorrow

eager dawn
#

too hard for new dev

mental ore
#

It is relatievely simple if you just read the README but I understand its not for you

eager dawn
#

i need the js in the registry

#

i just wand to make a pickaxe