Jump to content

Recommended Posts

Posted

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

 

 

Posted

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.

Posted

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?

Posted

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.

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.