#Adding a New tag

34 messages · Page 1 of 1 (latest)

vague knoll
#

Been running into a problem with trying to add a new tag:

ServerEvents.tags('item', event => {
  wTypes.forEach(weapon => {
    swMats.forEach(material => {
      let itemID = `spartanweaponry:${material}_${weapon}`;
    event.add('windtail:melee', itemID);
});

(wTypes and swMats are just array's holding the strings to concat the two together to form the ID)

Im just trying to add the tag windtail:melee to an item, but it just doesn't seem to work. I went to go as far as making a datapack to create the tag first and loading it before KubeJS but it still didn't work so Im just a bit stumped and confused. Here's the server log

vapid orioleBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

indigo cave
#

can you post the log file itself here pls

vague knoll
#

Sure

worthy talonBOT
#

Paste version of server.log from @vague knoll

indigo cave
#

hm theres nothing wrong there

#

have you tried debugging it?

#
ServerEvents.tags('item', event => {
  wTypes.forEach(weapon => {
    swMats.forEach(material => {
      let itemID = `spartanweaponry:${material}_${weapon}`
      event.add('windtail:melee', itemID)
      console.log(itemID)
    })
  })
})
vague knoll
#

I've have and I've used existing tags like minecraft:swords and forge:tools/swords and both added themselves to the items. I just seem to run into an issue when adding a custom tag.

I'll rerun it with the consol.log rq, give me a sec

worthy talonBOT
#

Paste version of server.log from @vague knoll

indigo cave
#

so its doing something

#

are those item IDs correct?

vague knoll
#

That's how the item ID's are formatted. I did use existing tags earlier as a test for the mod Reforged (formerly Tiered) and it was clear the tags then were being applied as items would gain rarities

#

This is the full code:


var wTypes = [
    'dagger',
    'parrying_dagger',
    'longsword',
    'katana',
    'saber',
    'rapier',
    'greatsword',
    'battle_hammer',
    'warhammer',
    'spear',
    'halberd',
    'pike',
    'lance',
    'throwing_knife',
    'tomahawk',
    'javelin',
    'boomerang',
    'battleaxe',
    'flanged_mace',
    'glaive',
    'quarterstaff',
    'scythe'
];

var swMats = [
    'wooden',
    'stone',
    'copper',
    'iron',
    'gold',
    'diamond',
    'netherite',
    'tin',
    'bronze',
    'steel',
    'silver',
    'electrum',
    'lead',
    'nickel',
    'invar',
    'constantan',
    'platinum',
    'aluminum'
];

var sfMats = [
    'dragon_bone',
    'flamed_dragon_bone',
    'iced_dragon_bone',
    'lightning_dragon_bone',
    'desert_myrmex_chitin',
    'desert_myrmex_stinger',
    'jungle_myrmex_chitin',
    'jungle_myrmex_stinger',
    'fire_dragonsteel',
    'ice_dragonsteel',
    'lightning_dragonsteel'
];

var gItems = [
    'spartanweaponry:wooden_club',
    'spartanweaponry:studded_club',
    'spartanweaponry:cestus',
    'spartanweaponry:studded_cestus'
];

ServerEvents.tags('item', event => {

    gItems.forEach((itemID) => event.add('windtail:melee', itemID));

    wTypes.forEach(weapon => {
        swMats.forEach(material => {
            let itemID = `spartanweaponry:${material}_${weapon}`;
            event.add('windtail:melee', itemID);
            console.log(itemID);
        });
    });

    wTypes.forEach(weapon => {
        sfMats.forEach(material => {
            let itemID = `spartanfire:${material}_${weapon}`;
            event.add('windtail:melee', itemID);
        });
    });
});
#

Is there a way to check if an Item ID is valid?

indigo cave
#

i think you can do something like

if(Item.of('id here').isEmpty()) continue
vague knoll
#

Assuming put it before event.add(...)?

indigo cave
#

yeah

vague knoll
#

The game crashed, I think I ran the reload command to many times. It's gonna take a sec to get back up. Seemed to have a problem with if ... continue , I think it wants to use if ... return to skip over

#

Oh my god

#

I think itemID is being applied globally or used globally

#

It's printing out the Ranged weapons from RangedTags.js and the tag is applied on the ranged items

#

Oh not the itemID, it was the vars

indigo cave
#

return exits, continue continues to the next element in the list

vague knoll
#

It through a fit when I used it, I did it like this (Im somewhat a novice with for loops, sorry if it was wrong):

    wTypes.forEach(weapon => {
        swMats.forEach(material => {
            let itemID = `spartanweaponry:${material}_${weapon}`;
            if(Item.of(itemID).isEmpty()) continue;
            event.add('windtail:melee', itemID);
            console.log(itemID);
        });
    });
indigo steeple
#

The problem is that Array.forEach is not a standard for loop.

indigo cave
#
    wTypes.forEach(weapon => {
        swMats.forEach(material => {
            let itemID = `spartanweaponry:${material}_${weapon}`
            if(!Item.of(itemID).isEmpty()){
              event.add('windtail:melee', itemID)
              console.log(itemID)
            }
        })
    })
#

ezpz

#

no more confusion xD

vague knoll
#

Switching the var's to let's fixed the issue. I used the same name for wTypes across both RangeTags.js and MeleeTags.js and RangeTags was loaded last so it was using the wTypes of RangeTags.

I'm assuming it's still good to use that since it'll skip anything that isn't a real item

#

Ah well anyways, thanks for the help!