Posted January 23, 20178 yr I made a capability that saves 1 int in the player. It acts as the amount of money they have in their account. Upon death or relog, the cap resets back to it's default value. It works PERFECTLY otherwise. I've asked multiple people. 5/6 don't know how caps work, the remaining 1/6 couldn't figure out the issue because my cap is basically a carbon copy of his, yet his persists. Anyways, capability package: https://github.com/LordSaad44/Cash-Shop/tree/master/src/main/java/me/lordsaad/cashshop/api/capability Class that's hooking the cap to the player: https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/api/ModCapabilities.java Packet: https://github.com/LordSaad44/Cash-Shop/tree/master/src/main/java/me/lordsaad/cashshop/common/network Registering the cap: https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/common/CommonProxy.java#L26 (registering the event down in postInit) (works perfectly, i breakpointed) I tried the respawn event (PlayerEvent.Clone), but the original entity in the event had it's cap reset as well, so i was copying the default reset value from the original entity over to the new entity. Respawn(clone) event: https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/common/core/EventHandler.java
January 23, 20178 yr Because all you're doing on the respawn/clone event is telling the client about the old data. You're not actually transferring the data to the new capability. 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.
January 23, 20178 yr Author I just uploaded a new commit with the fix you suggested, you have a point, i should be setting it. But that actually didn't work. It failed with the same result. https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/common/core/EventHandler.java
January 23, 20178 yr Author Ignore the purse for a sec. I was trying a lot of things and didn't update everything per solution. https://github.com/LordSaad44/Cash-Shop/blob/master/src/main/java/me/lordsaad/cashshop/common/command/CommandWallet.java#L49 I'm updating the cap here server side and it works perfectly. It's clone copying that's dysfunctional...
January 24, 20178 yr Author How is it not updating though? I have a hud thing that renders the int on my hud, running the command (which sends a sync packet) updates it on my hud as well, therefore I can only assume it's being sent and read properly. Is the packet insufficient? What would I have to do?
January 24, 20178 yr Author So basically make a packet that sends from client to server that acts on the cap. Right? That's what I'm getting here. That should be easy.
January 24, 20178 yr No. Your capability exists serverside, this is where you make ALL CHANGES. When a change is made you send a packet to the client to update the display. 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.
January 25, 20178 yr Author No no no... My display is updating properly. Getting the cap seems to return the proper one as well. So it's definitely working CLIENT side. But the clone event returns the default cap, so it's not changing on the SERVER. So i have to send the packet from client to server, right? You said it exists on the server, but I'm updating the value from the client.
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.