Turtledove Posted May 11, 2020 Posted May 11, 2020 I'm overriding vanilla sword behavior, such that the player cannot swing their sword unless a certain amount of ticks have passed, which is determined by logic done on the server. I've got everything already setup, and the packets are successfully sent to client. However, I'm not sure how to retrieve this information within my input handler class's static mouse event, from my message handler. Is there a better way of doing this than creating a static member variable inside the event handler class? Quote
kaydogz Posted May 11, 2020 Posted May 11, 2020 On 5/11/2020 at 5:34 PM, Turtledove said: I'm overriding vanilla sword behavior, such that the player cannot swing their sword unless a certain amount of ticks have passed, which is determined by logic done on the server. I've got everything already setup, and the packets are successfully sent to client. However, I'm not sure how to retrieve this information within my input handler class's static mouse event, from my message handler. Is there a better way of doing this than creating a static member variable inside the event handler class? Expand Don't create a static variable. Use a capability to keep track of the cooldown per player. Quote
Turtledove Posted May 11, 2020 Author Posted May 11, 2020 On 5/11/2020 at 6:00 PM, kaydogz said: Don't create a static variable. Use a capability to keep track of the cooldown per player. Expand I already have the cooldown set up as a capability serverside with IPlayerData, which is also where it's incremented every tick. In my server to client message handler, do I just set that variable in the same class (but on the client) and access it as normal in the event handling method? So I guess in that case there'd be a server and client version of my IPlayerData running at the same time, correct? Quote
kaydogz Posted May 11, 2020 Posted May 11, 2020 On 5/11/2020 at 6:04 PM, Turtledove said: I already have the cooldown set up as a capability serverside with IPlayerData, which is also where it's incremented every tick. In my server to client message handler, do I just set that variable in the same class (but on the client) and access it as normal in the event handling method? So I guess in that case there'd be a server and client version of my IPlayerData running at the same time, correct? Expand Yes and remember you need to sync the values on each side. Quote
Turtledove Posted May 12, 2020 Author Posted May 12, 2020 On 5/11/2020 at 6:53 PM, kaydogz said: Yes and remember you need to sync the values on each side. Expand Got it working flawlessly on the first try, thanks. Quote
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.