Posted July 29, 20214 yr 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?
July 29, 20214 yr 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?
July 29, 20214 yr Author 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
July 29, 20214 yr 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
July 29, 20214 yr Author 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.