urbanxx001 Posted September 28, 2020 Share Posted September 28, 2020 (edited) I have a RightClickEmpty event that needs to pass the server player into a method from an item class. However, event.getPlayer() only returns the client player. I heard that it should be done with packet handlers then, is that right? Alternatively, I could achieve the same thing with the onArmorTick method in the item class. But for that I would need to detect right clicking, which doesn't seem possible without an event. Edited September 28, 2020 by urbanxx001 Quote Link to comment Share on other sites More sharing options...
ChampionAsh5357 Posted September 28, 2020 Share Posted September 28, 2020 If this is your item, you should not need an event. You can simply override Item#onItemRightClick and do the logic there. Quote Link to comment Share on other sites More sharing options...
urbanxx001 Posted September 28, 2020 Author Share Posted September 28, 2020 (edited) Yes but it needs to happen when the item, which is armor, is equiped, i.e. it's not in the hotbar. Edited September 28, 2020 by urbanxx001 Quote Link to comment Share on other sites More sharing options...
ChampionAsh5357 Posted September 29, 2020 Share Posted September 29, 2020 Then you would use PlayerInteractEvent$EntityInteract or PlayerInteractEvent$EntityInteractSpecific then to get when the user right clicks an entity. From there, you can cancel the event as needed and check the armor slots for what you are looking for. Quote Link to comment Share on other sites More sharing options...
urbanxx001 Posted September 29, 2020 Author Share Posted September 29, 2020 (edited) It's not for interacting with another entity though, which is why I'm using PlayerInteractEvent$RightClickEmpty. Or are you recommending the other two methods as they can access ServerPlayerEntity? My main issue is getting the server player. I can already get the slot from player.getItemStackFromSlot(EquipmentSlotType.CHEST); Edited September 29, 2020 by urbanxx001 Quote Link to comment Share on other sites More sharing options...
ChampionAsh5357 Posted September 29, 2020 Share Posted September 29, 2020 Ah, I'm sorry. I'm quite tired and misread for some reason. So yes, you would need a packet setup. As the javadoc says, 'The server is not aware of when the client right clicks empty space with an empty hand, you will need to tell the server yourself.' However, I'm assuming this handles only the case when there is no item in the hand while the armor is on. You would also need to hook into RightClickItem to cover all use cases. However, that one is called on the server. So you can create a separate method to call the packet instance and the other event instance from. 1 Quote Link to comment Share on other sites More sharing options...
urbanxx001 Posted September 29, 2020 Author Share Posted September 29, 2020 Ah ok, thank you so much! I'll create a packet and cover both events then. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.