#how to get all item ids from one mod
114 messages · Page 1 of 1 (latest)
Once your question has been answered, please close this post with </resolve:1050379261372006400> command!
Ingredient.of('@mekanism').stacks
then you can go through them like
Ingredient.of('@mekanism').stacks.forEach(item => {})
yeah i read about it but because im a bit curious could i ask what would .stacks do
i rea dabout is the same as just looking at some code from someone else and not understanding it lmao
you have the option of using .stacks or .itemIds
stacks gives you a list of ItemStack
itemIds gives you a list of just item IDs
imma look a bit into what an itemstack is and be back for some more questions 🙂
ItemStack is basically an item that you have in your inventory with all the data it holds
so things like count, ID, tags, etc
NBT
ok
wait so what could be an example of what i would get if i called .stacks on @botania
lets say you have the apothecary from botania
yeah
with itemIds you only have botania:apothecary, but with stacks you have the equivalent of Item.of('botania:apothecary')
i dont really do voicechat 
ah ok
but im happy to answer if i know the answer
so what would item.of return on it
thanks
.
thats the item stack, so you can have stuff like i mentioned above

ok
the item stack basically holds all info about that specific item
ok
one of which is the ID
as far as i know that would just convert it to a different type of list, so you can have other methods to use on it
yeah isee
well now the second part i was gonna ask is what does the "@mekanism" part mean
ok
you can also replace with /^mekanism:/
its regex, ^ means "start with" so basically says "any ID that starts with mekanism:"
yes, instead of "something here" you do /something here/
ok
so now im confused about what events are
as you shouldnt be able to just get ids from nowhere
it gets the IDs from the game's registry
which in super simple terms, is a list of all items in the game
ok
so doing .stacks basically tells it its getting it fro mthe registry or am i stupid
/ just not understanding anything
yeah, it basically gets the items with your "search term" and gives you a list
ah nice
so its like some function?
or whatever of the million things it could be
i think its a beaned function
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.
yeha yeah
and to be sure, that would return an array right?
and it would be like mechanism:atomically_reactive_grenade or whatever such
yes
ok
if you wanna know more about stacks and itemIds here they are:
Stacks: https://github1s.com/KubeJS-Mods/KubeJS/blob/1.18/main/common/src/main/java/dev/latvian/mods/kubejs/item/ingredient/IngredientJS.java#L270
ItemIDs: https://github1s.com/KubeJS-Mods/KubeJS/blob/1.18/main/common/src/main/java/dev/latvian/mods/kubejs/item/ingredient/IngredientJS.java#L294
and you can see they are functions "pre-beaned"
ok
ok
als owould ingredient become an array or do i need to do something else to get it to be one
im just curious about it
probs wont use it like that
when ido ingredient.of does that mean ingredient becomes an array
in a way yes
or whatever it could
but you still need those 2 functions
so i could later use ingredient to do a foreach?
im guessing no as its probably used to create an array that is used once and then never used again
i mean you can reuse it as many times as you want
ok
onEvent('tags.items', event => {
event.add('environmentz:warm_armor', '@mcda')
});```
also why does this work

like my reaction was wtf how did my friend make this work
i think the event might be item.tags
im guessing this works right? js Ingredient.of('@mcda').itemIds.forEach(id => { event.add('environmentz:warm_armor', id) })
try this
it is tags.items
This event is fired when a tag collection is loaded, to modify it with script. You can add and remov...
1.18.2
i also see this, kinda confused which one is the correct one lmao
lmao
if you put a console.log('test') in that event, will it show up in the server logs?
Paste version of server.txt from @midnight pivot
thx gnom
thanks gnome
try it with this just for testing
ok
Cool thing... My script wasnt working correctly so i had to fix my config. Every change i did was overwritten i will try again today
@midnight pivot Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!