#how to register a custom components for items ?
1 messages · Page 1 of 1 (latest)
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
- Block Events
- Block Events Migration to Custom Components
- Item Events
- Item Events Migration to Custom Components
MS Docs
@eager dawn
thx
so
const UnbreakableItemComponent = {
onBeforeDurabilityDamage(event) {
event.durabilityDamage = 0;
},
};
world.beforeEvents.worldInitialize.subscribe(({ itemComponentRegistry }) => {
itemComponentRegistry.registerCustomComponent("wiki:unbreakable", UnbreakableItemComponent);
})```
if i understand this suppose to register
the durability components
?
Correct, I think. I'll have to check the onBeforeDurabiltiyDamage event but that structure is right
https://github.com/SmokeyStack/adk-lib/blob/main/rc/scripts/item/registry/on_before_durability_damage.ts#L99 This is what I use for my custom component library
i have this error
Notice how you're using yes:mining_durability_damage but in the script you gave me above is registering wiki:unbreakable
euh
export const functions = {
miningDurabilityDamage: miningDurabilityDamage,
onUse: onUse,
onHit: onHit,
hitDurabilityDamage: hitDurabilityDamage
//onPlayerDestroy: onPlayerDestroy
};
this ?
What?
Notice how this says wiki:unbreakable, but you're using yes:mining_durability_damage for your items
why mojand decide to remove on use
wiki:unbreakable
?
i think my translate is bad
xx
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

That's because onBeforeDurabilityDamage only works when you're hitting entities
https://github.com/SmokeyStack/adk-lib/blob/main/docs/items/on-mine-block/digger.md I would just use my custom component library
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
ill try so
i copy mc fortify
for pickaxes
What are you doing?

You're not using it correctly
Please just read the README
i dont understand ur thing bro
too hard for new dev
It is relatievely simple if you just read the README but I understand its not for you
but hm
i need the js in the registry
i just wand to make a pickaxe