#Use tags to remove tags

78 messages · Page 1 of 1 (latest)

rocky ravine
#

Hello I know it sounds stupid, but is there somehow to use tags to remove tags? I use Item Stage so I made a custom tag (crafted:stage/automation) and I made that when this tag is on an item it lock it under the stage Automation, so I made that most of the mods are locked under the stage Automation, but I want to do that some items aren't locked so I could all my modpacks wood types or I could use the tag minecraft:logs that could be much easier but tags doesn't look to work so is there somehow else to use the tags?

Here is my tags.js code :

stiff fableBOT
#

Paste version of tags.js from @rocky ravine

astral mirage
#

??kjswiki

stiff fableBOT
astral mirage
#

try using getObjectIds() like in the last example of that, and filter tags based off that

#
let allStone = event.get('forge:stone').getObjectIds()
let allWood = event.get('minecraft:logs').getObjectIds()
allStone.forEach(stone => {
  if (!allWood.contains(stone)) {
    event.add('minecraft:non_stoney_logs', stone)
  }
})

like this, it will add all entries from the stone tag that are not in the logs tag.
You can replace either of the event.get().getObjectIds() with Ingredient.of('@modid').itemIds if you dont want the input to be a tag

#

Use tags to remove tags

rocky ravine
#

I'm gonne try it thank you!

rocky ravine
#

It doesnt work :/

#
const beginnerAllowedTags = ['#minecraft:leaves', '#minecraft:planks', '#minecraft:logs', '#minecraft:dirt', '#forge:stone', '#minecraft:flowers']

const beginnerAllowedItems = ['minecraft:deepslate_lapis_ore']


onEvent('item.tags', event => {
    beginnerLockedMods.forEach(currentItem => {
        event.add('crafted:stage/automation', currentItem)
    });

    beginnerAllowedItems.forEach(item => {
        event.remove('crafted:stage/automation', item)
    });

    beginnerAllowedTags.forEach(tag => {
        let allItems = event.get(tag).getObjectIds();
        allItems.forEach(item => {
            event.remove('crafted:stage/automation', item)
        });
    });
})```
astral mirage
#

dont use it to remove

#

use it to add

rocky ravine
#

But I actually want to remove it

#

I locked every mod on my modpack and I want to let only some items for the first stage

astral mirage
#

There are two ways you can do this

  1. Lock every item in every mod, and then remove the ones you dont want locked
  2. Lock every item in every mod except for the items you dont want
#
  1. isnt working, so try 2.
rocky ravine
#

And how can I do that?

#

Found it

#

I'm gonna try thanks for the help

#

How can I retrieve the mod items?

#

Does mod.getObjectIds() work?

astral mirage
#

no

#

You can replace either of the event.get().getObjectIds() with Ingredient.of('@modid').itemIds if you dont want the input to be a tag

rocky ravine
#
    beginnerLockedMods.forEach(mod => {
        let modItems = Ingredient.of(mod).itemIds;
        modItems.forEach(item => {
            if (!beginnerAllowedItems.test(item)) {
                event.add('crafted:stage/automation', item)
            }
        });
    });
})``` I reproduced the wiki code, but I test on an array so I don't think it works
#

I made an array for the blacklist items

#

I code in Java I don't have any experience in JavaScript so I don't know if it works

#

I hate loops so much

#

After searching I found a function for testing if the array contains de value

#

I'm gonna try this if it works I'm gonna try to make it with tags

#

Items worked perfectly

stiff fableBOT
#

[Quote ➤](#1050205181960274110 message) Already tried doesn't work

astral mirage
#

How doesnt it work.
Does it error?

rocky ravine
#

It doesn't give an error, the tag isn't not applied to the item

astral mirage
rocky ravine
#

The code changed i'm gonne post the new one

stiff fableBOT
#

Paste version of tags.js from @rocky ravine

rocky ravine
#

Items work perfectly juste with the tag blacklist it doesn't apply

astral mirage
#

you are trying to get the mod as a tag

#

not as a mod

#

instead of event.get(mod).getObjectIds() use Ingredient.of(mod).itemIds

#

but only for @modid syntax

rocky ravine
#

So I have a list 'BeginnerLockedMods' constant and at first I check if the item isn't in the list of items, if it does the tag isn't applied else wel

#

I think I found the issue

#

I only check for the item, and if it false I don't check for the tag list wait

#

Ok I'm waiting on the game to reload

#

I'm on a big modpack takes sometimes

#

I changed the code in this onEvent('item.tags', event => { beginnerLockedMods.forEach(mod => { let modItems = event.get(mod).getObjectIds() modItems.forEach(item => { if (!beginnerItemBlackList.includes(item)) { beginnerTagBlackList.forEach(blacklistTag => { let tagsItems = event.get(blacklistTag).getObjectIds() if (!tagsItems.contains(item)) { event.add('crafted:stage/automation', item) } else { return; } }); } else { event.add('crafted:stage/automation', item); } }); }); });

#

But for some reasons now no items get tagged

astral mirage
#

yes

rocky ravine
#

Ok I'm reloading

#

I got this error

astral mirage
#

are you up to date on kjs and rhino?

rocky ravine
#

I think so let me check

astral mirage
astral mirage
rocky ravine
#

It's already reloading

#

Will maybe ItemStackJS#getItemIds() work?

astral mirage
#

that is exactly what you are already using

stiff fableBOT
#

Kubejs has a feature known as beans which allows you to make scripts a tad more readable.
Anything getXy() can be gotten with xy, anything setXy(value) can be set with xy = value and anything isXy() can be checked with just xy.

This allows us to shorten our code! For example, to get a list of all online players you can do: event.getServer().getPlayers(). With beans this can be shortened to event.server.players!

Note that get and is beans only work if the method has no parameters. This means a method like getHeldItem(InteractionHand hand) cannot be shortened to heldItem.
For set the method needs to have a single parameter.

astral mirage
#

well, technically IngredientJS#getItemids()

#

but ItemStackJS implements IngredientJS

rocky ravine
#

I don't really know how the object is coded so for me just getting the direct value using just xy a private method and getXy() a public method

rocky ravine
#

It's the server.txt log

rocky ravine
#

Any updates? Or something I could do?

warm light
#

unfortunately, that might take a while as im really busy rn

rocky ravine
#

And is there maybe another function that I could use that doesn't throws this exception?

silk ivyBOT
#

@rocky ravine Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!