#Give a player a game stage on getting an item
76 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
you would use either the item pickup server event or the player inventory changed server event
PlayerEvents.InventoryChanged would be the one I recommend using since it accounts for all ways that you can get an item in your inventory
If you only want to give the game stage when an item is picked up specifically then you can use ItemEvents.pickedUp
Thanks for this!
Still wish they had examples for these on the wiki
yeah the wiki is in a terrible state. It has less and less examples with each version
I often use Object.keys(event).forEach(e=>console.log(e)) to figure out what properties an event has
probejs would also be useful if you can get that set up properly
I see
I don't think javascript works like that
use event.getItem() to get the item involved with the event
not sure what property of event.getItem() you use to get the tags though
Try event.getItem().getTags()
try this code
PlayerEvents.inventoryChanged(e => {
const item = e.getItem();
if (item.getTags().includes('forge:tools/iron')) {
e.server.runCommandSilent(`say Works lol`);
}
})
Should have pad more attention to the js part of web design class
But in my deffence I wouldn't think it would help me in mc mod packs
Still no works
riiiiiiiiiiiiip
If you're using FTB Quests you could run a command to give a player a stage when getting an item.
as a quest reward
I am not
okay let me open up a testing instance to create some code
and make sure it works before sending
wait i think i know whats wrong with this code
i may be wrong, but i'm pretty sure you should use .contains() instead of .includes()
also you can probably use e.player.tell() instead of e.server.runCommandSilent()
this is just a temp thing
that probably will be what I end up doing but i don't see a reason to change rn
fair
problably just gonna use the action bar for ascetics
first i gotta make this work tho ofc
aaaaaand no dice
im checking some old code of mine relating to checking tags rn
hopefully it contains something helpful
okay in my testing instance i used /kubejs hand to check an iron tools tags and it doesn't have a forge:tools/iron tag
weird
let me try with a different tag then
ok still doesn't work
hold on let me Frankenstein something together
because my code worked for individual items
yeah im also trying to cobble together unrelated code bits in an attempt to make something work
i genuinely dont know why it isnt working though
wait i have a kind of hacky solution
const tools = ['minecraft:iron_pickaxe','minecraft:iron_axe','minecraft:iron_shovel']
PlayerEvents.inventoryChanged(e => {
if (tools.includes(e.item.id)) e.player.tell('player has iron tool')
})```
list all iron tools in the tools array
and the game should detect if a player has one of them on an inventory update
aaaaaaaaaaaaa i fuckin guess i can do that
it won't automatically take from the tags but it should work
tags would just be so much nicer tho
hopefully someone with actual experience comes along and helps you
thanks for trying at least
o shit
const tools = ['minecraft:iron_pickaxe','minecraft:iron_axe','minecraft:iron_shovel']
PlayerEvents.inventoryChanged(e => {
if (e.item.hasTag('forge:tools/iron')) e.player.tell('player has iron tool')
})```
👍