#Mana system debaucle

1 messages · Page 1 of 1 (latest)

wraith karma
#

Idk why it gives me this error, im clearly geting the tags from the equippableItem variiable

    at forEach (native)
    at <anonymous> (custom_components/wand.js:45)```

Here my code
```js
system.runInterval(() => {
    world.getAllPlayers().forEach(player => {

        if (!player) return;

        const equippable = player.getComponent("minecraft:equippable");
        const equippedItem = equippable?.getEquipment("Mainhand");
        const itemTag = equippedItem.getTags();

        if (equippedItem && equippedItem?.typeId === "wands:wand" || itemTag === "wands") {
            player?.runCommand(`title @s actionbar §b:: Mana: ${mana}/${maxMana} ::`);
        }
    });
}, 20);
golden bronze
#

getTags returns an array of every tags available for item if you want to check just one tag use .hasTag method
equippedItem.hasTag('wands')

wraith karma
#

serious

golden bronze
#

what are errors?

wraith karma
#
system.runInterval(() => {
    world.getAllPlayers().forEach(player => {

        if (!player) return;

        const equippable = player.getComponent("minecraft:equippable");
        const equippedItem = equippable?.getEquipment("Mainhand");


        if (equippedItem?.typeId === "wands:wand" && equippedItem.hasTag('wands')) {
            player?.runCommand(`title @s actionbar §b:: Mana: ${mana}/${maxMana} ::`);
        }
    });
}, 20);
wraith karma
#

my guess is the conditions for the if statement isnt getting met

#

for some reason

golden bronze
#

try to add prefix for tag in item

wraith karma
golden bronze
#

ig without any prefix it assumes minecraft:

wraith karma
wraith karma
golden bronze
#
        "minecraft:tags": {
                "tags": [
                    "wands:is_wand"
                ]
            },```

`equippedItem.hasTag('wands:is_wand')`
wraith karma
golden bronze
#

double check for tyoe ids

#

@wraith karma there is native way to do actionbar
player.onScreenDisplay.setActionBar(your actionbar); you can check other onScreenDisplay methods as well

#
system.runInterval(() => {
    world.getAllPlayers().forEach(player => {

        if (!player) return;

        const equippable = player.getComponent("minecraft:equippable");
        if (!equippable) return;
        const equippedItem = equippable.getEquipment("Mainhand");


        if (equippedItem && equippedItem.typeId === "minecraft:diamond_sword" && equippedItem.hasTag('minecraft:is_sword')) {
            player.onScreenDisplay.setActionBar(`§b:: Mana: ${mana}/${maxMana} ::`);
        }
    });
}, 20);```
it's working properly for me
wraith karma
#

it works now

#

i guess name spaces in item tags

#

are necessary

#

curse mojang and their inconsistent naming system

golden bronze
#

LoL

wraith karma
runic lava
#

how did u get that ucstom tag for items to work?

#

i tried to make my own custom item tag

#

and it wont work

wraith karma
#

damn, this post is old

runic lava
#

every dam time i try to make my own custom tag

#

it wont work

wraith karma
#

what does yours look like

runic lava
#

},
"minecraft:tags": {
"tags": [
"swmc:wayfinder"
]
}

wraith karma
#

this is how mine looks like

#

how exactly are you trying to detect the tags

runic lava
#

molangs

wraith karma
#

oh, is that possible

runic lava
#

yea

wraith karma