#How to check if a player is wearing a certain accessory
7 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Here is a curio check
const checkCurios = (event, curiosList) => {
let curios = event.player.nbt.ForgeCaps['curios:inventory']
let key = false;
curiosList.forEach(curio => {
if (curios.toString().contains(curio)) {
key = true;
}
})
return key
}```
and you use that like so:
```js
const talismanBuff = (talisman, effectList) => {
PlayerEvents.tick(event => {
const { player } = event;
if (player.age % 200 === 0) {
let hasCurio = checkCurios(event, [talisman]);
if (!hasCurio) return
effectList.forEach(effect => {
player.potionEffects.add(effect.id, 1200, effect.amplifier, false, false);
});
}
});
};```
if you now just do this:
```js
talismanBuff('mod:talisman', [{id: 'minecraft:speed', amplifier: 2}])```
you will now get speed 3 when wearing `mod:talisman`
the check runs every 200 ticks (10 seconds) and gives the effect for 1200 ticks (60 seconds)