Jump to content

Check if players on server are holding a specific item from client side?


Recommended Posts

Posted

I want to check all players on a server if they are holding a specific item. I think I understand how to get the item they are holding, but I dont know from which event to check?

Posted
Just now, GMqwerty said:

I want to check all players on a server if they are holding a specific item. I think I understand how to get the item they are holding, but I dont know from which event to check?

when exactly do you want to check this?

Posted
Just now, GMqwerty said:

I want to run some code when a player holds a sword, so I guess I would have to check constantly? i dont know tho

you can use TickEvent.WorldTickEvent than get all players from the world via World#players
but note, TickEvents have two phases (START, END) choose one and they run on server and on client check this via TickEvent#side

Posted
3 hours ago, diesieben07 said:

Note that the client does not know about all players. This is something that should be done server side using LivingEquipmentChangeEvent so that you don't have to constantly check all players.

Why do you want to do this client side?

yea ik, i just want to check what items players near me hold, i am making a mod that shows you if someone is going to attack you, so if someone is holding a sword and is in a 10 block radius it shows you a message

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.