user.getScoreboardTags() in Item TypedAction<Result> use() returns an empty list unless the tag was added code side
JSJBDEV opened this issue ยท 12 comments
typing in user.getScoreboardTags() where user is the PlayerEntity instance from the stated class, returns and empty set unless the scoreboard tag was added by the code itself, for example:
if i give myself the tag "foo" in game using the /tag command then print the toString value of user.getScoreboardTags() "foo" does not show up, but if I add a tag using user.addScoreboardTag("foo") then print the toString value the tag shows up.
Is this meant to happen, or is this a bug?
ive tested it between runClient instances and during a single one to check its not to do with the name value
If you are doing like MinecraftClient.getInstance().player.getScoreboardTags()
the tags definitely does not show up, because the tags added by /tag
command are only added to server-side player. It is strongly suggested not to touch scoreboard tags on client-side entities. If you want to find a player on the server, iterate through the player list on server in like one of your server-side executed methods, such as server tick callbacks.
public TypedActionResult<ItemStack> use(World world, PlayerEntity user, Hand hand) {
if(hand==Hand.MAIN_HAND && world.isClient && QuestWeaver.quests==null)
{
QuestWeaver.quests= QuestAssembly.assemble(world);
}
user.addScoreboardTag("first_quest");
Set<String> tags = user.getScoreboardTags();
tags.forEach(System.out::println);
if(hand==Hand.MAIN_HAND && world.isClient)
{
MinecraftClient.getInstance().openScreen(new QuestScreen(new LiteralText("screen"),tags));
}
return super.use(world, user, hand);
}```
this is on a custom item @liach the only tag that shows up is the one added here, any tag added using the /tag command does not show up
This never works because you are doing it on client, and tags only exist on server
Is your quest some helper on client or is it supposed to be part of the game on logical server
the user.getScoreboardTags() part is outside of the isClient If statement, sure that means it should operate wherever possible? the tags kinda need to be in both but I can pass them from server to client if necessary
Oh I have a feeling I know where you coming from now, the tags will only be added on the serverSide pass of this method but because they are only being used by a client side method that doesnt work, right?
so I would need to make the Set of tags from outside that method? @liach
Just come to https://discordapp.com/invite/v6v4pMv and ask
will try and find a way through it but thanks for your help, ive also joined the discord just in case
does the "use" method count as a client side entity then? @liach