#custom shield like vanilla shield in script

1 messages · Page 1 of 1 (latest)

swift jay
#

How do I add knockback to items and attachments like a shield in script?

sly glacier
swift jay
#

Is that all in the code?

#

@sly glacier sorry for ping I need to know I add item.typeId for this

#

?

sly glacier
#

wdym'

swift jay
#

I mean, where I put it in class like itemuseon or other class

swift jay
#

Like this?

import { world } from "@minecraft/server"

world.beforeEvents.ItemUseAfterEvent.subscribe(({ source, item }) => {
  if (item.typeId == "shields:custom_shield") {
    const player = source
    player.applyknockback()
  }
})
hollow cloak
stiff ivy
#

@swift jay I'm gonna write a script like this soon, so I'll keep you updated

swift jay
#

Thanks