HalestormXV Posted February 20, 2018 Posted February 20, 2018 So I have a Capability. It is awesome...I love it. However if I make changes to it or want to reflect a GUI it needs to be synced with the server/client etc. No problem. I have a packet that takes care of that and works fine. Quite literally: PacketHandler.INSTANCE.sendTo(new PacketSyncRCLevel(rc_Lvl), (EntityPlayerMP)sender) Great and fantastic. It gets the job done. Displays my debug message to show it is working, etc. Except this means that every time I want to sync my Capability I will have to call this (the last argument will obviously change as well as the rc_LvL variable depending on what I am doing) So say I want to auto-sync whenever the value changes. Where would be the best place to do that? Within the interface of the capability itself? Within its handler? This is more of just a curiosity question because although I don't have to sync much of anything right now I know in the future if I want to add a GUI, level bar, or whatever a sync will need to occur. Quote
Draco18s Posted February 20, 2018 Posted February 20, 2018 1 hour ago, HalestormXV said: Where would be the best place to do that? I'm voting to close as "Too Broad" Wait, this isn't Stack Overflow. That said, this is pretty much up to you. You can do it via setter methods in the capability if you want. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
HalestormXV Posted February 20, 2018 Author Posted February 20, 2018 44 minutes ago, Draco18s said: I'm voting to close as "Too Broad" Wait, this isn't Stack Overflow. That said, this is pretty much up to you. You can do it via setter methods in the capability if you want. Got it, so anytime the method called to update the value of the capability I can call the sync to update it with the same value and it should be fine. So for example, @Override public void gainRuneLevel(int value) { int clampValue = this.runeLevel - value; this.runeLevel = MathHelper.clamp(clampValue, this.min_runeLevel, this.max_runeLevel); } So I can adjust that method to take the player that this method got called on as an added argument and right below the this.runeLevel I can add to call to a SyncMethod that will take care of sending packets and what not and it should be fine? I mean obviously this is just conceptual and I won't know anything until I try it out but I wanted to gather some thoughts and ideas first. 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.